Package org.eclipse.mosaic.lib.database
Class Database
- java.lang.Object
-
- org.eclipse.mosaic.lib.database.Database
-
public class Database extends Object
This contains all information about the traffic network, as well as possible obstacles affecting communications and predefined routing information. The information can be persisted to and read from a file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Database.Builder
Builder class for simple generation for a newDatabase
.static class
Database.RouteBuilder
-
Field Summary
Fields Modifier and Type Field Description static String
IMPORT_ORIGIN_OSM
Value for key "importOrigin" which states, that the import origin of the database was a OpenStreetMap file.static String
IMPORT_ORIGIN_SUMO
Value for key "importOrigin" which states, that the import origin of the database was a SUMO network file.static String
PROPERTY_IMPORT_ORIGIN
Key for the import origin property.static String
PROPERTY_VERSION
Key for the import origin property.static String
VERSION_UNKNOWN
Default name if no version name was defined.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getBorderNodeIds()
This function is looking for nodes at the map borders (all from_nodes from connections which appear only in one entry).GeoRectangle
getBoundingBox()
Returns the bounding box containing all nodes in the database.Building
getBuilding(String id)
Returns theBuilding
with the given id.Collection<Building>
getBuildings()
Returns all buildings from the database.Connection
getConnection(String id)
Returns theConnection
with the given id.Collection<Connection>
getConnections()
Returns an unmodifiable view of the knownConnection
s.String
getImportOrigin()
Returns the import origin of the given Database.Node
getNode(String id)
Returns theNode
with the given id.Collection<Node>
getNodes()
Returns an unmodifiable view of the knownNode
s.String
getProperty(String key)
Returns the value of the requested property with the given key.Set<String>
getPropertyKeys()
Returns all property keys.Restriction
getRestriction(String id)
Returns theRestriction
with the given id.Collection<Restriction>
getRestrictions()
Returns an unmodifiable view of the knownRestriction
s.Collection<Roundabout>
getRoundabouts()
Returns all roundabouts from the database.Route
getRoute(String id)
Returns theRoute
with the given id.Collection<Route>
getRoutes()
Returns an unmodifiable view of the knownRoute
s.Collection<TrafficLightNode>
getTrafficLightNodes()
Returns a list of all nodes, which are tagged as traffic lights.String
getVersion()
Returns the version of the given Database.Way
getWay(String id)
Returns theWay
with the given id.Collection<Way>
getWays()
Returns an unmodifiable view of the knownWay
s.static Database
loadFromFile(File file)
This method loads tries to load a database object from the givenFile
, which should refer to a database-file.static Database
loadFromFile(String filename)
This method loads tries to load a database object from the given filename, which should refer to a database-file.void
saveToFile(String filename)
Saves the current database to a SQLite file.
-
-
-
Field Detail
-
VERSION_UNKNOWN
public static final String VERSION_UNKNOWN
Default name if no version name was defined. If a database has this value set it usually means, that the database was one of the following:
- just created and is not persisted yet
- not loaded yet
- could not be loaded from persistence
- See Also:
- Constant Field Values
-
PROPERTY_VERSION
public static final String PROPERTY_VERSION
Key for the import origin property.- See Also:
- Constant Field Values
-
PROPERTY_IMPORT_ORIGIN
public static final String PROPERTY_IMPORT_ORIGIN
Key for the import origin property.- See Also:
- Constant Field Values
-
IMPORT_ORIGIN_SUMO
public static final String IMPORT_ORIGIN_SUMO
Value for key "importOrigin" which states, that the import origin of the database was a SUMO network file.- See Also:
- Constant Field Values
-
IMPORT_ORIGIN_OSM
public static final String IMPORT_ORIGIN_OSM
Value for key "importOrigin" which states, that the import origin of the database was a OpenStreetMap file.- See Also:
- Constant Field Values
-
-
Method Detail
-
loadFromFile
public static Database loadFromFile(File file)
This method loads tries to load a database object from the givenFile
, which should refer to a database-file. ASQLiteReader
is used for the translation of the database to the Java-Object- Parameters:
file
- the database-file- Returns:
- the loaded database
-
loadFromFile
public static Database loadFromFile(String filename)
This method loads tries to load a database object from the given filename, which should refer to a database-file.- Parameters:
filename
- aString
representation of the file to be loaded- Returns:
- the loaded database
-
saveToFile
public void saveToFile(String filename)
Saves the current database to a SQLite file.- Parameters:
filename
- database filename.
-
getVersion
public String getVersion()
Returns the version of the given Database.- Returns:
- version as string or
VERSION_UNKNOWN
-
getImportOrigin
public String getImportOrigin()
Returns the import origin of the given Database.- Returns:
- import origin as string
-
getProperty
public String getProperty(String key)
Returns the value of the requested property with the given key.- Parameters:
key
- Key of the requested property.- Returns:
- Requested property.
-
getPropertyKeys
public Set<String> getPropertyKeys()
Returns all property keys.- Returns:
- Set of the property keys.
-
getNode
public Node getNode(String id)
Returns theNode
with the given id.- Parameters:
id
- Id of the Node.- Returns:
- Requested node.
-
getWay
public Way getWay(String id)
Returns theWay
with the given id.- Parameters:
id
- Id of the way.- Returns:
- Way with the given Id.
-
getConnection
public Connection getConnection(String id)
Returns theConnection
with the given id.- Parameters:
id
- Id of the connection.- Returns:
- Connection with the given Id.
-
getBuilding
public Building getBuilding(String id)
Returns theBuilding
with the given id.- Parameters:
id
- id of the building.- Returns:
- The building identified by the given id.
-
getRoute
public Route getRoute(String id)
Returns theRoute
with the given id.- Parameters:
id
- Id of the route.- Returns:
- Route with the given Id.
-
getRestriction
public Restriction getRestriction(String id)
Returns theRestriction
with the given id.- Parameters:
id
- Id of the restriction.- Returns:
- Restriction with the given Id.
-
getBoundingBox
public GeoRectangle getBoundingBox()
Returns the bounding box containing all nodes in the database.- Returns:
- the bounding box as
GeoRectangle
-
getNodes
public Collection<Node> getNodes()
Returns an unmodifiable view of the knownNode
s.- Returns:
- Nodes as
Collection
.
-
getTrafficLightNodes
public Collection<TrafficLightNode> getTrafficLightNodes()
Returns a list of all nodes, which are tagged as traffic lights.- Returns:
- Traffic light nodes.
-
getWays
public Collection<Way> getWays()
Returns an unmodifiable view of the knownWay
s.- Returns:
- All ways as
Collection
.
-
getConnections
public Collection<Connection> getConnections()
Returns an unmodifiable view of the knownConnection
s.- Returns:
- All connections as
Collection
.
-
getRoundabouts
public Collection<Roundabout> getRoundabouts()
Returns all roundabouts from the database.- Returns:
- All roundabouts in a
Collection
.
-
getBuildings
public Collection<Building> getBuildings()
Returns all buildings from the database.- Returns:
- All buildings in a
Collection
.
-
getRoutes
public Collection<Route> getRoutes()
Returns an unmodifiable view of the knownRoute
s.- Returns:
- All routes as
Collection
.
-
getRestrictions
public Collection<Restriction> getRestrictions()
Returns an unmodifiable view of the knownRestriction
s.- Returns:
- All restrictions as
Collection
.
-
-