org.apache.lucene.spatial.query
Class SpatialArgsParser
java.lang.Object
org.apache.lucene.spatial.query.SpatialArgsParser
public class SpatialArgsParser
- extends Object
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 WktShapeParser
,
but it can be overridden/customized via parseShape(String, com.spatial4j.core.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.
Method Summary |
protected SpatialArgs |
newSpatialArgs(SpatialOperation op,
com.spatial4j.core.shape.Shape shape)
|
SpatialArgs |
parse(String v,
com.spatial4j.core.context.SpatialContext ctx)
Parses a string such as "Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025". |
protected static Map<String,String> |
parseMap(String body)
Parses "a=b c=d f" (whitespace separated) into name-value pairs. |
protected com.spatial4j.core.shape.Shape |
parseShape(String str,
com.spatial4j.core.context.SpatialContext ctx)
|
protected static boolean |
readBool(String v,
boolean defaultValue)
|
protected static Double |
readDouble(String v)
|
protected void |
readNameValuePairs(SpatialArgs args,
Map<String,String> nameValPairs)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DIST_ERR_PCT
public static final String DIST_ERR_PCT
- See Also:
- Constant Field Values
DIST_ERR
public static final String DIST_ERR
- See Also:
- Constant Field Values
SpatialArgsParser
public SpatialArgsParser()
parse
public SpatialArgs parse(String v,
com.spatial4j.core.context.SpatialContext ctx)
throws ParseException,
com.spatial4j.core.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 unknown
ParseException
- If there is a problem parsing the string
com.spatial4j.core.exception.InvalidShapeException
- When the coordinates are invalid for the shape
newSpatialArgs
protected SpatialArgs newSpatialArgs(SpatialOperation op,
com.spatial4j.core.shape.Shape shape)
readNameValuePairs
protected void readNameValuePairs(SpatialArgs args,
Map<String,String> nameValPairs)
parseShape
protected com.spatial4j.core.shape.Shape parseShape(String str,
com.spatial4j.core.context.SpatialContext ctx)
throws ParseException
- Throws:
ParseException
readDouble
protected static Double readDouble(String v)
readBool
protected static boolean readBool(String v,
boolean defaultValue)
parseMap
protected static Map<String,String> parseMap(String body)
- Parses "a=b c=d f" (whitespace separated) into name-value pairs. If there
is no '=' as in 'f' above then it's short for f=f.
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.