Class SpatialUtils


  • public class SpatialUtils
    extends Object
    Utility methods pertaining to spatial.
    • Method Detail

      • parsePoint

        public static org.locationtech.spatial4j.shape.Point parsePoint​(String str,
                                                                        org.locationtech.spatial4j.context.SpatialContext ctx)
                                                                 throws org.locationtech.spatial4j.exception.InvalidShapeException
        Parses either "lat, lon" (spaces optional on either comma side) or "x y" style formats. Spaces can be basically anywhere. And not any whitespace, just the space char.
        Parameters:
        str - Non-null; may have leading or trailing spaces
        ctx - Non-null
        Returns:
        Non-null
        Throws:
        org.locationtech.spatial4j.exception.InvalidShapeException - If for any reason there was a problem parsing the string or creating the point.
      • parseRectangle

        public static org.locationtech.spatial4j.shape.Rectangle parseRectangle​(String str,
                                                                                org.locationtech.spatial4j.context.SpatialContext ctx)
                                                                         throws org.locationtech.spatial4j.exception.InvalidShapeException
        Parses str in the format of '[minPoint TO maxPoint]' where minPoint is the lower left corner and maxPoint is the upper-right corner of the bounding box. Both corners may optionally be wrapped with a quote and then it's parsed via parsePoint(String, org.locationtech.spatial4j.context.SpatialContext).
        Parameters:
        str - Non-null; may *not* have leading or trailing spaces
        ctx - Non-null
        Returns:
        the Rectangle
        Throws:
        org.locationtech.spatial4j.exception.InvalidShapeException - If for any reason there was a problem parsing the string or creating the rectangle.