Package org.apache.lucene.spatial.query
Class SpatialArgsParser
java.lang.Object
org.apache.lucene.spatial.query.SpatialArgsParser
Parses a string that usually looks like "OPERATION(SHAPE)" into a
SpatialArgs object. The
set of operations supported are defined in SpatialOperation, such as "Intersects" being a
common one. The shape portion is defined by WKT WKTReader,
but it can be overridden/customized via parseShape(String, org.locationtech.spatial4j.context.SpatialContext). There are some optional name-value pair
parameters that follow the closing parenthesis. Example:
Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025
In the future it would be good to support something at least semi-standardized like a variant of [E]CQL.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SpatialArgsnewSpatialArgs(SpatialOperation op, org.locationtech.spatial4j.shape.Shape shape) Parses a string such as "Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025".Parses "a=b zScaling=d f" (whitespace separated) into name-value pairs.protected org.locationtech.spatial4j.shape.ShapeparseShape(String str, org.locationtech.spatial4j.context.SpatialContext ctx) protected static booleanprotected static DoublereadDouble(String v) protected voidreadNameValuePairs(SpatialArgs args, Map<String, String> nameValPairs)
-
Field Details
-
DIST_ERR_PCT
- See Also:
-
DIST_ERR
- See Also:
-
-
Constructor Details
-
SpatialArgsParser
public SpatialArgsParser()
-
-
Method Details
-
parse
public SpatialArgs parse(String v, org.locationtech.spatial4j.context.SpatialContext ctx) throws ParseException, org.locationtech.spatial4j.exception.InvalidShapeException Parses a string such as "Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025".- Parameters:
v- The string to parse. Mandatory.ctx- The spatial context. Mandatory.- Returns:
- Not null.
- Throws:
IllegalArgumentException- if the parameters don't make sense or an add-on parameter is unknownParseException- If there is a problem parsing the stringorg.locationtech.spatial4j.exception.InvalidShapeException- When the coordinates are invalid for the shape
-
newSpatialArgs
protected SpatialArgs newSpatialArgs(SpatialOperation op, org.locationtech.spatial4j.shape.Shape shape) -
readNameValuePairs
-
parseShape
protected org.locationtech.spatial4j.shape.Shape parseShape(String str, org.locationtech.spatial4j.context.SpatialContext ctx) throws ParseException - Throws:
ParseException
-
readDouble
-
readBool
-
parseMap
Parses "a=b zScaling=d f" (whitespace separated) into name-value pairs. If there is no '=' as in 'f' above then it's short for f=f.
-