public class SpatialArgsParser
extends java.lang.Object
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, 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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DIST_ERR |
static java.lang.String |
DIST_ERR_PCT |
Constructor and Description |
---|
SpatialArgsParser() |
Modifier and Type | Method and Description |
---|---|
protected SpatialArgs |
newSpatialArgs(SpatialOperation op,
org.locationtech.spatial4j.shape.Shape shape) |
SpatialArgs |
parse(java.lang.String v,
org.locationtech.spatial4j.context.SpatialContext ctx)
Parses a string such as "Intersects(ENVELOPE(-10,-8,22,20)) distErrPct=0.025".
|
protected static java.util.Map<java.lang.String,java.lang.String> |
parseMap(java.lang.String body)
Parses "a=b c=d f" (whitespace separated) into name-value pairs.
|
protected org.locationtech.spatial4j.shape.Shape |
parseShape(java.lang.String str,
org.locationtech.spatial4j.context.SpatialContext ctx) |
protected static boolean |
readBool(java.lang.String v,
boolean defaultValue) |
protected static java.lang.Double |
readDouble(java.lang.String v) |
protected void |
readNameValuePairs(SpatialArgs args,
java.util.Map<java.lang.String,java.lang.String> nameValPairs) |
public static final java.lang.String DIST_ERR_PCT
public static final java.lang.String DIST_ERR
public SpatialArgs parse(java.lang.String v, org.locationtech.spatial4j.context.SpatialContext ctx) throws java.text.ParseException, org.locationtech.spatial4j.exception.InvalidShapeException
v
- The string to parse. Mandatory.ctx
- The spatial context. Mandatory.java.lang.IllegalArgumentException
- if the parameters don't make sense or an add-on parameter is unknownjava.text.ParseException
- If there is a problem parsing the stringorg.locationtech.spatial4j.exception.InvalidShapeException
- When the coordinates are invalid for the shapeprotected SpatialArgs newSpatialArgs(SpatialOperation op, org.locationtech.spatial4j.shape.Shape shape)
protected void readNameValuePairs(SpatialArgs args, java.util.Map<java.lang.String,java.lang.String> nameValPairs)
protected org.locationtech.spatial4j.shape.Shape parseShape(java.lang.String str, org.locationtech.spatial4j.context.SpatialContext ctx) throws java.text.ParseException
java.text.ParseException
protected static java.lang.Double readDouble(java.lang.String v)
protected static boolean readBool(java.lang.String v, boolean defaultValue)
protected static java.util.Map<java.lang.String,java.lang.String> parseMap(java.lang.String body)
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.