Reading and processing information from a database » History » Version 4
Rafael Bailon-Ruiz, 2020-12-04 12:26
1 | 4 | Rafael Bailon-Ruiz | 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]]* |
---|---|---|---|
2 | 3 | Rafael Bailon-Ruiz | |
3 | 1 | Rafael Bailon-Ruiz | h1. Reading and processing information from a database |
4 | |||
5 | 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. |
||
6 | |||
7 | 2 | Rafael Bailon-Ruiz | {{toc}} |
8 | |||
9 | 1 | Rafael Bailon-Ruiz | h2. The database |
10 | |||
11 | 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...). |
||
12 | Because of these reasons, this paragraph will only talk about the NephelaeDataServer. |
||
13 | 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. |
||
14 | 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. |
||
15 | Usage exemple : |
||
16 | <pre><code class=python>db = NephelaeDataServer.load('path/to/some/file') |
||
17 | db.find_entries(keys=keys, tags=['RCT']) # Finding all the SpbEntry related to the RCT</code></pre> |
||
18 | NephelaeDataServer comes also with notification methods, these methods are add_gps(), add_status() and add_sample(). |
||
19 | These methods are always called when an Aircraft is sending data to the database, notifying these methods. |
||
20 | |||
21 | h2. Process data |
||
22 | |||
23 | Since the data registered in the database is raw data, we use objects that processes copies of registered data. |
||
24 | Why registering raw data ? Because of reuse ability. This way we can take this data to reproduce an experiment and try differently. |
||
25 | 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. |
||
26 | A non-exhaustive list of usages : |
||
27 | |||
28 | * Fetching from the database |
||
29 | |||
30 | * Process a certain type of sample |
||
31 | |||
32 | * Fetching status of an UAV |
||
33 | |||
34 | * Reorganize data |
||
35 | 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. |
||
36 | 2 | Rafael Bailon-Ruiz | |
37 | h2. New database format |
||
38 | |||
39 | h3. Data model |
||
40 | |||
41 | The CAMS database model is based on the OGR data model and the OGC OpenPackage specification. |
||
42 | |||
43 | * Dataset (= OGR Dataset) |
||
44 | ** Collection (= OGR Layer) |
||
45 | *** Record (= OGR Feature) |
||
46 | **** Mandatory fields: |
||
47 | ***** geom [automatic, the location of the record] (= OGR Point 3D Geometry) |
||
48 | ***** t : (=OGR OFTDateTime) |
||
49 | ***** producer : (=ogr OFTString with 80 chars) |
||
50 | **** Optional fields: |
||
51 | ***** data associated with the records. They can be of integer, real and text types. |