Package org.goplanit.converter.zoning
Class ZoningConverterUtils
- java.lang.Object
-
- org.goplanit.converter.zoning.ZoningConverterUtils
-
public class ZoningConverterUtils extends Object
Utilities regarding Zoning conversions that might be useful for implementations supporting the mapping of non-PLANit geometry based entities to PLANit transfer zones and connectoids- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description ZoningConverterUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DirectedConnectoid
createAndRegisterDirectedConnectoid(Zoning zoning, TransferZone accessZone, boolean downstreamAccessNode, MacroscopicLinkSegment linkSegment, Set<Mode> allowedModes)
create directed connectoid for the link segment provided, all related to the given transfer zone and with access modes provided.static Collection<DirectedConnectoid>
createAndRegisterDirectedConnectoids(Zoning zoning, TransferZone transferZone, Node accessNode, Iterable<? extends MacroscopicLinkSegment> linkSegments, Set<Mode> allowedModes)
create directed connectoids, one per link segment provided, all related to the given transfer zone and with access modes provided.static Pair<MacroscopicLink,Boolean>
excludeClosestLinksIncrementallyOnWrongSideOf(org.locationtech.jts.geom.Geometry location, Collection<MacroscopicLink> links, boolean isLeftHandDrive, Collection<? extends Mode> accessModes, PlanitJtsCrsUtils geoUtils)
Exclude the closest link if it is situated on the wrong side of the road, then if links are remaining keep going with removing the then closest if it is also on the wrong side of the road etc.static Collection<MacroscopicLink>
excludeLinksOnWrongSideOf(org.locationtech.jts.geom.Geometry location, Collection<MacroscopicLink> links, boolean isLeftHandDrive, Collection<? extends Mode> accessModes, PlanitJtsCrsUtils geoUtils)
create a subset of links from the passed in ones, removing all links for which we can be certain that geometry is located on the wrong side of the road infrastructure geometry.static Collection<LinkSegment>
findAccessEntryLinkSegmentsForWaitingArea(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Node node, Mode accessMode, String countryName, boolean mustAvoidCrossingTraffic, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, Function<Node,String> getOverwrittenWaitingAreaSourceId, PlanitJtsCrsUtils geoUtils)
Find the link segments that are accessible for the given access link, node, mode combination taking into account the relative location of the transfer zone if needed and mode compatibility.static Collection<? extends LinkSegment>
findAccessLinkSegmentsForWaitingArea(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Mode accessMode, String countryName, boolean mustAvoidCrossingTraffic, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, Function<Node,String> getOverwrittenWaitingAreaSourceId, PlanitJtsCrsUtils geoUtils)
static org.locationtech.jts.geom.Point
findConnectoidLocationForWaitingAreaOnLink(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Mode accessMode, double maxAllowedDistanceMeters, Function<Node,String> getOverwrittenWaitingAreaSourceIdForNode, Function<org.locationtech.jts.geom.Point,String> getOverwrittenWaitingAreaSourceIdForPoint, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
Deprecated.static org.locationtech.jts.geom.Point
findConnectoidLocationForWaitingAreaOnLinkSegment(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLinkSegment accessLinkSegment, String accessLinkSourceId, Mode accessMode, double maxAllowedDistanceMeters, Function<Node,String> getOverwrittenWaitingAreaSourceIdForNode, Function<org.locationtech.jts.geom.Point,String> getOverwrittenWaitingAreaSourceIdForPoint, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
find a suitable connectoid location on the given link based on the constraints that it must be able to reside on a link segment that is in the correct relative position to the transfer zone and supports the access mode on at least one of the designated link segment(s) that is eligible (if any).static boolean
hasWaitingAreaPotentialAccessLinkSegmentForLinkNodeModeCombination(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Node accessNode, Mode accessMode, Function<Node,String> getOverwrittenWaitingAreaSourceId, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
Verify if any valid access link segments exist for the given combination of link, one of its extreme nodes, and the access mode, taking into account any explicit overwrites that may exist that are not bounded by any limitations on compatibility.static Collection<LinkSegment>
identifyLinkSegmentsOnWrongSideOf(org.locationtech.jts.geom.Geometry location, Collection<LinkSegment> accessLinkSegments, boolean leftHandDrive, PlanitJtsCrsUtils geoUtils)
Find the access link segments ineligible given the intended location and the access mode.static boolean
isAvoidCrossTrafficForAccessMode(Mode accessMode)
Verify if the waiting area for an access mode's access link(segment) must be on the logical relative location (left hand side for left hand drive) or not.static <T> boolean
isAvoidCrossTrafficForAccessModeOrAccessNodeWaitingAreaOverwritten(Mode accessMode, String waitingAreaSourceId, T accessEntity, Function<T,String> getOverwrittenWaitingAreaSourceId)
Verify if the waiting area for an access mode's access link(segment) must be on the logical relative location (left hand side for left hand drive) or not.static boolean
isPotentialAccessEntryLinkSegmentForWaitingArea(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLinkSegment accessLinkSegment, String accessLinkSourceId, Node accessNode, Mode accessMode, Function<Node,String> getOverwrittenWaitingAreaSourceId, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
Verify if given link segment is potentially viable as access link segment for the given extreme node and access mode, taking into account any explicit overwrites that may exist that are not bounded by any limitations on compatibility.static boolean
isWaitingAreaLeftOfAccessLineSegment(org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLinkSegment accessLinkSegment, org.locationtech.jts.geom.LineSegment accessLinkSegmentLineSegment, PlanitJtsCrsUtils geoUtils)
Verify if the provided line segment (somewhere along the geometry of the access link segment) resides on the correct side of the waiting area location, assuming this matters
-
-
-
Method Detail
-
isWaitingAreaLeftOfAccessLineSegment
public static boolean isWaitingAreaLeftOfAccessLineSegment(org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLinkSegment accessLinkSegment, org.locationtech.jts.geom.LineSegment accessLinkSegmentLineSegment, PlanitJtsCrsUtils geoUtils)
Verify if the provided line segment (somewhere along the geometry of the access link segment) resides on the correct side of the waiting area location, assuming this matters- Parameters:
waitingAreaGeometry
- for which to check locationaccessLinkSegment
- the location resides onaccessLinkSegmentLineSegment
- to usegeoUtils
- to use- Returns:
- true when left of, false otherwise
-
isAvoidCrossTrafficForAccessModeOrAccessNodeWaitingAreaOverwritten
public static <T> boolean isAvoidCrossTrafficForAccessModeOrAccessNodeWaitingAreaOverwritten(Mode accessMode, String waitingAreaSourceId, T accessEntity, Function<T,String> getOverwrittenWaitingAreaSourceId)
Verify if the waiting area for an access mode's access link(segment) must be on the logical relative location (left hand side for left hand drive) or not. In case the mapping is overwritten it is assumed the driving direction does not matter as it is user defined to be explicitly mapped.- Type Parameters:
T
- type of access entity- Parameters:
accessMode
- to checkwaitingAreaSourceId
- required to check if user overwrite is present for this waiting area, may be null toaccessEntity
- the access entity that may be mapped to the waiting area under investigation, may be null if not availablegetOverwrittenWaitingAreaSourceId
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrritten- Returns:
- true when restricted for driving direction, false otherwise
-
isAvoidCrossTrafficForAccessMode
public static boolean isAvoidCrossTrafficForAccessMode(Mode accessMode)
Verify if the waiting area for an access mode's access link(segment) must be on the logical relative location (left hand side for left hand drive) or not.- Parameters:
accessMode
- to check- Returns:
- true when restricted for driving direction, false otherwise
-
excludeLinksOnWrongSideOf
public static Collection<MacroscopicLink> excludeLinksOnWrongSideOf(org.locationtech.jts.geom.Geometry location, Collection<MacroscopicLink> links, boolean isLeftHandDrive, Collection<? extends Mode> accessModes, PlanitJtsCrsUtils geoUtils)
create a subset of links from the passed in ones, removing all links for which we can be certain that geometry is located on the wrong side of the road infrastructure geometry. Note that rails is not excluded in this exercise, i.e., it is assumed rail lines ar bi-rectional. Right or wrong side is verified by checking if the link is one-way. If so, we can be sure (based on the driving direction of the country) if the geometry is located to the closest by (logical) driving direction given the placement of the geometry, i.e., on the left hand side for left hand drive countries, on the right hand side for right hand driving countries- Parameters:
location
- representing the location of concern expected to have access to the linklinks
- to remove in-eligible ones fromisLeftHandDrive
- flagaccessModes
- to considergeoUtils
- to use- Returns:
- remaining links that are deemed eligible
-
identifyLinkSegmentsOnWrongSideOf
public static Collection<LinkSegment> identifyLinkSegmentsOnWrongSideOf(org.locationtech.jts.geom.Geometry location, Collection<LinkSegment> accessLinkSegments, boolean leftHandDrive, PlanitJtsCrsUtils geoUtils)
Find the access link segments ineligible given the intended location and the access mode. When transfer zone location differs from the connectoid location determine on which side of the infrastructure it exists and based on the country's driving direction and access mode determine the access link segments- Parameters:
accessLinkSegments
- to filterlocation
- to identify incorrectly located link segments forleftHandDrive
- is infrastructure left hand drive or notgeoUtils
- to use for determining geographic eligibility- Returns:
- ineligible link segments to be access link segments for connectoid at this location
-
excludeClosestLinksIncrementallyOnWrongSideOf
public static Pair<MacroscopicLink,Boolean> excludeClosestLinksIncrementallyOnWrongSideOf(org.locationtech.jts.geom.Geometry location, Collection<MacroscopicLink> links, boolean isLeftHandDrive, Collection<? extends Mode> accessModes, PlanitJtsCrsUtils geoUtils)
Exclude the closest link if it is situated on the wrong side of the road, then if links are remaining keep going with removing the then closest if it is also on the wrong side of the road etc.- Parameters:
location
- to verify against, typically a transfer zone locationlinks
- to updateisLeftHandDrive
- network driving directionaccessModes
- for the locationgeoUtils
- to use- Returns:
- pair with remaining closest link found and boolean indicating if any closest links were removed before finding a compatible closest links (true when one or more closest links are removed, false otherwise)
-
findAccessLinkSegmentsForWaitingArea
public static Collection<? extends LinkSegment> findAccessLinkSegmentsForWaitingArea(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Mode accessMode, String countryName, boolean mustAvoidCrossingTraffic, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, Function<Node,String> getOverwrittenWaitingAreaSourceId, PlanitJtsCrsUtils geoUtils)
-
findAccessEntryLinkSegmentsForWaitingArea
public static Collection<LinkSegment> findAccessEntryLinkSegmentsForWaitingArea(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Node node, Mode accessMode, String countryName, boolean mustAvoidCrossingTraffic, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, Function<Node,String> getOverwrittenWaitingAreaSourceId, PlanitJtsCrsUtils geoUtils)
Find the link segments that are accessible for the given access link, node, mode combination taking into account the relative location of the transfer zone if needed and mode compatibility.- Parameters:
waitingAreaSourceId
- these link segments pertain towaitingAreaGeometry
- these link segments pertain toaccessLink
- that is nominatedaccessLinkSourceId
- source id of the access link used, this will be matched gainst the overwritten access link source id (if provided)node
- extreme node of the linkaccessMode
- eligible access modecountryName
- we are considering from which we will extract whether it is a left or right hand drive countrymustAvoidCrossingTraffic
- flag indicating if cross traffic should be avoided for the access link segments that are deemed eligiblegetOverwrittenAccessLinkSourceIdForWaitingAreaSourceId
- mapping from waiting area source id to nominated access link source id, which if a match to provided access link source id makes sure that even if there exists crossing traffic this does not render its access link segment(s) invalid, may be nullgetOverwrittenWaitingAreaSourceId
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrrittengeoUtils
- to use- Returns:
- found link segments that are deemed valid given the constraints
-
isPotentialAccessEntryLinkSegmentForWaitingArea
public static boolean isPotentialAccessEntryLinkSegmentForWaitingArea(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLinkSegment accessLinkSegment, String accessLinkSourceId, Node accessNode, Mode accessMode, Function<Node,String> getOverwrittenWaitingAreaSourceId, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
Verify if given link segment is potentially viable as access link segment for the given extreme node and access mode, taking into account any explicit overwrites that may exist that are not bounded by any limitations on compatibility.- Parameters:
waitingAreaSourceId
- we're checking forwaitingAreaGeometry
- we're checking foraccessLinkSegment
- nominatedaccessLinkSourceId
- original source id of the PLANit access linkaccessNode
- that is nominatedaccessMode
- usedgetOverwrittenWaitingAreaSourceId
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrittengetOverwrittenAccessLinkSourceIdForWaitingAreaSourceId
- mapping from waiting area source id to nominated access link source id, which if a match to provided access link source id makes sure that even if there exists crossing traffic this does not render its access link segment(s) invalid, may be nullcountryName
- to extract driving direction fromgeoUtils
- gis functionality to apply in finding connectoid location- Returns:
- true when at least one valid access link segment exists, false otherwise
-
hasWaitingAreaPotentialAccessLinkSegmentForLinkNodeModeCombination
public static boolean hasWaitingAreaPotentialAccessLinkSegmentForLinkNodeModeCombination(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Node accessNode, Mode accessMode, Function<Node,String> getOverwrittenWaitingAreaSourceId, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
Verify if any valid access link segments exist for the given combination of link, one of its extreme nodes, and the access mode, taking into account any explicit overwrites that may exist that are not bounded by any limitations on compatibility.- Parameters:
waitingAreaSourceId
- we're checking forwaitingAreaGeometry
- we're checking foraccessLink
- nominatedaccessLinkSourceId
- original source id of the PLANit access linkaccessNode
- that is nominatedaccessMode
- usedgetOverwrittenWaitingAreaSourceId
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrittengetOverwrittenAccessLinkSourceIdForWaitingAreaSourceId
- mapping from waiting area source id to nominated access link source id, which if a match to provided access link source id makes sure that even if there exists crossing traffic this does not render its access link segment(s) invalid, may be nullcountryName
- to extract driving direction fromgeoUtils
- gis functionality to apply in finding connectoid location- Returns:
- true when at least one valid access link segment exists, false otherwise
-
findConnectoidLocationForWaitingAreaOnLinkSegment
public static org.locationtech.jts.geom.Point findConnectoidLocationForWaitingAreaOnLinkSegment(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLinkSegment accessLinkSegment, String accessLinkSourceId, Mode accessMode, double maxAllowedDistanceMeters, Function<Node,String> getOverwrittenWaitingAreaSourceIdForNode, Function<org.locationtech.jts.geom.Point,String> getOverwrittenWaitingAreaSourceIdForPoint, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
find a suitable connectoid location on the given link based on the constraints that it must be able to reside on a link segment that is in the correct relative position to the transfer zone and supports the access mode on at least one of the designated link segment(s) that is eligible (if any). If not null is returned, otherwise the returned location may be an existing extreme node's location, or a location internal to the link if the extreme node does not fall within the constraints provided- Parameters:
waitingAreaSourceId
- supplies a relevant source id of the waiting area in question to use for exceptions or logging when neededwaitingAreaGeometry
- to find location for (which is either sourced from a PLANit transfer zone, or to be created transfer zone) that will reflect this waiting area)accessLinkSegment
- to find location onaccessLinkSourceId
- the access link's source idaccessMode
- to be compatible withmaxAllowedDistanceMeters
- the maximum allowed distance between stop and waiting area that we allowgetOverwrittenWaitingAreaSourceIdForNode
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrittengetOverwrittenWaitingAreaSourceIdForPoint
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrittengetOverwrittenAccessLinkSourceIdForWaitingAreaSourceId
- mapping from waiting area source id to nominated access link source id, which if a match to provided access link source id makes sure that even if there exists crossing traffic this does not render its access link segment(s) invalid, may be nullcountryName
- to extract driving direction fromgeoUtils
- gis functionality to apply in finding connectoid location- Returns:
- found location either existing node or projected location that is nearest and does not exist as a shape point on the link yet, or null if no valid position could be found
-
findConnectoidLocationForWaitingAreaOnLink
@Deprecated public static org.locationtech.jts.geom.Point findConnectoidLocationForWaitingAreaOnLink(String waitingAreaSourceId, org.locationtech.jts.geom.Geometry waitingAreaGeometry, MacroscopicLink accessLink, String accessLinkSourceId, Mode accessMode, double maxAllowedDistanceMeters, Function<Node,String> getOverwrittenWaitingAreaSourceIdForNode, Function<org.locationtech.jts.geom.Point,String> getOverwrittenWaitingAreaSourceIdForPoint, Function<String,String> getOverwrittenAccessLinkSourceIdForWaitingAreaSourceId, String countryName, PlanitJtsCrsUtils geoUtils)
Deprecated.find a suitable connectoid location on the given link based on the constraints that it must be able to reside on a link segment that is in the correct relative position to the transfer zone and supports the access mode on at least one of the designated link segment(s) that is eligible (if any). If not null is returned, otherwise the returned location may be an existing extreme node's location, or a location internal to the link if the extreme node does not fall within the constraints provided- Parameters:
waitingAreaSourceId
- supplies a relevant source id of the waiting area in question to use for exceptions or logging when neededwaitingAreaGeometry
- to find location for (which is either sourced from a PLANit transfer zone, or to be created transfer zone) that will reflect this waiting area)accessLink
- to find location onaccessLinkSourceId
- the access link's source idaccessMode
- to be compatible withmaxAllowedDistanceMeters
- the maximum allowed distance between stop and waiting area that we allowgetOverwrittenWaitingAreaSourceIdForNode
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrittengetOverwrittenWaitingAreaSourceIdForPoint
- function that provides the overwritten waiting area source id for a given access node, maybe return null if not overwrittengetOverwrittenAccessLinkSourceIdForWaitingAreaSourceId
- mapping from waiting area source id to nominated access link source id, which if a match to provided access link source id makes sure that even if there exists crossing traffic this does not render its access link segment(s) invalid, may be nullcountryName
- to extract driving direction fromgeoUtils
- gis functionality to apply in finding connectoid location- Returns:
- found location either existing node or projected location that is nearest and does not exist as a shape point on the link yet, or null if no valid position could be found
-
createAndRegisterDirectedConnectoid
public static DirectedConnectoid createAndRegisterDirectedConnectoid(Zoning zoning, TransferZone accessZone, boolean downstreamAccessNode, MacroscopicLinkSegment linkSegment, Set<Mode> allowedModes)
create directed connectoid for the link segment provided, all related to the given transfer zone and with access modes provided. When the link segment does not have any of the passed in modes listed as allowed, no connectoid is created and null is returned- Parameters:
zoning
- to register onaccessZone
- to relate connectoids todownstreamAccessNode
- when true access node is chosen as the downstream node, when false, upstream node is chosenlinkSegment
- to create connectoid forallowedModes
- used for the connectoid- Returns:
- created connectoid when at least one of the allowed modes is also allowed on the link segment
-
createAndRegisterDirectedConnectoids
public static Collection<DirectedConnectoid> createAndRegisterDirectedConnectoids(Zoning zoning, TransferZone transferZone, Node accessNode, Iterable<? extends MacroscopicLinkSegment> linkSegments, Set<Mode> allowedModes)
create directed connectoids, one per link segment provided, all related to the given transfer zone and with access modes provided. connectoids are only created when the access link segment has at least one of the allowed modes as an eligible mode- Parameters:
zoning
- to register ontransferZone
- to relate connectoids toaccessNode
- the access node the connectoid utilises (determine the up/downstream connection of the attached link segment(s)linkSegments
- to create connectoids for (one per segment)allowedModes
- used for each connectoid- Returns:
- created connectoids
-
-