# Data Analysis, Simulation and Visualization for Environmentally Safe Maritime Data
## 4 Marine Simulation System
### System Programming Details  
The main database schema adopted is illustrated as Figure 7:  
The first table contains the position, speed, orientation, status (such as anchored, cruising, etc.) and the time of message reception by the receiver. The second table refers to the ship's static details and is connected to the dynamic data via the mmsi field. The static data are useful when extracting the flag of convenience, size, age, etc. Finally, the third table contains details on the type of the ship, and the hazard level of cargo. From this table, the preprocessing tools is creating the spatio-temporal data for the smallest granularity level, which is set to a day. The aggregated data are stored on the following database table as shown as Figure 8:  
Figure 6: The outcome of the clustering approach.  
Figure 7: Database Schema.  
Each RoI is assigned a unique key (ID). All the other fields correspond to the criteria mentioned earlier. Finally, the outcome of the clustering process is coded as field color (numeric) on a scale from \(-1\) to \(5\), \(-1\) meaning no hazard and \(5\) meaning very dangerous area.  
In order to record ship movements within an area, we split the AEGEAN area into spatial polygons and the application asks the database about passing ships, speed and hazard level. Since the RoI size is adjustable, data preprocessing from database would require numerous database I/O operation. Therefore, we have created a series of classes in Java that could help this process by performing a plethora of spatial operations in memory. Figure 9 shows these class connections.  
The main class is called GMap. Its duty is to create a map and the separation into RoI, each one with the marine criteria. The separation of the map into regions is achieved by providing the top left point, the size of rectangles (squares) and the number of areas, horizontally and vertically. The predefined values are the separation start point, using Latitude 41.0000001 and Longitude 18.0000001 in order to cover the Hellenic Seas. Afterwards, the CustomRectangle class creates the remaining RoI, also calling the method for retrieving data from the database and preprocessing them to find the criteria. The CustomRectangle object extends the LatLonBoundingBox object, from the Spheres library, which provides a spatial polygon object. When reading data from database, GMap creates a connection and asks for ship information, creating a Vessel object along with all the ship's characteristics. As described earlier, the connection closes and all spatial operations and queries are performed using the Spheres  
Figure 8: The simulation data are stored in a separate table.  
Figure 9: Class connection flowchart.  
library. As soon as all vessels are identified (using the Marker object) in each RoI, the hazard criteria are calculated, as well as density. In order to retrieve the wave height from POSEIDON, the Gmap object is using a method (called waves) for asking a Live Access Server (LAS) using the center of each RoI as anaphora. The LAS usually responds as text and then the Gmaps object aggregates values from hours to per day granularity. Subsequently, the ClusterProcess method is called in order to cluster the created dataset. ClusterProcess can be called with different arguments as regards to the clustering method and its internal parameters. Finally, a reconnection to the database is performed in order to update clustering outcome (the danger level of each RoI) into table mydata (field color).