Class 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 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_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 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
      • getTrafficLightNodes

        public Collection<TrafficLightNode> getTrafficLightNodes()
        Returns a list of all nodes, which are tagged as traffic lights.
        Returns:
        Traffic light nodes.
      • 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.
      • getBorderNodeIds

        @Nonnull
        public List<String> getBorderNodeIds()
        This function is looking for nodes at the map borders (all from_nodes from connections which appear only in one entry).
        Returns:
        List of node IDs, referring to Nodes which are the starting point of only one way.