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 Details

    • OSMNetwork

      public OSMNetwork​(String name)
      Construct a new OSMNetwork.
      Parameters:
      name - String; the name of the new Network
  • Method Details

    • getNodesFromWay

      public final List<Long> getNodesFromWay​(Long wayId) throws IOException
      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

      public final OSMNode getNode​(long nodeId) throws IOException
      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

      public final Map<Long,​OSMNode> 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

      public final OSMRelation getRelation​(long relid) throws IOException
      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

      public final Map<Long,​OSMRelation> 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

      public final OSMWay getWay​(long wayid) throws IOException
      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

      public final String getName()
      Retrieve the name of this OSMNetwork.
      Returns:
      name String; the name of this OSMNetwork
    • setNodes

      public final void setNodes​(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.
      Parameters:
      newnodes - LinkedHashMap<Long, OSMNode>; the (new) Nodes for this Network
    • addNode

      public final void addNode​(OSMNode node)
      Add one OSMNode to this OSMNetwork.
      Parameters:
      node - OSMNode; the node to add to this OSMNetwork
    • addWay

      public final void addWay​(OSMWay way)
      Add one OSMWay to this OSMNetwork.
      Parameters:
      way - OSMWay; the OSMWay to add
    • addRelation

      public final void addRelation​(OSMRelation osmRelation)
      Add one OSMRelation to this Network.
      Parameters:
      osmRelation - OSMRelation; the OSMRelation to add
    • getWays

      public final Map<Long,​OSMWay> 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

      public final List<OSMLink> 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 IOException
      Creates links out of the ways in this network.
      Parameters:
      warningListener - WarningListener; the warning listener that will receive warning events
      progressListener - 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

      public final OSMLink findFollowingLink​(OSMLink link)
      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

      public final OSMLink findPrecedingLink​(OSMLink link)
      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

      public final boolean hasPrecedingLink​(OSMLink link)
      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

      public final boolean hasFollowingLink​(OSMLink link)
      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

      public final String toString()
      Overrides:
      toString in class Object