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_UNKNOWN
as 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 newConnection
to the database.addConnection
(Connection connection) Deprecated.Adds a newNode
to the database using an id and a position.Adds a newNode
to the database using an id and a position.Deprecated.useaddNode(String, GeoPoint)
insteadaddNodeToConnection
(String connectionId, String nodeId) This will add aNode
to 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 newRestriction
to the database.addRoundabout
(String roundaboutId, List<Node> nodes) Adds a newRoundabout
to the database.Adds a newRoute
to the database.void
Deprecated.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.void
Sets the "intersection" flag for all nodes, which have more than 2 neighboring nodes.void
Cleans the database of detected graphs, used for importing purposes.Resets network components of database.void
This clears the list of routes.void
boolean
connectionExists
(String connectionId) copyFromDatabase
(Database other) Copies all elements of the givenDatabase
into 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.Builder
loadFromFile
(File file) This method loads tries to load a database object from the givenFile
, which should refer to a database-file.boolean
nodeExists
(String nodeId) void
setImportOrigin
(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_UNKNOWN
as 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. ASQLiteReader
is 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 givenDatabase
into the current one.- Parameters:
other
- theDatabase
to 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 newNode
to the database. Be aware, that node IDs have to be distinct! Adding aNode
whose 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 newNode
to the database using an id and a position. This method will create a newNode
, add it to thedatabase
and will return the createdNode
for further manipulation of it. This overload of the methodaddNode(org.eclipse.mosaic.lib.database.road.Node)
is used to addTrafficLightNode
-Node
s to the database.- Parameters:
nodeId
- aString
representing a unique id for theNode
position
- the position of theNode
isTrafficLight
- boolean to determine if the node to be added is aTrafficLightNode
- Returns:
- the created
Node
for further manipulation
-
nodeExists
-
getNode
-
getNodes
-
addWay
Deprecated.useaddWay(String, String, String)
insteadAdds a newWay
to the database. Be aware that adding aWay
whose ID is already in the list will replace the previousWay
. This method also makes sure, that theNode
s of the way know the way.- Parameters:
way
- Way to add.
-
addWay
-
getWay
-
getWays
-
addConnection
Deprecated.useaddConnection(String, String)
insteadAdds a newConnection
to the database. Be aware that adding aConnection
whose ID is already in the list will replace the previousConnection
. This method also makes sure, that dependentNode
s andWay
s know the connection.- Parameters:
connection
- Connection to add.- Returns:
- the builder for easy cascading
-
addConnection
Adds a newConnection
to the database. Be aware that adding aConnection
whose ID is already in the list will replace the previousConnection
. This method also makes sure, that dependentNode
s andWay
s know the connection.- Parameters:
connectionId
- the id of the connection to be addedwayId
- the way id abstracted by theConnection
- Returns:
- the added
Connection
for further manipulation
-
getConnections
-
getConnection
-
addNodeToWay
-
addNodeToConnection
This will add aNode
to aConnection
, validating the input parameters against null.- Parameters:
connectionId
- the id of theConnection
to add the node tonodeId
- the id of theNode
to be added to the connection- Returns:
- the builder for easy cascading
-
addRoundabout
Adds a newRoundabout
to 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 newRestriction
to the database. This method will create a newRestriction
object using the given parameters.- Parameters:
restrictionId
- the id for the restrictiontype
- theRestriction.Type
of the restrictionsourceWayId
- start of the restrictionviaNodeId
- restriction will be via this nodetargetWayId
- end of the restriction- Returns:
- the
Restriction
object 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 newRoute
to the database. Be aware that adding aRoute
whose ID is already in the list will replace the previousRoute
. This method also returns theDatabase.RouteBuilder
for further manipulation.- Parameters:
routeId
- the id of the route to be added
-
addRoute
Deprecated.use addRoute insteadAdds a newRoute
to the database. Be aware that adding aRoute
whose 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