Class OsmBoundingAreaUtils


  • public class OsmBoundingAreaUtils
    extends Object
    Utilities regarding the use of a bounding box when parsing OSM data
    Author:
    markr
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.locationtech.jts.geom.Envelope createBoundingBox​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, double offsetInMeters, PlanitJtsCrsUtils geoUtils)
      create a (Rectangular) bounding box around the osm node geometry based on the provided offset
      static org.locationtech.jts.geom.Envelope createBoundingBoxForOsmWay​(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity, double offsetInMeters, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, PlanitJtsCrsUtils geoUtils)
      create a bounding box based on the provided offset and OSM entity geometry.
      static boolean isCoveredByZoningBoundingPolygon​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode, org.locationtech.jts.geom.Polygon boundingPolygon)
      Verify if node resides on or within the zoning bounding polygon.
      static boolean isCoveredByZoningBoundingPolygon​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay, Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes, org.locationtech.jts.geom.Polygon boundingPolygon)
      Verify if OSM way has at least one node that resides within the zoning bounding polygon.
      static boolean isNearNetworkBoundingBox​(org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.Envelope networkBoundingBox, PlanitJtsCrsUtils geoUtils)
      check if geometry is near network bounding box using buffer based on PlanitOsmNetworkReaderData.BOUNDINGBOX_NEARNESS_DISTANCE_METERS
      static void logWarningIfNotNearBoundingBox​(String message, org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.Envelope boundingBox, PlanitJtsCrsUtils geoUtils)
      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.
    • Constructor Detail

      • OsmBoundingAreaUtils

        public OsmBoundingAreaUtils()
    • Method Detail

      • logWarningIfNotNearBoundingBox

        public static void logWarningIfNotNearBoundingBox​(String message,
                                                          org.locationtech.jts.geom.Geometry geometry,
                                                          org.locationtech.jts.geom.Envelope boundingBox,
                                                          PlanitJtsCrsUtils geoUtils)
        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 box
        geometry - to determine distance to bounding box to
        boundingBox - to use
        geoUtils - to use
      • isNearNetworkBoundingBox

        public static boolean isNearNetworkBoundingBox​(org.locationtech.jts.geom.Geometry geometry,
                                                       org.locationtech.jts.geom.Envelope networkBoundingBox,
                                                       PlanitJtsCrsUtils geoUtils)
        check if geometry is near network bounding box using buffer based on PlanitOsmNetworkReaderData.BOUNDINGBOX_NEARNESS_DISTANCE_METERS
        Parameters:
        geometry - to check
        networkBoundingBox - to consider
        geoUtils - to use
        Returns:
        true when near, false otherwise
      • isCoveredByZoningBoundingPolygon

        public static boolean isCoveredByZoningBoundingPolygon​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                               org.locationtech.jts.geom.Polygon boundingPolygon)
        Verify if node resides on or within the zoning bounding polygon. If no bounding area is defined or if no node is provided (null), false is returned by definition
        Parameters:
        osmNode - to verify
        boundingPolygon - defining the area
        Returns:
        true when no bounding area, or covered by bounding area, false otherwise
      • isCoveredByZoningBoundingPolygon

        public static boolean isCoveredByZoningBoundingPolygon​(de.topobyte.osm4j.core.model.iface.OsmWay osmWay,
                                                               Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                               org.locationtech.jts.geom.Polygon boundingPolygon)
        Verify if OSM way has at least one node that resides within the zoning bounding polygon. If no bounding area is defined or OSM way is null false is returned by definition
        Parameters:
        osmWay - to verify
        osmNodes - to collect nodes of way from
        boundingPolygon - defining the area
        Returns:
        true when covered by bounding area, false otherwise
      • createBoundingBoxForOsmWay

        public static org.locationtech.jts.geom.Envelope createBoundingBoxForOsmWay​(de.topobyte.osm4j.core.model.iface.OsmEntity osmEntity,
                                                                                    double offsetInMeters,
                                                                                    Map<Long,​de.topobyte.osm4j.core.model.iface.OsmNode> osmNodes,
                                                                                    PlanitJtsCrsUtils geoUtils)
        create a bounding box based on the provided offset and OSM entity geometry. The bounding box adds the offset to the extremes of the geometry
        Parameters:
        osmEntity - to create bounding box for
        offsetInMeters - buffer in meters
        osmNodes - used in case osm entity is not a node and we require to obtain geometry information from underlying referenced nodes
        geoUtils - used to extract distances based on underlying crs
        Returns:
        bounding box
      • createBoundingBox

        public static org.locationtech.jts.geom.Envelope createBoundingBox​(de.topobyte.osm4j.core.model.iface.OsmNode osmNode,
                                                                           double offsetInMeters,
                                                                           PlanitJtsCrsUtils geoUtils)
        create a (Rectangular) bounding box around the osm node geometry based on the provided offset
        Parameters:
        osmNode - to create bounding box around
        offsetInMeters - of the bounding box with node location in centre
        geoUtils - to properly create bounding box based on crs
        Returns:
        bounding box