Objectives

  • To understand various data structures and searching and sorting techniques;
  • To analyze these techniques in relation to a particular problem;
  • To implement these techniques within a program.

Problem Description

As Part of my research I will be collecting a lot of data containing information on various ships around the world and their positions on the globe. This data comes in the form of 2 different types of messages. One type of message contains a series of static details about a ship, the other is a position report that contains some additional information of the ships current status. These two messages are linked only by the MMSI value. A ships MMSI is its internationally unique id number.

In this assignment I would like you to develop an efficient way of filtering some data files and combining ship static information with position reports.

Task Requirements

The program takes 2 command line argument for the filenames, these files will contain Json arrays that. The first file should point to a file containing ship information (such as name, MMSI, and a number of other things) the second should point to a file that contains position reports (each containing the ships MMSI, time of transmission, Latitude, Longitude, and other information)

See appendix for sample file input and output formats.

Read the 2 Jsontext file using the Gsonpackage and out put the screen the minimum and maximum for each of the following variables. (to make it easier to perform queries that are within the data range, this should probably be reprinted every time you display a menu)

  • Latitude
  • Longitude
  • Time of transmission

Once the data is loaded, you system will need to be able to satisfy the following queries .

Search to find a ships details based, given its full name by the user.

Output a ships details (if they exist) and every position report given an MMSI by the user.

Output a ships details (if they exist) and every position report given an MMSI and a time range by the user.

Output all position reports within a given range of Latitude, Longitude, and Time of Transmission; and include the full details of the ship with each position (if the ships details exist).

Outputs for the last three options should be prettified Json that is saved to a file specified by the user. Output of position reports should be in chronological order with the Json array.

Along with this functional aspect of the assignment you will need to submit a small text file with your code that explains the algorithms you chose and why, and any modifications or new algorithms you have implemented to solve this particular problem

You can make use of only 2 generic containers, Arraylist and/or Vector, or a data structure of your own, such as a tree. No other inbuilt data structures are to be used and the sorting and searching algorithms must be programmed by you.

Appendix

Input: Ship details

[{
"idmessage":"27301", "idsession":"362", "time_stamp_system":"2017-01-20 14:51:14", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"ODLK1", "name":"ODLXJ KWW", "type_of_ship_and_cargo":"0", "bow_to_possition_unit":"212", "stern_to_possition_unit":"71", "port_to_possition_unit":"22", "starboard_to_possitio_unit":"22", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
}
, {
"idmessage":"27302", "idsession":"362", "time_stamp_system":"2017-01-20 14:51:15", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000002", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"XJEH1", "name":"XJE HJS", "type_of_ship_and_cargo":"10", "bow_to_possition_unit":"164", "stern_to_possition_unit":"55", "port_to_possition_unit":"19", "starboard_to_possitio_unit":"19", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
}
, …
{
"idmessage":"27500", "idsession":"362", "time_stamp_system":"2017-01-20 15:29:17", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000200", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"MNCZ1", "name":"MNC", "type_of_ship_and_cargo":"30", "bow_to_possition_unit":"45", "stern_to_possition_unit":"15", "port_to_possition_unit":"9", "starboard_to_possitio_unit":"9", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
}
]

Input: Ship Positions

[{
"idmessage":"28342077", "idsession":"362", "time_stamp_system":"2017-01-20 14:52:14", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320335089449", "position_accuracy":"0", "longitude":"-0.30209106951849", "latitude":"35.858197688993", "COG":"342.10849091998", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"14"
}
, {
"idmessage":"28342078", "idsession":"362", "time_stamp_system":"2017-01-20 14:53:15", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320234365784", "position_accuracy":"0", "longitude":"-0.30347662312939", "latitude":"35.861676165834", "COG":"342.10922598276", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"15"
}
, {
"idmessage":"28342079", "idsession":"362", "time_stamp_system":"2017-01-20 14:54:15", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320133830513", "position_accuracy":"0", "longitude":"-0.30485952405955", "latitude":"35.86514798304", "COG":"342.10995970588", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"15"
}
, …
{
"idmessage":"28346776", "idsession":"362", "time_stamp_system":"2017-01-20 15:33:58", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000131", "navigation_status":"0", "ROT":"0", "SOG":"82.149456445689", "position_accuracy":"0", "longitude":"14.382186854995", "latitude":"35.816096509973", "COG":"272.4168768769", "trueheading":"272", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"58"
}
]

