Class OsmZoningHandlerBase
- java.lang.Object
-
- de.topobyte.osm4j.core.access.DefaultOsmHandler
-
- org.goplanit.osm.converter.zoning.handler.OsmZoningHandlerBase
-
- All Implemented Interfaces:
de.topobyte.osm4j.core.access.OsmHandler
- Direct Known Subclasses:
OsmZoningMainProcessingHandler
,OsmZoningPostProcessingHandler
,OsmZoningPreProcessingHandler
public abstract class OsmZoningHandlerBase extends de.topobyte.osm4j.core.access.DefaultOsmHandler
Base Handler for all zoning handlers. Contains shared functionality that is used across the different zoning handlers- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description OsmZoningHandlerBase(OsmPublicTransportReaderSettings transferSettings, OsmZoningReaderData zoningReaderData, OsmNetworkToZoningReaderData network2ZoningData, PlanitOsmNetwork referenceNetwork, Zoning zoningToPopulate, OsmZoningHandlerProfiler profiler)
constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected OsmConnectoidHelper
getConnectoidHelper()
Get the connectoid parserprotected PlanitJtsCrsUtils
getGeoUtils()
Get geo utilsprotected OsmNetworkToZoningReaderData
getNetworkToZoningData()
Get network to zoning dataprotected OsmZoningHandlerProfiler
getProfiler()
Get profilerprotected OsmPublicTransportModeConversion
getPtModeHelper()
Get the public transport mode parserprotected PlanitOsmNetwork
getReferenceNetwork()
protected OsmPublicTransportReaderSettings
getSettings()
Get PT settingsprotected TransferZoneGroupHelper
getTransferZoneGroupHelper()
Get the transfer zone group parserprotected TransferZoneHelper
getTransferZoneHelper()
Get the transfer zone parserprotected Zoning
getZoning()
Collect zoningprotected OsmZoningReaderData
getZoningReaderData()
Get zoning reader dataprotected boolean
hasNetworkLayersWithActiveOsmNode(long osmNodeId)
Verify if there exist any layers where the node is active either as an extreme node or internal to a PLANit linkabstract void
initialiseBeforeParsing()
Call this BEFORE we parse the OSM network to initialise the handler properlyprotected OsmPtVersionScheme
isActivatedPublicTransportInfrastructure(Map<String,String> tags)
Verify if tags represent an infrastructure used for transfers between modes, for example PT platforms, stops, etc.protected boolean
isCoveredByZoningBoundingPolygon(de.topobyte.osm4j.core.model.iface.OsmNode osmNode)
Verify if node resides on or within the zoning bounding polygon.protected boolean
isCoveredByZoningBoundingPolygon(de.topobyte.osm4j.core.model.iface.OsmWay osmWay)
Verify if OSM way has at least one node that resides within the zoning bounding polygon.protected boolean
isNearNetworkBoundingBox(de.topobyte.osm4j.core.model.iface.OsmNode osmNode)
Verify if node resides near the zoning bounding polygon based on #OsmNetworkReaderData.protected void
logWarningIfNotNearBoundingBox(String message, org.locationtech.jts.geom.Geometry geometry)
log the given warning message but only when it is not too close to the bounding box, because then it is too likely that it is discarded due to missing infrastructure or other missing assets that could not be parsed fully as they pass through the bounding box barrier.abstract void
reset()
reset the contents, mainly to free up unused resourcesprotected boolean
skipOsmNode(de.topobyte.osm4j.core.model.iface.OsmNode osmNode)
skip osm node when marked for exclusion in settingsprotected boolean
skipOsmPtEntity(de.topobyte.osm4j.core.model.iface.OsmRelationMember member)
Skip SOM relation member when marked for exclusion in settingsprotected boolean
skipOsmWay(de.topobyte.osm4j.core.model.iface.OsmWay osmWay)
skip osm way when marked for exclusion in settingsprotected void
wrapHandlePtOsmNode(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, TriConsumer<de.topobyte.osm4j.core.model.iface.OsmNode,OsmPtVersionScheme,Map<String,String>> osmNodeConsumer)
Wrap the handling of OSM node by checking if it is eligible (PT specific) and catch any run time PLANit exceptions, if eligible delegate to consumer.protected void
wrapHandlePtOsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation osmRelation, BiConsumer<de.topobyte.osm4j.core.model.iface.OsmRelation,Map<String,String>> osmRelationConsumer)
Wrap the handling of OSM relation by performing basic checks on eligibility and wrapping any run time excpetions thrownprotected void
wrapHandlePtOsmWay(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, TriConsumer<de.topobyte.osm4j.core.model.iface.OsmWay,OsmPtVersionScheme,Map<String,String>> osmWayConsumer)
Wrap the handling of OSM way for OSM zoning by checking if it is eligible and catch any run time PLANit exceptions, if eligible delegate to consumer.
-
-
-
Constructor Detail
-
OsmZoningHandlerBase
public OsmZoningHandlerBase(OsmPublicTransportReaderSettings transferSettings, OsmZoningReaderData zoningReaderData, OsmNetworkToZoningReaderData network2ZoningData, PlanitOsmNetwork referenceNetwork, Zoning zoningToPopulate, OsmZoningHandlerProfiler profiler)
constructor- Parameters:
transferSettings
- for the handlerzoningReaderData
- gather data during parsing and utilise available data from pre-processingnetwork2ZoningData
- data transferred from parsing network to be used by zoning reader.referenceNetwork
- to usezoningToPopulate
- to populateprofiler
- to keep track of created/parsed entities across zone handlers
-
-
Method Detail
-
getReferenceNetwork
protected PlanitOsmNetwork getReferenceNetwork()
-
skipOsmPtEntity
protected boolean skipOsmPtEntity(de.topobyte.osm4j.core.model.iface.OsmRelationMember member)
Skip SOM relation member when marked for exclusion in settings- Parameters:
member
- to verify- Returns:
- true when it should be skipped, false otherwise
-
skipOsmNode
protected boolean skipOsmNode(de.topobyte.osm4j.core.model.iface.OsmNode osmNode)
skip osm node when marked for exclusion in settings- Parameters:
osmNode
- to verify- Returns:
- true when it should be skipped, false otherwise
-
skipOsmWay
protected boolean skipOsmWay(de.topobyte.osm4j.core.model.iface.OsmWay osmWay)
skip osm way when marked for exclusion in settings- Parameters:
osmWay
- to verify- Returns:
- true when it should be skipped, false otherwise
-
isCoveredByZoningBoundingPolygon
protected boolean isCoveredByZoningBoundingPolygon(de.topobyte.osm4j.core.model.iface.OsmNode osmNode)
Verify if node resides on or within the zoning bounding polygon. If no bounding area is defined this always returns true- Parameters:
osmNode
- to verify- Returns:
- true when no bounding area, or covered by bounding area, false otherwise
-
isNearNetworkBoundingBox
protected boolean isNearNetworkBoundingBox(de.topobyte.osm4j.core.model.iface.OsmNode osmNode)
Verify if node resides near the zoning bounding polygon based on #OsmNetworkReaderData. If no bounding area is defined this always returns true- Parameters:
osmNode
- to verify- Returns:
- true when no bounding area, or covered by bounding area, false otherwise
-
isCoveredByZoningBoundingPolygon
protected boolean isCoveredByZoningBoundingPolygon(de.topobyte.osm4j.core.model.iface.OsmWay osmWay)
Verify if OSM way has at least one node that resides within the zoning bounding polygon. If no bounding area is defined this always returns true- Parameters:
osmWay
- to verify- Returns:
- true when no bounding area, or covered by bounding area, false otherwise
-
hasNetworkLayersWithActiveOsmNode
protected boolean hasNetworkLayersWithActiveOsmNode(long osmNodeId)
Verify if there exist any layers where the node is active either as an extreme node or internal to a PLANit link- Parameters:
osmNodeId
- to use- Returns:
- true when one or more layers are found, false otherwise
-
isActivatedPublicTransportInfrastructure
protected OsmPtVersionScheme isActivatedPublicTransportInfrastructure(Map<String,String> tags)
Verify if tags represent an infrastructure used for transfers between modes, for example PT platforms, stops, etc. and is also activated for parsing based on the related settings- Parameters:
tags
- to verify- Returns:
- which scheme it is compatible with, NONE if none could be found or if it is not active
-
logWarningIfNotNearBoundingBox
protected void logWarningIfNotNearBoundingBox(String message, org.locationtech.jts.geom.Geometry geometry)
log the given warning message but only when it is not too close to the bounding box, because then it is too likely that it is discarded due to missing infrastructure or other missing assets that could not be parsed fully as they pass through the bounding box barrier. Therefore the resulting warning message is likely more confusing than helpful in those situation and is therefore ignored- Parameters:
message
- to log if not too close to bounding boxgeometry
- to determine distance to bounding box to
-
wrapHandlePtOsmWay
protected void wrapHandlePtOsmWay(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, TriConsumer<de.topobyte.osm4j.core.model.iface.OsmWay,OsmPtVersionScheme,Map<String,String>> osmWayConsumer)
Wrap the handling of OSM way for OSM zoning by checking if it is eligible and catch any run time PLANit exceptions, if eligible delegate to consumer.- Parameters:
osmWay
- to parseosmWayConsumer
- to apply to eligible OSM way
-
wrapHandlePtOsmRelation
protected void wrapHandlePtOsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation osmRelation, BiConsumer<de.topobyte.osm4j.core.model.iface.OsmRelation,Map<String,String>> osmRelationConsumer)
Wrap the handling of OSM relation by performing basic checks on eligibility and wrapping any run time excpetions thrown- Parameters:
osmRelation
- to wrap parsing ofosmRelationConsumer
- to apply when relation is has Ptv2 public transport tags and is either a stop area or multipolygon transport platform
-
wrapHandlePtOsmNode
protected void wrapHandlePtOsmNode(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, TriConsumer<de.topobyte.osm4j.core.model.iface.OsmNode,OsmPtVersionScheme,Map<String,String>> osmNodeConsumer)
Wrap the handling of OSM node by checking if it is eligible (PT specific) and catch any run time PLANit exceptions, if eligible delegate to consumer.- Parameters:
osmNode
- to parseosmNodeConsumer
- to apply to eligible OSM way
-
getGeoUtils
protected final PlanitJtsCrsUtils getGeoUtils()
Get geo utils- Returns:
- geo utils
-
getProfiler
protected final OsmZoningHandlerProfiler getProfiler()
Get profiler- Returns:
- profiler
-
getZoningReaderData
protected final OsmZoningReaderData getZoningReaderData()
Get zoning reader data- Returns:
- data
-
getZoning
protected final Zoning getZoning()
Collect zoning- Returns:
- zoning;
-
getNetworkToZoningData
protected final OsmNetworkToZoningReaderData getNetworkToZoningData()
Get network to zoning data- Returns:
- network to zoning data
-
getSettings
protected OsmPublicTransportReaderSettings getSettings()
Get PT settings- Returns:
- settings
-
getTransferZoneHelper
protected TransferZoneHelper getTransferZoneHelper()
Get the transfer zone parser- Returns:
- transfer zone parser
-
getTransferZoneGroupHelper
protected TransferZoneGroupHelper getTransferZoneGroupHelper()
Get the transfer zone group parser- Returns:
- transfer zone group parser
-
getPtModeHelper
protected OsmPublicTransportModeConversion getPtModeHelper()
Get the public transport mode parser- Returns:
- public transport mode parser
-
getConnectoidHelper
protected OsmConnectoidHelper getConnectoidHelper()
Get the connectoid parser- Returns:
- connectoidParser parser
-
initialiseBeforeParsing
public abstract void initialiseBeforeParsing()
Call this BEFORE we parse the OSM network to initialise the handler properly
-
reset
public abstract void reset()
reset the contents, mainly to free up unused resources
-
-