Reading and processing information from a database » History » Revision 3
Revision 2 (Rafael Bailon-Ruiz, 2020-11-12 18:15) → Revision 3/4 (Rafael Bailon-Ruiz, 2020-12-03 18:32)
p{border: solid 1px #00008B; padding: 1em; margin: 1em; background: #EEF}. %{color:darkblue; font-weight: bold; font-size: large}Note:% *This page explains the legacy CAMS database format. For information about the current format go to [[Working with the database]]!*
h1. Reading and processing information from a database
The purpose of this page is to show you how to use the CAMS database and how to process data inside without modifying stored data.
{{toc}}
h2. The database
The databases objects here are SpatializedDatabase and its subclass, NephelaeDataServer. While being both usable, only the NephelaeDataServer is being used to register data and play simulations / real-flights. The reason is because this version is tailored to the CAMS needs (notification methods, uav ids, variable names...).
Because of these reasons, this paragraph will only talk about the NephelaeDataServer.
The NephelaeDataServer uses SpbEntry objects to register data. These objects have a Position to know where the data has been found, aswell as a list of tags to know what type of data is inside. The data attribute of SpbEntry are either AircraftStatus object or SensorSample during simulations.
You can retrieve data from the database using the __getitem__() function or the find_entries() (see the getitem function as a sugar syntax of the find entries function). This will return a list of SpbEntries.
Usage exemple :
<pre><code class=python>db = NephelaeDataServer.load('path/to/some/file')
db.find_entries(keys=keys, tags=['RCT']) # Finding all the SpbEntry related to the RCT</code></pre>
NephelaeDataServer comes also with notification methods, these methods are add_gps(), add_status() and add_sample().
These methods are always called when an Aircraft is sending data to the database, notifying these methods.
h2. Process data
Since the data registered in the database is raw data, we use objects that processes copies of registered data.
Why registering raw data ? Because of reuse ability. This way we can take this data to reproduce an experiment and try differently.
To process copies of registered data, we use a dataview. It's a sort of "view" that process copies of registered data. There is a lot of dataviews types, each for a specific usage.
A non-exhaustive list of usages :
* Fetching from the database
* Process a certain type of sample
* Fetching status of an UAV
* Reorganize data
A dataview can generally have multiple parents and children dataviews. Fetching data from a dataview will return the result of all the parent dataviews, applying the different data process. Once finished, the dataview will apply its own data process and return it.
h2. New database format
h3. Data model
The CAMS database model is based on the OGR data model and the OGC OpenPackage specification.
* Dataset (= OGR Dataset)
** Collection (= OGR Layer)
*** Record (= OGR Feature)
**** Mandatory fields:
***** geom [automatic, the location of the record] (= OGR Point 3D Geometry)
***** t : (=OGR OFTDateTime)
***** producer : (=ogr OFTString with 80 chars)
**** Optional fields:
***** data associated with the records. They can be of integer, real and text types.