Output: Ship details and path for a single ship

{"ship" : {
"idmessage":"27301", "idsession":"362", "time_stamp_system":"2017-01-20 14:51:14", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"ODLK1", "name":"ODLXJ KWW", "type_of_ship_and_cargo":"0", "bow_to_possition_unit":"212", "stern_to_possition_unit":"71", "port_to_possition_unit":"22", "starboard_to_possitio_unit":"22", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
},
"positions":[{
"idmessage":"28342077", "idsession":"362", "time_stamp_system":"2017-01-20 14:52:14", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320335089449", "position_accuracy":"0", "longitude":"-0.30209106951849", "latitude":"35.858197688993", "COG":"342.10849091998", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"14"
}
, {
"idmessage":"28342078", "idsession":"362", "time_stamp_system":"2017-01-20 14:53:15", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320234365784", "position_accuracy":"0", "longitude":"-0.30347662312939", "latitude":"35.861676165834", "COG":"342.10922598276", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"15"
}
, {
"idmessage":"28342079", "idsession":"362", "time_stamp_system":"2017-01-20 14:54:15", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320133830513", "position_accuracy":"0", "longitude":"-0.30485952405955", "latitude":"35.86514798304", "COG":"342.10995970588", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"15"
}
, {
"idmessage":"28342093", "idsession":"362", "time_stamp_system":"2017-01-20 14:55:15", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000001", "navigation_status":"0", "ROT":"0", "SOG":"24.320033087498", "position_accuracy":"0", "longitude":"-0.30624522137147", "latitude":"35.868626820647", "COG":"342.11069498043", "trueheading":"342", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"15"
}
]]

Output: Ship details and positions of ships within a given region and time

{
"idmessage":"28342085", "idsession":"362", "time_stamp_system":"2017-01-20 14:54:47", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000007", "navigation_status":"0", "ROT":"0", "SOG":"67.806516678587", "position_accuracy":"0", "longitude":"-3.5114907531731", "latitude":"36.711612999692", "COG":"135.60579633104", "trueheading":"136", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"47", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"XXBP1", "name":"XXBF PSK", "type_of_ship_and_cargo":"10", "bow_to_possition_unit":"20", "stern_to_possition_unit":"7", "port_to_possition_unit":"6", "starboard_to_possitio_unit":"6", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
}
, {
"idmessage":"28342086", "idsession":"362", "time_stamp_system":"2017-01-20 14:54:48", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000008", "navigation_status":"0", "ROT":"0", "SOG":"91.089882137445", "position_accuracy":"0", "longitude":"-3.202969530337", "latitude":"43.393700261955", "COG":"19.85565522845", "trueheading":"20", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"48", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"DXIZ1", "name":"DXI", "type_of_ship_and_cargo":"30", "bow_to_possition_unit":"90", "stern_to_possition_unit":"30", "port_to_possition_unit":"13", "starboard_to_possitio_unit":"13", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
}
, {
"idmessage":"28342087", "idsession":"362", "time_stamp_system":"2017-01-20 14:54:49", "NMEA_string":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "processed":"1", "MMSI":"0000000009", "navigation_status":"0", "ROT":"0", "SOG":"43.389999936329", "position_accuracy":"0", "longitude":"-9.6349596393461", "latitude":"30.417366842833", "COG":"180.27424396315", "trueheading":"180", "maneuver_indicator":"0", "RAIM_flag":"0", "diagnostic_information":"0", "time_stamp_seconds_only":"49", "AIS_version":"0", "IMO_number":"xxxxxxxxxx", "callSign":"SLEP1", "name":"SLEX PHMTI", "type_of_ship_and_cargo":"0", "bow_to_possition_unit":"210", "stern_to_possition_unit":"70", "port_to_possition_unit":"22", "starboard_to_possitio_unit":"22", "type_of_position_fixing_divice":"1", "ETA":null, "destination":"", "last_static_draught":"0", "DTE":"127"
}

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.