Class OsmNetworkLayerParser


  • public class OsmNetworkLayerParser
    extends Object
    Takes care of populating a PLANit layer based on the OSM way information that has been identified as relevant to this layer by the OsmNetworkMainProcessingHandler
    Author:
    markr
    • Method Detail

      • updatedLinkSegmentTypeBasedOnOsmWay

        protected Pair<MacroscopicLinkSegmentType,​MacroscopicLinkSegmentType> updatedLinkSegmentTypeBasedOnOsmWay​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                                                                                        Map<String,​String> tags,
                                                                                                                        MacroscopicLinkSegmentType linkSegmentType)
        given the OSM way tags and settings we construct or find the appropriate link segment types for both directions, if no better alternative could be found than the one that is passed in is used, which is assumed to be the default link segment type for the OSM way. It is not assumed that changes to mode access are ALWAYS accompanied by an access=X. However when this tag is available we apply its umbrella result to either include or exclude all supported modes as a starting point
        Parameters:
        osmWay - the tags belong to
        tags - of the OSM way to extract the link segment type for
        linkSegmentType - use thus far for this way
        Returns:
        the link segment types for the forward direction and backward direction as per OSM specification of forward and backward. When no allowed modes exist in a direction the link segment type is set to null
      • extractPartialOsmWay

        public MacroscopicLink extractPartialOsmWay​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                    Map<String,​String> tags,
                                                    int startNodeIndex,
                                                    int endNodeIndex,
                                                    boolean isPartOfCircularWay,
                                                    Pair<MacroscopicLinkSegmentType,​MacroscopicLinkSegmentType> linkSegmentTypes)
        extract OSM way's PLANit infrastructure for the part of the way that is indicated. When it is marked as being a (partial) section of a circular way, then we only allow the presumed one way direction applicable when creating directional link segments. The result is a newly registered link, its nodes, and linksegment(s) on the network layer. The parser will try to infer missing/default data by using defaults set by the user. The provided link segment types are based on the osmWay data and are assumed to be readily available and provided by the PlanitOsmHandler when identifying the correct layer (this layer)
        Parameters:
        osmWay - to parse
        tags - related to the OSM way
        startNodeIndex - to start parsing nodes from
        endNodeIndex - to stop parsing nodes
        isPartOfCircularWay - flag
        linkSegmentTypes - to use
        Returns:
        created link (if any), if no link could be created null is returned
      • breakLinksWithInternalNode

        protected boolean breakLinksWithInternalNode​(Node thePlanitNode)
        whenever we find that internal nodes are used by more than one link OR a node is an extreme node on an existing link but also an internal link on another node, we break the links where this node is internal. the end result is a situations where all nodes used by more than one link are extreme nodes, i.e., start/end nodes.

        Osm ways with multiple PLANit links associated with them can cause problems because in the handler we only register nodes internal to the original way to link mapping. If a link is broken we adjust the original link and create an additional link causing the original mapping between internal nodes and PLANit link to be potentially incorrect. We require the osmWaysWithMultiplePlanitLinks map to track these changes so that we can always identify which of multiple PLANit links an internal node currently resides on.

        Parameters:
        thePlanitNode - to break links for where it is internal to them (based on its OSM node id reference)
        Returns:
        true when links were broken, false otherwise
      • breakLinksWithInternalConnections

        protected void breakLinksWithInternalConnections()
        whenever we find that internal nodes are used by more than one link OR a node is an extreme node on an existing link but also an internal link on another node, we break the links where this node is internal. the end result is a situations where all nodes used by more than one link are extreme nodes, i.e., start/end nodes.

        Osm ways with multiple planit links associated with them can cause problems because in the handler we only register nodes internal to the original way to link mapping. If a link is broken we adjust the original link and create an additional link causing the original mapping between internal nodes and PLANit link to be potentially incorrect. We require the osmWaysWithMultiplePlanitLinks map to track these changes so that we can always identify which of multiple PLANit links an internal node currently resides on.

      • logOsmProfileInformation

        public void logOsmProfileInformation()
        log profile information gathered during parsing (so far)
      • logPlanitStatsInformation

        public void logPlanitStatsInformation()
        log profile information gathered during parsing (so far)
      • reset

        public void reset()
        reset the contents, mainly to free up unused resources
      • complete

        public void complete()
        complete the parsing, invoked from parent handler complete method
      • getLayerData

        public OsmNetworkReaderLayerData getLayerData()
        collect the gathered data pertaining to Osm to Planit entity mapping that might be relevant to other parts of the reader
        Returns:
        layer data