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.
  • Field Details

    • 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:
    • PROPERTY_VERSION

      public static final String PROPERTY_VERSION
      Key for the import origin property.
      See Also:
    • PROPERTY_IMPORT_ORIGIN

      public static final String PROPERTY_IMPORT_ORIGIN
      Key for the import origin property.
      See Also:
    • 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:
    • 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:
  • Method Details

    • loadFromFile

      public static Database loadFromFile(File file)
      This method loads tries to load a database object from the given File, which should refer to a database-file. A SQLiteReader 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 - a String 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 the Node with the given id.
      Parameters:
      id - Id of the Node.
      Returns:
      Requested node.
    • getWay

      public Way getWay(String id)
      Returns the Way with the given id.
      Parameters:
      id - Id of the way.
      Returns:
      Way with the given Id.
    • getConnection

      public Connection getConnection(String id)
      Returns the Connection with the given id.
      Parameters:
      id - Id of the connection.
      Returns:
      Connection with the given Id.
    • getBuilding

      public Building getBuilding(String id)
      Returns the Building 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 the Route with the given id.
      Parameters:
      id - Id of the route.
      Returns:
      Route with the given Id.
    • getRestriction

      public Restriction getRestriction(String id)
      Returns the Restriction 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 known Nodes.
      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 known Ways.
      Returns:
      All ways as Collection.
    • getConnections

      public Collection<Connection> getConnections()
      Returns an unmodifiable view of the known Connections.
      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 known Routes.
      Returns:
      All routes as Collection.
    • getRestrictions

      public Collection<Restriction> getRestrictions()
      Returns an unmodifiable view of the known Restrictions.
      Returns:
      All restrictions as Collection.