Class OSMNetwork
java.lang.Object
org.opentrafficsim.road.network.factory.osm.OSMNetwork
- All Implemented Interfaces:
Serializable
public class OSMNetwork extends Object implements Serializable
Container for all imported entities of an OpenStreetMap file.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2015-07-26 01:01:13 +0200 (Sun, 26 Jul 2015) $, @version $Revision: 1155 $, by $Author: averbraeck $,
initial version 31 dec. 2014
- Author:
- Moritz Bergmann
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description OSMNetwork(String name)Construct a new OSMNetwork. -
Method Summary
Modifier and Type Method Description voidaddNode(OSMNode node)Add one OSMNode to this OSMNetwork.voidaddRelation(OSMRelation osmRelation)Add one OSMRelation to this Network.voidaddWay(OSMWay way)Add one OSMWay to this OSMNetwork.OSMLinkfindFollowingLink(OSMLink link)Finds the link that follows a given OSMLink.OSMLinkfindPrecedingLink(OSMLink link)Finds an OSMLink that precedes the given OSMLink.List<OSMLink>getLinks()Retrieve the list of OSMLinks of this OSMNetwork.StringgetName()Retrieve the name of this OSMNetwork.OSMNodegetNode(long nodeId)Retrieve a Node from this Network.Map<Long,OSMNode>getNodes()Retrieve the map of OSMNode ids to OSMNodes of this OSMNetwork.List<Long>getNodesFromWay(Long wayId)Retrieve a list of Nodes that form a Way from this Network.OSMRelationgetRelation(long relid)Retrieve a Relation from this Network.Map<Long,OSMRelation>getRelations()Retrieve the map of OSMRelations of this OSMNetwork.OSMWaygetWay(long wayid)Retrieve a Way from this Network.Map<Long,OSMWay>getWays()Retrieve the map of OSMWays of this OSMNetwork.booleanhasFollowingLink(OSMLink link)Returns true if the given OSMLink has a following OSMLink.booleanhasPrecedingLink(OSMLink link)Returns true if the given link has a preceding link.voidmakeLinks(WarningListener warningListener, ProgressListener progressListener)Creates links out of the ways in this network.voidremoveRedundancy()FIXME Network looks 'crooked' after using this.voidsetNodes(LinkedHashMap<Long,OSMNode> newnodes)Set/replace the Nodes of this Network.
The provided list is not copied; the caller should not modify the list after setting it.StringtoString()
-
Constructor Details
-
OSMNetwork
Construct a new OSMNetwork.- Parameters:
name- String; the name of the new Network
-
-
Method Details
-
getNodesFromWay
Retrieve a list of Nodes that form a Way from this Network.- Parameters:
wayId- Long; the id of the Way- Returns:
- List<Long>; the list of OSMNode ids of the OSMWay with the specified id
- Throws:
IOException- when no Way with the specified id exists in this Network
-
getNode
Retrieve a Node from this Network.- Parameters:
nodeId- long; the id of the Node- Returns:
- node OSMNode; the node with the specified id
- Throws:
IOException- when no OSMNode with the specified id exist in this Network
-
getNodes
Retrieve the map of OSMNode ids to OSMNodes of this OSMNetwork.- Returns:
- Map<Long, OSMNode>; the map of all Nodes in this Network (modifications of the returned object are reflected in this OSMNetwork)
-
getRelation
Retrieve a Relation from this Network.- Parameters:
relid- long; the id of the Relation- Returns:
- OSMRelation; modifications of the result are reflected in this OSMNetwork
- Throws:
IOException- when no Relation with the specified id exists in this Network
-
getRelations
Retrieve the map of OSMRelations of this OSMNetwork.- Returns:
- Map<Long, OSMRelation>; the map of all OSMRelations in the network (modifications of the returned object are reflected in this OSMNetwork)
-
getWay
Retrieve a Way from this Network.- Parameters:
wayid- long; the id of a Way- Returns:
- Way
- Throws:
IOException- when no Way with the specified id exist in this network
-
getName
Retrieve the name of this OSMNetwork.- Returns:
- name String; the name of this OSMNetwork
-
setNodes
Set/replace the Nodes of this Network.
The provided list is not copied; the caller should not modify the list after setting it.- Parameters:
newnodes- LinkedHashMap<Long, OSMNode>; the (new) Nodes for this Network
-
addNode
Add one OSMNode to this OSMNetwork.- Parameters:
node- OSMNode; the node to add to this OSMNetwork
-
addWay
Add one OSMWay to this OSMNetwork.- Parameters:
way- OSMWay; the OSMWay to add
-
addRelation
Add one OSMRelation to this Network.- Parameters:
osmRelation- OSMRelation; the OSMRelation to add
-
getWays
Retrieve the map of OSMWays of this OSMNetwork.- Returns:
- ways Map<Long, OSMWay>; the map of OSMWays of this OSMNetwork; modifications of the result are reflected in this OSMNetwork
-
getLinks
Retrieve the list of OSMLinks of this OSMNetwork.- Returns:
- links List<OSMLink>; the list of OSMLinks of this OSMNetwork; modifications of the result are reflected in this OSMNetwork
-
makeLinks
public final void makeLinks(WarningListener warningListener, ProgressListener progressListener) throws IOExceptionCreates links out of the ways in this network.- Parameters:
warningListener- WarningListener; the warning listener that will receive warning eventsprogressListener- ProgressListener; the progress listener that will receive progress events- Throws:
IOException- on read errors
-
removeRedundancy
public final void removeRedundancy()FIXME Network looks 'crooked' after using this. This function checks for and removes redundancies between the networks links. -
findFollowingLink
Finds the link that follows a given OSMLink.- Parameters:
link- OSMLink; OSMLink for which a successor OSMLink is sought- Returns:
- OSMLink (one of) the successor OSMLink(s) of the given OSMLink, or null if the given OSMLink has no successors
-
findPrecedingLink
Finds an OSMLink that precedes the given OSMLink.- Parameters:
link- OSMLink; the OSMLink for which a predecessor OSMLink is sought- Returns:
- OSMLink (one of) the predecessor OSMLink(s) of the given OSMLink, or null if the given OSMLink has no predecessors
-
hasPrecedingLink
Returns true if the given link has a preceding link.- Parameters:
link- OSMLink; the link for which the caller wants to know whether there is a preceding link- Returns:
- boolean; true if the given link has one or more predecessors; false otherwise
-
hasFollowingLink
Returns true if the given OSMLink has a following OSMLink.- Parameters:
link- OSMLink; the OSMLink for which the caller wants to know if it has a follower OSMLink- Returns:
- boolean; true if the specified OSMLink has a follower link in this OSMNetwork
-
toString
-