Class SpatialContextFactory
java.lang.Object
org.locationtech.spatial4j.context.SpatialContextFactory
- Direct Known Subclasses:
JtsSpatialContextFactory
Factory for a
SpatialContext
based on configuration data. Call
makeSpatialContext(java.util.Map, ClassLoader)
to construct one via String name-value
pairs. To construct one via code then create a factory instance, set the fields, then call
newSpatialContext()
.
The following keys are looked up in the args map:
- spatialContextFactory
- org.locationtech.spatial4j.context.SpatialContext or org.locationtech.spatial4j.context.jts.JtsSpatialContext
- geo
- true (default)| false -- see
SpatialContext.isGeo()
- shapeFactoryClass
- Java class of the
ShapeFactory
. - distCalculator
- haversine | lawOfCosines | vincentySphere | cartesian | cartesian^2
-- see
DistanceCalculator
- worldBounds
ENVELOPE(xMin, xMax, yMax, yMin)
-- seeSpatialContext.getWorldBounds()
- normWrapLongitude
- true | false (default) -- see
SpatialContext.isNormWrapLongitude()
- readers
- Comma separated list of
ShapeReader
class names - writers
- Comma separated list of
ShapeWriter
class names - binaryCodecClass
- Java class of the
BinaryCodec
-
Field Summary
FieldsModifier and TypeFieldDescriptionClass
<? extends BinaryCodec> protected ClassLoader
boolean
boolean
boolean
final List
<Class<? extends ShapeReader>> Class
<? extends ShapeFactory> final List
<Class<? extends ShapeWriter>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addReaderIfNoggitExists
(Class<? extends ShapeReader> reader) protected void
If no formats were defined in the config, this will make sure GeoJSON and WKT are registeredprotected void
init
(Map<String, String> args, ClassLoader classLoader) protected void
protected void
Getsname
from args and populates a field by the same name with the value.protected void
Check args for 'readers' and 'writers'.protected void
private <T> T
makeClassInstance
(Class<? extends T> clazz, Object... ctorArgs) static SpatialContext
makeSpatialContext
(Map<String, String> args, ClassLoader classLoader) Creates a newSpatialContext
based on configuration inargs
.Subclasses should simply construct the instance from the initialized configuration.
-
Field Details
-
args
-
classLoader
-
geo
public boolean geo -
distCalc
-
worldBounds
-
normWrapLongitude
public boolean normWrapLongitude -
shapeFactoryClass
-
binaryCodecClass
-
readers
-
writers
-
hasFormatConfig
public boolean hasFormatConfig
-
-
Constructor Details
-
SpatialContextFactory
public SpatialContextFactory()
-
-
Method Details
-
makeSpatialContext
Creates a newSpatialContext
based on configuration inargs
. See the class definition for what keys are looked up in it. The factory class is looked up via "spatialContextFactory" in args then falling back to a Java system property (with initial caps). If neither are specified thenSpatialContextFactory
is chosen.- Parameters:
args
- Non-null map of name-value pairs.classLoader
- Optional, except when a class name is provided to an argument.
-
init
-
initField
Getsname
from args and populates a field by the same name with the value. -
initCalculator
protected void initCalculator() -
initFormats
protected void initFormats()Check args for 'readers' and 'writers'. The value should be a comma separated list of class names. The legacy parameter 'wktShapeParserClass' is also supported to add a specific WKT prarser -
makeFormats
-
checkDefaultFormats
protected void checkDefaultFormats()If no formats were defined in the config, this will make sure GeoJSON and WKT are registered -
addReaderIfNoggitExists
-
initWorldBounds
protected void initWorldBounds() -
newSpatialContext
Subclasses should simply construct the instance from the initialized configuration. -
makeShapeFactory
-
makeBinaryCodec
-
makeClassInstance
-