Package org.apache.solr.util
Class SpatialUtils
- java.lang.Object
-
- org.apache.solr.util.SpatialUtils
-
public class SpatialUtils extends Object
Utility methods pertaining to spatial.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.locationtech.spatial4j.shape.ShapeparseGeomSolrException(String geomStr, org.locationtech.spatial4j.context.SpatialContext ctx)Parses a 'geom' parameter (might also be used to parse shapes for indexing).static org.locationtech.spatial4j.shape.PointparsePoint(String str, org.locationtech.spatial4j.context.SpatialContext ctx)Parses either "lat, lon" (spaces optional on either comma side) or "x y" style formats.static org.locationtech.spatial4j.shape.PointparsePointSolrException(String externalVal, org.locationtech.spatial4j.context.SpatialContext ctx)CallsparsePoint(String, org.locationtech.spatial4j.context.SpatialContext)and wraps the exception withSolrExceptionwith a helpful message.static org.locationtech.spatial4j.shape.RectangleparseRectangeSolrException(String externalVal, org.locationtech.spatial4j.context.SpatialContext ctx)CallsparseRectangle(String, org.locationtech.spatial4j.context.SpatialContext)and wraps the exception withSolrExceptionwith a helpful message.static org.locationtech.spatial4j.shape.RectangleparseRectangle(String str, org.locationtech.spatial4j.context.SpatialContext ctx)Parsesstrin the format of '[minPoint TO maxPoint]' whereminPointis the lower left corner and maxPoint is the upper-right corner of the bounding box.
-
-
-
Method Detail
-
parseGeomSolrException
public static org.locationtech.spatial4j.shape.Shape parseGeomSolrException(String geomStr, org.locationtech.spatial4j.context.SpatialContext ctx)
Parses a 'geom' parameter (might also be used to parse shapes for indexing).geomStrcan either be WKT or a rectangle-range syntax (seeparseRectangle(String, org.locationtech.spatial4j.context.SpatialContext).
-
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 spacesctx- 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.
-
parsePointSolrException
public static org.locationtech.spatial4j.shape.Point parsePointSolrException(String externalVal, org.locationtech.spatial4j.context.SpatialContext ctx) throws org.apache.solr.common.SolrException
CallsparsePoint(String, org.locationtech.spatial4j.context.SpatialContext)and wraps the exception withSolrExceptionwith a helpful message.- Throws:
org.apache.solr.common.SolrException
-
parseRectangle
public static org.locationtech.spatial4j.shape.Rectangle parseRectangle(String str, org.locationtech.spatial4j.context.SpatialContext ctx) throws org.locationtech.spatial4j.exception.InvalidShapeException
Parsesstrin the format of '[minPoint TO maxPoint]' whereminPointis 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 viaparsePoint(String, org.locationtech.spatial4j.context.SpatialContext).- Parameters:
str- Non-null; may *not* have leading or trailing spacesctx- 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.
-
parseRectangeSolrException
public static org.locationtech.spatial4j.shape.Rectangle parseRectangeSolrException(String externalVal, org.locationtech.spatial4j.context.SpatialContext ctx) throws org.apache.solr.common.SolrException
CallsparseRectangle(String, org.locationtech.spatial4j.context.SpatialContext)and wraps the exception withSolrExceptionwith a helpful message.- Throws:
org.apache.solr.common.SolrException
-
-