UCL-ShippingGroup / pyrate

Python AIS Tools Environment
MIT License
25 stars 10 forks source link

Structure of class AISdb doesn't reflect desired usage #25

Open willu47 opened 8 years ago

willu47 commented 8 years ago

In the way in which we're currently using pyrate, the AISdb class (and to a lesser extent the Table class) does not lend itself to easy reuse.

Here's a typical use case: @ejokeeffe ingests AIS data into the database using AISdb. He need to run the extrapolation algorithm, and so writes a new class, inheriting AISdb. The data he has is of a different structure to that assumed in the AISdb specification of the db columns and tables, so he has to rewrite most of the code to define a database structure which aligns with the data, and the algorithm he wishes to run on the data. He writes a separate algorithm to ingest the data from csv files into the database, based on algorithm/aisparser.py.

@willu47 comes along, and adds some database tables to ingest vessel characterisation data into the same database. He extends @ejokeeffe's class, adding more tables and columns to the tables. He writes a separate algorithm to ingest the data from csv files into the database, again based on algorithm/aisparser.py.

@tristanps suggests running the same vessel analysis algorithm on a different data set, which has a different structure to the previous vessel characterisation data. @willu47 now makes small modifications to the vessel parsing algorithm to map the columns of the new csv file to the predefined database columns.

It would be good to work out a design which allows more reuse of code, given that its going to be exceedingly common to:

  1. receive similar data in different formats
  2. require database tables to store the AIS data, but with different headings and data types (e.g. duration instead of timestamps)