Class ShapeBuilder<T extends org.locationtech.spatial4j.shape.Shape,G extends org.elasticsearch.geometry.Geometry,E extends ShapeBuilder<T,G,E>>
java.lang.Object
org.elasticsearch.common.geo.builders.ShapeBuilder<T,G,E>
- All Implemented Interfaces:
NamedWriteable
,Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
- Direct Known Subclasses:
CircleBuilder
,EnvelopeBuilder
,GeometryCollectionBuilder
,LineStringBuilder
,MultiLineStringBuilder
,MultiPointBuilder
,MultiPolygonBuilder
,PointBuilder
,PolygonBuilder
public abstract class ShapeBuilder<T extends org.locationtech.spatial4j.shape.Shape,G extends org.elasticsearch.geometry.Geometry,E extends ShapeBuilder<T,G,E>>
extends Object
implements NamedWriteable, org.elasticsearch.common.xcontent.ToXContentObject
Basic class for building GeoJSON shapes like Polygons, Linestrings, etc
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
This helper class implements a linked list forCoordinate
.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionprotected static boolean
protected static boolean
protected List<org.locationtech.jts.geom.Coordinate>
static double
static org.locationtech.jts.geom.GeometryFactory
protected static org.elasticsearch.common.geo.builders.ShapeBuilder.IntersectionOrder
protected static org.apache.logging.log4j.Logger
protected static boolean
It's possible that some geometries in a MULTI* shape might overlap.static org.locationtech.spatial4j.context.jts.JtsSpatialContext
protected boolean
We're expecting some geometries might cross the dateline.static org.locationtech.jts.geom.Coordinate
coordinate at [0.0, 0.0]Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionprotected
default ctorprotected
ShapeBuilder(List<org.locationtech.jts.geom.Coordinate> coordinates)
ctor from list of coordinatesprotected
ctor from serialized stream input -
Method Summary
Modifier and TypeMethodDescriptionabstract G
build lucene geometry.abstract T
buildS4J()
Create a new Shape from this builder.protected StringBuilder
coordinate(double longitude, double latitude)
Add a new coordinate to the collectioncoordinate(org.locationtech.jts.geom.Coordinate coordinate)
Add a new coordinate to the collectionprotected static StringBuilder
coordinateListToWKT(List<org.locationtech.jts.geom.Coordinate> coordinates)
protected org.locationtech.jts.geom.Coordinate[]
coordinates(boolean closed)
Copy all coordinate to a new Arraycoordinates(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
Add a collection of coordinates to the collectioncoordinates(org.locationtech.jts.geom.Coordinate... coordinates)
Add a array of coordinates to the collectionprotected org.elasticsearch.common.xcontent.XContentBuilder
coordinatesToXcontent(org.elasticsearch.common.xcontent.XContentBuilder builder, boolean closed)
builds an array of coordinates to aXContentBuilder
protected static boolean
boolean
Returns the name of the writeable objectint
hashCode()
protected static double
intersection(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, double dateline)
Calculate the intersection of a line segment and a vertical dateline.protected static int
intersections(double dateline, ShapeBuilder.Edge[] edges)
Calculate all intersections of line segments and a vertical line.protected org.locationtech.spatial4j.shape.jts.JtsGeometry
jtsGeometry(org.locationtech.jts.geom.Geometry geom)
abstract int
tracks number of dimensions for this shapeprotected static org.locationtech.jts.geom.Coordinate
protected static org.locationtech.jts.geom.Coordinate
shift(org.locationtech.jts.geom.Coordinate coordinate, double dateline)
toString()
toWKT()
protected static org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.locationtech.jts.geom.Coordinate coordinate)
abstract GeoShapeType
type()
get the shapes typeprotected static void
writeCoordinateTo(org.locationtech.jts.geom.Coordinate coordinate, StreamOutput out)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
LOGGER
protected static final org.apache.logging.log4j.Logger LOGGER -
coordinates
-
DATELINE
public static final double DATELINE- See Also:
- Constant Field Values
-
ZERO_ZERO
public static final org.locationtech.jts.geom.Coordinate ZERO_ZEROcoordinate at [0.0, 0.0] -
SPATIAL_CONTEXT
public static final org.locationtech.spatial4j.context.jts.JtsSpatialContext SPATIAL_CONTEXT -
FACTORY
public static final org.locationtech.jts.geom.GeometryFactory FACTORY -
wrapdateline
protected final boolean wrapdatelineWe're expecting some geometries might cross the dateline. -
MULTI_POLYGON_MAY_OVERLAP
protected static final boolean MULTI_POLYGON_MAY_OVERLAPIt's possible that some geometries in a MULTI* shape might overlap. With the possible exception of GeometryCollection, this normally isn't allowed.- See Also:
- Constant Field Values
-
AUTO_VALIDATE_JTS_GEOMETRY
protected static final boolean AUTO_VALIDATE_JTS_GEOMETRY- See Also:
JtsGeometry.validate()
, Constant Field Values
-
AUTO_INDEX_JTS_GEOMETRY
protected static final boolean AUTO_INDEX_JTS_GEOMETRY- See Also:
JtsGeometry.index()
, Constant Field Values
-
INTERSECTION_ORDER
protected static final org.elasticsearch.common.geo.builders.ShapeBuilder.IntersectionOrder INTERSECTION_ORDER
-
-
Constructor Details
-
ShapeBuilder
protected ShapeBuilder()default ctor -
ShapeBuilder
ctor from list of coordinates -
ShapeBuilder
ctor from serialized stream input- Throws:
IOException
-
-
Method Details
-
readFromStream
protected static org.locationtech.jts.geom.Coordinate readFromStream(StreamInput in) throws IOException- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
writeCoordinateTo
protected static void writeCoordinateTo(org.locationtech.jts.geom.Coordinate coordinate, StreamOutput out) throws IOException- Throws:
IOException
-
coordinate
Add a new coordinate to the collection- Parameters:
longitude
- longitude of the coordinatelatitude
- latitude of the coordinate- Returns:
- this
-
coordinate
Add a new coordinate to the collection- Parameters:
coordinate
- coordinate of the point- Returns:
- this
-
coordinates
Add a array of coordinates to the collection- Parameters:
coordinates
- array ofCoordinate
s to add- Returns:
- this
-
coordinates
Add a collection of coordinates to the collection- Parameters:
coordinates
- array ofCoordinate
s to add- Returns:
- this
-
coordinates
protected org.locationtech.jts.geom.Coordinate[] coordinates(boolean closed)Copy all coordinate to a new Array- Parameters:
closed
- if set to true the first point of the array is repeated as last element- Returns:
- Array of coordinates
-
jtsGeometry
protected org.locationtech.spatial4j.shape.jts.JtsGeometry jtsGeometry(org.locationtech.jts.geom.Geometry geom) -
buildS4J
Create a new Shape from this builder. Since calling this method could change the defined shape. (by inserting new coordinates or change the position of points) the builder looses its validity. So this method should only be called once on a builder- Returns:
- new
Shape
defined by the builder
-
buildGeometry
build lucene geometry.- Returns:
- GeoPoint, double[][], Line, Line[], Polygon, Polygon[], Rectangle, Object[]
-
shift
protected static org.locationtech.jts.geom.Coordinate shift(org.locationtech.jts.geom.Coordinate coordinate, double dateline) -
type
get the shapes type- Returns:
- type of the shape
-
numDimensions
public abstract int numDimensions()tracks number of dimensions for this shape -
intersection
protected static final double intersection(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, double dateline)Calculate the intersection of a line segment and a vertical dateline.- Parameters:
p1
- start-point of the line segmentp2
- end-point of the line segmentdateline
- x-coordinate of the vertical dateline- Returns:
- position of the intersection in the open range (0..1] if the line
segment intersects with the line segment. Otherwise this method
returns
Double.NaN
-
intersections
Calculate all intersections of line segments and a vertical line. The Array of edges will be ordered asc by the y-coordinate of the intersections of edges.- Parameters:
dateline
- x-coordinate of the datelineedges
- set of edges that may intersect with the dateline- Returns:
- number of intersecting edges
-
contentToWKT
-
toWKT
-
coordinateListToWKT
protected static StringBuilder coordinateListToWKT(List<org.locationtech.jts.geom.Coordinate> coordinates) -
debugEnabled
protected static final boolean debugEnabled() -
toXContent
protected static org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.locationtech.jts.geom.Coordinate coordinate) throws IOException- Throws:
IOException
-
coordinatesToXcontent
protected org.elasticsearch.common.xcontent.XContentBuilder coordinatesToXcontent(org.elasticsearch.common.xcontent.XContentBuilder builder, boolean closed) throws IOExceptionbuilds an array of coordinates to aXContentBuilder
- Parameters:
builder
- builder to useclosed
- repeat the first point at the end of the array if it's not already defines as last element of the array- Returns:
- the builder
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
getWriteableName
Description copied from interface:NamedWriteable
Returns the name of the writeable object- Specified by:
getWriteableName
in interfaceNamedWriteable
-
toString
-