Class OSHDBGeometryBuilder


  • public class OSHDBGeometryBuilder
    extends Object
    Builds JTS geometries from OSM entities.
    • Method Detail

      • getGeometry

        @Nonnull
        public static org.locationtech.jts.geom.Geometry getGeometry​(OSMEntity entity,
                                                                     OSHDBTimestamp timestamp,
                                                                     TagInterpreter areaDecider)
        Gets the geometry of an OSM entity at a specific timestamp.

        The given timestamp must be in the valid timestamp range of the given entity version:

        • timestamp must be equal or bigger than entity.getTimestamp()
        • timestamp must be less than the next version of this osm entity (if one exists)
        Parameters:
        entity - the osm entity to generate the geometry of
        timestamp - the timestamp for which to create the entity's geometry
        areaDecider - a TagInterpreter object which decides whether to generate a linear or a polygonal geometry for the respective entity (based on its tags)
        Returns:
        a JTS geometry object (simple features compatible, i.e. a Point, LineString, Polygon or MultiPolygon)
      • getGeometry

        public static org.locationtech.jts.geom.Polygon getGeometry​(@Nonnull
                                                                    OSHDBBoundable bbox)
        Converts a OSHDBBoundingBox to a rectangular polygon.

        Will return a polygon with exactly 4 vertices even for point or line-like BoundingBox. Nevertheless, for degenerate bounding boxes (width and/or height of 0) the result might not pass the Geometry.isRectangle test.

        Parameters:
        bbox - The BoundingBox the polygon should be created for.
        Returns:
        a rectangular Polygon
      • getCoordinate

        public static org.locationtech.jts.geom.Coordinate getCoordinate​(OSMNode node)
      • getCoordinate

        public static org.locationtech.jts.geom.Coordinate getCoordinate​(int osmLon,
                                                                         int osmLat)
        Creates a new instance of jts Coordinate from lon, lat in osm-coordinate system.
        Parameters:
        osmLon - Longitude in osm-coordinate system
        osmLat - Latitude in osm-coordinate system
        Returns:
        new Coordinate instance
      • getGeometryClipped

        public static org.locationtech.jts.geom.Geometry getGeometryClipped​(OSMEntity entity,
                                                                            OSHDBTimestamp timestamp,
                                                                            TagInterpreter areaDecider,
                                                                            OSHDBBoundingBox clipBbox)
        Builds the geometry of an OSM entity at the given timestamp, clipped to the given bounding box.
        Parameters:
        entity - the osm entity to generate the geometry of
        timestamp - the timestamp for which to create the entity's geometry
        areaDecider - a TagInterpreter object which decides whether to generate a linear or a polygonal geometry for the respective entity (based on its tags)
        clipBbox - the bounding box to clip the resulting geometry to
        Returns:
        a JTS geometry object (simple features compatible, i.e. a Point, LineString, Polygon or MultiPolygon)
      • getGeometryClipped

        public static <P extends org.locationtech.jts.geom.Geometry & org.locationtech.jts.geom.Polygonal> org.locationtech.jts.geom.Geometry getGeometryClipped​(OSMEntity entity,
                                                                                                                                                                 OSHDBTimestamp timestamp,
                                                                                                                                                                 TagInterpreter areaDecider,
                                                                                                                                                                 P clipPoly)
        Builds the geometry of an OSM entity at the given timestamp, clipped to the given polygon.
        Type Parameters:
        P - either Polygon or MultiPolygon
        Parameters:
        entity - the osm entity to generate the geometry of
        timestamp - the timestamp for which to create the entity's geometry
        areaDecider - a TagInterpreter object which decides whether to generate a linear or a polygonal geometry for the respective entity (based on its tags)
        clipPoly - a polygon to clip the resulting geometry to
        Returns:
        a JTS geometry object (simple features compatible, i.e. a Point, LineString, Polygon or MultiPolygon)
      • boundingBoxOf

        public static OSHDBBoundingBox boundingBoxOf​(org.locationtech.jts.geom.Envelope envelope)
        Converts a JTS bounding box ("envelope") to an OSHDBBoundingBox object.
        Parameters:
        envelope - the bounding box object to convert
        Returns:
        the same bounding box as an OSHDBBoundingBox object