Skip to content

Commit

Permalink
fix(scenario-database): Fixed database type affinities (#342)
Browse files Browse the repository at this point in the history
* fix(scenario-database): Fixed database type affiliations
* fix(scenario-database): changed type affinity FLOAT to REAL
* made variables in TABLES-class final

Signed-off-by: Moritz Schweppenhäuser <[email protected]>
  • Loading branch information
schwepmo committed Aug 21, 2023
1 parent 8eef354 commit 8f038ca
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ public Collection<Way> getWays() {
public Builder addConnection(Connection connection) {
database.connections.put(connection.getId(), connection);

//FIXME complete the description
//additionally, make sure dependent nodes ...
// additionally, make sure dependent nodes are added
for (Node node : connection.getNodes()) {
node.addConnection(connection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,30 @@ private void initTables() throws SQLException {
Statement statement = sqlite.connect();
// create tables
// integrity
statement.executeUpdate("CREATE TABLE " + TABLES.PROPERTIES + " (id String UNIQUE, value TEXT)");
statement.executeUpdate("CREATE TABLE " + TABLES.PROPERTIES + " (id TEXT UNIQUE, value TEXT)");
statement.executeUpdate("INSERT INTO " + TABLES.PROPERTIES + "(id, value) VALUES ('" + Database.PROPERTY_VERSION + "', '" + Database.VERSION_UNKNOWN + "')");
statement.executeUpdate("INSERT INTO " + TABLES.PROPERTIES + "(id, value) VALUES ('" + Database.PROPERTY_IMPORT_ORIGIN + "', '')");
// pure network
statement.executeUpdate("CREATE TABLE " + TABLES.NODE + " (id STRING, lat DOUBLE, lon DOUBLE, ele DOUBLE, is_traffic_light BOOLEAN, is_intersection BOOLEAN, is_generated BOOLEAN)");
statement.executeUpdate("CREATE TABLE " + TABLES.WAY + " (id STRING, name TEXT, type TEXT, speed DOUBLE, lanesForward INTEGER, lanesBackward INTEGER, oneway BOOLEAN)");
statement.executeUpdate("CREATE TABLE " + TABLES.WAY_CONSISTS_OF + " (way_id STRING, node_id STRING, sequence_number INTEGER)");
statement.executeUpdate("CREATE TABLE " + TABLES.CONNECTION + " (id STRING, way_id STRING, lanes INTEGER, length FLOAT)");
statement.executeUpdate("CREATE TABLE " + TABLES.CONNECTION_CONSISTS_OF + " (connection_id STRING, node_id STRING, sequence_number INTEGER)");
statement.executeUpdate("CREATE TABLE " + TABLES.NODE + " (id TEXT, lat REAL, lon REAL, ele REAL, is_traffic_light BOOLEAN, is_intersection BOOLEAN, is_generated BOOLEAN)");
statement.executeUpdate("CREATE TABLE " + TABLES.WAY + " (id TEXT, name TEXT, type TEXT, speed REAL, lanesForward INTEGER, lanesBackward INTEGER, oneway BOOLEAN)");
statement.executeUpdate("CREATE TABLE " + TABLES.WAY_CONSISTS_OF + " (way_id TEXT, node_id TEXT, sequence_number INTEGER)");
statement.executeUpdate("CREATE TABLE " + TABLES.CONNECTION + " (id TEXT, way_id TEXT, lanes INTEGER, length REAL)");
statement.executeUpdate("CREATE TABLE " + TABLES.CONNECTION_CONSISTS_OF + " (connection_id TEXT, node_id TEXT, sequence_number INTEGER)");
// turn restrictions
statement.executeUpdate("CREATE TABLE " + TABLES.RESTRICTION + " (id STRING, source_way_id STRING, via_node_id STRING, target_way_id STRING, type STRING)");
statement.executeUpdate("CREATE TABLE " + TABLES.RESTRICTION + " (id TEXT, source_way_id TEXT, via_node_id TEXT, target_way_id TEXT, type TEXT)");
// traffic signals
statement.executeUpdate("CREATE TABLE " + TABLES.TRAFFIC_SIGNALS + " (id STRING, ref_node_id STRING, phases STRING, timing STRING, from_way_id STRING, via0_way_id STRING, via1_way_id STRING, to_way_id STRING, lanes_from STRING, lanes_via0 STRING, lanes_via1 STRING, lanes_to STRING)");
statement.executeUpdate("CREATE TABLE " + TABLES.TRAFFIC_SIGNALS + " (id TEXT, ref_node_id TEXT, phases TEXT, timing TEXT, from_way_id TEXT, via0_way_id TEXT, via1_way_id TEXT, to_way_id TEXT, lanes_from TEXT, lanes_via0 TEXT, lanes_via1 TEXT, lanes_to TEXT)");
// vehicle data
statement.executeUpdate("CREATE TABLE " + TABLES.ROUTE + " (id STRING, sequence_number INTEGER, connection_id STRING)");
statement.executeUpdate("CREATE TABLE " + TABLES.ROUTE + " (id TEXT, sequence_number INTEGER, connection_id TEXT)");
// roundabouts
statement.executeUpdate("CREATE TABLE " + TABLES.ROUNDABOUT + " (id STRING)");
statement.executeUpdate("CREATE TABLE " + TABLES.ROUNDABOUT_CONSISTS_OF + " (roundabout_id STRING, node_id STRING, sequence_number INTEGER)");
statement.executeUpdate("CREATE TABLE " + TABLES.ROUNDABOUT + " (id TEXT)");
statement.executeUpdate("CREATE TABLE " + TABLES.ROUNDABOUT_CONSISTS_OF + " (roundabout_id TEXT, node_id TEXT, sequence_number INTEGER)");
// buildings and its corners
statement.executeUpdate("CREATE TABLE " + TABLES.BUILDING + " (id STRING, name TEXT, height DOUBLE)");
statement.executeUpdate("CREATE TABLE " + TABLES.BUILDING_CONSISTS_OF + " (building_id STRING, lat DOUBLE, lon DOUBLE, sequence_number INTEGER)");
statement.executeUpdate("CREATE TABLE " + TABLES.BUILDING + " (id TEXT, name TEXT, height REAL)");
statement.executeUpdate("CREATE TABLE " + TABLES.BUILDING_CONSISTS_OF + " (building_id TEXT, lat REAL, lon REAL, sequence_number INTEGER)");

// Connection Details (like parking lots)
statement.executeUpdate("CREATE TABLE " + TABLES.CONNECTION_DETAILS + " (id STRING, connection STRING, type STRING, value STRING)");
statement.executeUpdate("CREATE TABLE " + TABLES.CONNECTION_DETAILS + " (id TEXT, connection TEXT, type TEXT, value TEXT)");
sqlite.disconnect(statement);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,28 @@
package org.eclipse.mosaic.lib.database.persistence;

final class TABLES {
static String PROPERTIES = "Properties";
static String NODE = "Node";
static String WAY = "Way";
static String WAY_CONSISTS_OF = "WayConsistsOf";
static String CONNECTION = "Connection";
static String CONNECTION_CONSISTS_OF = "ConnectionConsistsOf";
static String RESTRICTION = "Restriction";
static String TRAFFIC_SIGNALS = "TrafficSignals";
static String ROUTE = "Route";
static String ROUNDABOUT = "Roundabout";
static String ROUNDABOUT_CONSISTS_OF = "RoundaboutConsistsOf";
static String BUILDING = "Building";
static String BUILDING_CONSISTS_OF = "BuildingConsistsOf";
static String CONNECTION_DETAILS = "ConnectionDetails";
final static String PROPERTIES = "Properties";
final static String NODE = "Node";
final static String WAY = "Way";
final static String WAY_CONSISTS_OF = "WayConsistsOf";
final static String CONNECTION = "Connection";
final static String CONNECTION_CONSISTS_OF = "ConnectionConsistsOf";
final static String RESTRICTION = "Restriction";
final static String TRAFFIC_SIGNALS = "TrafficSignals";
final static String ROUTE = "Route";
final static String ROUNDABOUT = "Roundabout";
final static String ROUNDABOUT_CONSISTS_OF = "RoundaboutConsistsOf";
final static String BUILDING = "Building";
final static String BUILDING_CONSISTS_OF = "BuildingConsistsOf";
final static String CONNECTION_DETAILS = "ConnectionDetails";
/**
* Will no longer be written to, but used to update old versions of databases.
*/
@Deprecated
static String CORNER = "Corner";
final static String CORNER = "Corner";
/**
* Will no longer be written to, but used to update old versions of databases.
*/
@Deprecated
static String WALL = "Wall";



final static String WALL = "Wall";
}

0 comments on commit 8f038ca

Please sign in to comment.