Package org.eclipse.mosaic.lib.database
Class Database.Builder
java.lang.Object
org.eclipse.mosaic.lib.database.Database.Builder
- Enclosing class:
- Database
Builder class for simple generation for a new
Database.-
Constructor Summary
ConstructorsConstructorDescriptionBuilder()Default constructor for theDatabase.Builder, creating theDatabase-object usingDatabase.VERSION_UNKNOWNas version for theDatabase.Constructor for theDatabase.Builder, creating theDatabase-object using the given version parameter as version for theDatabase. -
Method Summary
Modifier and TypeMethodDescriptionaddBuilding(String id, String name, double height, GeoPoint[] corners) Adds a new building by a given list of corners defining the corners of the building.addConnection(String connectionId, String wayId) Adds a newConnectionto the database.addConnection(Connection connection) Deprecated.Adds a newNodeto the database using an id and a position.Adds a newNodeto the database using an id and a position.Deprecated.useaddNode(String, GeoPoint)insteadaddNodeToConnection(String connectionId, String nodeId) This will add aNodeto aConnection, validating the input parameters against null.addNodeToWay(String wayId, String nodeId) addProperty(String key, String value) Adds a new property to the database.addRestriction(String restrictionId, Restriction.Type type, String sourceWayId, String viaNodeId, String targetWayId) Adds a newRestrictionto the database.addRoundabout(String roundaboutId, List<Node> nodes) Adds a newRoundaboutto the database.Adds a newRouteto the database.voidDeprecated.use addRoute insteadDeprecated.useaddWay(String, String, String)insteadbuild()This method cleans the database of unnecessary network elements and returns it.build(boolean cleanupUnusedFields) This method allows to disable the cleaning of the database.voidSets the "intersection" flag for all nodes, which have more than 2 neighboring nodes.voidCleans the database of detected graphs, used for importing purposes.Resets network components of database.voidThis clears the list of routes.voidbooleanconnectionExists(String connectionId) copyFromDatabase(Database other) Copies all elements of the givenDatabaseinto the current one.getConnection(String connectionId) Deprecated.will be removed in future versions.getNodes()getWays()loadFromDatabase(Database database) Overrides the database to be created with the inputDatabase.static Database.BuilderloadFromFile(File file) This method loads tries to load a database object from the givenFile, which should refer to a database-file.booleannodeExists(String nodeId) voidsetImportOrigin(String value) Sets the import origin as a new property in the database.
-
Constructor Details
-
Builder
public Builder()Default constructor for theDatabase.Builder, creating theDatabase-object usingDatabase.VERSION_UNKNOWNas version for theDatabase. -
Builder
Constructor for theDatabase.Builder, creating theDatabase-object using the given version parameter as version for theDatabase.- Parameters:
version- the version to be used for the database
-
-
Method Details
-
loadFromFile
This method loads tries to load a database object from the givenFile, which should refer to a database-file. ASQLiteReaderis used for the translation of the database to the Java-Object- Parameters:
file- the database-file- Returns:
- the builder for easy cascading of methods
-
loadFromDatabase
Overrides the database to be created with the inputDatabase.- Parameters:
database- theDatabase-object, that shall be used as the database- Returns:
- the builder for easy cascading
-
copyFromDatabase
Copies all elements of the givenDatabaseinto the current one.- Parameters:
other- theDatabaseto copy into the existing one- Returns:
- the builder for easy cascading
-
getIntermediateDatabase
Deprecated.will be removed in future versions. It should not be required to have access to a Database which is being currently built.Returns the current state of the database, it is used to access by different classes, that add fields to this object, but need information already contained in the object.- Returns:
- the current database
-
clearNetwork
Resets network components of database.- Returns:
- the builder for easy cascading
-
addProperty
Adds a new property to the database. Adding a property whose key is already in the list will replace the previous value.- Parameters:
key- the key of the propertyvalue- the value of the property- Returns:
- the builder for easy cascading
-
addNode
Deprecated.useaddNode(String, GeoPoint)insteadAdds a newNodeto the database. Be aware, that node IDs have to be distinct! Adding aNodewhose ID is already in the list will replace the previousNode.- Parameters:
node- Node to add.- Returns:
- this builder for easy cascading
-
addNode
-
addNode
Adds a newNodeto the database using an id and a position. This method will create a newNode, add it to thedatabaseand will return the createdNodefor further manipulation of it. This overload of the methodaddNode(org.eclipse.mosaic.lib.database.road.Node)is used to addTrafficLightNode-Nodes to the database.- Parameters:
nodeId- aStringrepresenting a unique id for theNodeposition- the position of theNodeisTrafficLight- boolean to determine if the node to be added is aTrafficLightNode- Returns:
- the created
Nodefor further manipulation
-
nodeExists
-
getNode
-
getNodes
-
addWay
Deprecated.useaddWay(String, String, String)insteadAdds a newWayto the database. Be aware that adding aWaywhose ID is already in the list will replace the previousWay. This method also makes sure, that theNodes of the way know the way.- Parameters:
way- Way to add.
-
addWay
-
getWay
-
getWays
-
addConnection
Deprecated.useaddConnection(String, String)insteadAdds a newConnectionto the database. Be aware that adding aConnectionwhose ID is already in the list will replace the previousConnection. This method also makes sure, that dependentNodes andWays know the connection.- Parameters:
connection- Connection to add.- Returns:
- the builder for easy cascading
-
addConnection
Adds a newConnectionto the database. Be aware that adding aConnectionwhose ID is already in the list will replace the previousConnection. This method also makes sure, that dependentNodes andWays know the connection.- Parameters:
connectionId- the id of the connection to be addedwayId- the way id abstracted by theConnection- Returns:
- the added
Connectionfor further manipulation
-
getConnections
-
getConnection
-
addNodeToWay
-
addNodeToConnection
This will add aNodeto aConnection, validating the input parameters against null.- Parameters:
connectionId- the id of theConnectionto add the node tonodeId- the id of theNodeto be added to the connection- Returns:
- the builder for easy cascading
-
addRoundabout
Adds a newRoundaboutto the database.- Parameters:
roundaboutId- the id of the roundaboutnodes- the nodes belonging to the roundabout- Returns:
- the builder for easy cascading
-
addRestriction
public Restriction addRestriction(String restrictionId, Restriction.Type type, String sourceWayId, String viaNodeId, String targetWayId) Adds a newRestrictionto the database. This method will create a newRestrictionobject using the given parameters.- Parameters:
restrictionId- the id for the restrictiontype- theRestriction.Typeof the restrictionsourceWayId- start of the restrictionviaNodeId- restriction will be via this nodetargetWayId- end of the restriction- Returns:
- the
Restrictionobject for further manipulation
-
addBuilding
Adds a new building by a given list of corners defining the corners of the building.- Parameters:
id- the id of the buildingname- the name of the buildingheight- the height of the buildingcorners- the list of geographical points describing the contour of the building
-
addRoute
Adds a newRouteto the database. Be aware that adding aRoutewhose ID is already in the list will replace the previousRoute. This method also returns theDatabase.RouteBuilderfor further manipulation.- Parameters:
routeId- the id of the route to be added
-
addRoute
Deprecated.use addRoute insteadAdds a newRouteto the database. Be aware that adding aRoutewhose ID is already in the list will replace the previousRoute.- Parameters:
route- Route to add.
-
getRoute
-
setImportOrigin
Sets the import origin as a new property in the database. Adding a property whose key is already in the list will replace the previous value.- Parameters:
value- the value the import origin should be set to
-
build
This method cleans the database of unnecessary network elements and returns it.- Returns:
- the build
Database
-
build
This method allows to disable the cleaning of the database. This is mostly of importance for testing purposes.- Returns:
- the build
Database
-
cleanGraphs
public void cleanGraphs()Cleans the database of detected graphs, used for importing purposes. -
clearRoutes
public void clearRoutes()This clears the list of routes. Should only be called when importing routes! -
calculateIntersections
public void calculateIntersections()Sets the "intersection" flag for all nodes, which have more than 2 neighboring nodes. -
completeConnections
public void completeConnections() -
connectionExists
-
addConnection(String, String)instead