Class ShapeBuilder<T extends org.locationtech.spatial4j.shape.Shape,G extends Geometry,E extends ShapeBuilder<T,G,E>>
java.lang.Object
org.elasticsearch.common.geo.builders.ShapeBuilder<T,G,E>
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,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 Geometry,E extends ShapeBuilder<T,G,E>> extends java.lang.Object implements NamedWriteable, ToXContentObject
Basic class for building GeoJSON shapes like Polygons, Linestrings, etc
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classShapeBuilder.EdgeThis helper class implements a linked list forCoordinate.static classShapeBuilder.OrientationNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description protected static booleanAUTO_INDEX_JTS_GEOMETRYprotected static booleanAUTO_VALIDATE_JTS_GEOMETRYprotected java.util.List<org.locationtech.jts.geom.Coordinate>coordinatesstatic doubleDATELINEstatic org.locationtech.jts.geom.GeometryFactoryFACTORYprotected static org.elasticsearch.common.geo.builders.ShapeBuilder.IntersectionOrderINTERSECTION_ORDERprotected static org.apache.logging.log4j.LoggerLOGGERprotected static booleanMULTI_POLYGON_MAY_OVERLAPIt's possible that some geometries in a MULTI* shape might overlap.static org.locationtech.spatial4j.context.jts.JtsSpatialContextSPATIAL_CONTEXTprotected booleanwrapdatelineWe're expecting some geometries might cross the dateline.static org.locationtech.jts.geom.CoordinateZERO_ZEROcoordinate at [0.0, 0.0] -
Constructor Summary
Constructors Modifier Constructor Description protectedShapeBuilder()default ctorprotectedShapeBuilder(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)ctor from list of coordinatesprotectedShapeBuilder(StreamInput in)ctor from serialized stream input -
Method Summary
Modifier and Type Method Description abstract GbuildGeometry()build lucene geometry.abstract TbuildS4J()Create a new Shape from this builder.protected java.lang.StringBuildercontentToWKT()Ecoordinate(double longitude, double latitude)Add a new coordinate to the collectionEcoordinate(org.locationtech.jts.geom.Coordinate coordinate)Add a new coordinate to the collectionprotected static java.lang.StringBuildercoordinateListToWKT(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)protected org.locationtech.jts.geom.Coordinate[]coordinates(boolean closed)Copy all coordinate to a new ArrayEcoordinates(java.util.Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)Add a collection of coordinates to the collectionEcoordinates(org.locationtech.jts.geom.Coordinate... coordinates)Add a array of coordinates to the collectionprotected XContentBuildercoordinatesToXcontent(XContentBuilder builder, boolean closed)builds an array of coordinates to aXContentBuilderprotected static booleandebugEnabled()booleanequals(java.lang.Object o)java.lang.StringgetWriteableName()Returns the name of the writeable objectinthashCode()protected static doubleintersection(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 intintersections(double dateline, ShapeBuilder.Edge[] edges)Calculate all intersections of line segments and a vertical line.protected org.locationtech.spatial4j.shape.jts.JtsGeometryjtsGeometry(org.locationtech.jts.geom.Geometry geom)abstract intnumDimensions()tracks number of dimensions for this shapeprotected static org.locationtech.jts.geom.CoordinatereadFromStream(StreamInput in)protected static org.locationtech.jts.geom.Coordinateshift(org.locationtech.jts.geom.Coordinate coordinate, double dateline)java.lang.StringtoString()java.lang.StringtoWKT()protected static XContentBuildertoXContent(XContentBuilder builder, org.locationtech.jts.geom.Coordinate coordinate)abstract GeoShapeTypetype()get the shapes typeprotected static voidwriteCoordinateTo(org.locationtech.jts.geom.Coordinate coordinate, StreamOutput out)voidwriteTo(StreamOutput out)Write this into the StreamOutput.
-
Field Details
-
LOGGER
protected static final org.apache.logging.log4j.Logger LOGGER -
coordinates
protected final java.util.List<org.locationtech.jts.geom.Coordinate> 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
protected ShapeBuilder(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)ctor from list of coordinates -
ShapeBuilder
ctor from serialized stream input- Throws:
java.io.IOException
-
-
Method Details
-
readFromStream
protected static org.locationtech.jts.geom.Coordinate readFromStream(StreamInput in) throws java.io.IOException- Throws:
java.io.IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
writeCoordinateTo
protected static void writeCoordinateTo(org.locationtech.jts.geom.Coordinate coordinate, StreamOutput out) throws java.io.IOException- Throws:
java.io.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 ofCoordinates to add- Returns:
- this
-
coordinates
public E coordinates(java.util.Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)Add a collection of coordinates to the collection- Parameters:
coordinates- array ofCoordinates 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
Shapedefined 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
protected java.lang.StringBuilder contentToWKT() -
toWKT
public java.lang.String toWKT() -
coordinateListToWKT
protected static java.lang.StringBuilder coordinateListToWKT(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates) -
debugEnabled
protected static final boolean debugEnabled() -
toXContent
protected static XContentBuilder toXContent(XContentBuilder builder, org.locationtech.jts.geom.Coordinate coordinate) throws java.io.IOException- Throws:
java.io.IOException
-
coordinatesToXcontent
protected XContentBuilder coordinatesToXcontent(XContentBuilder builder, boolean closed) throws java.io.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:
java.io.IOException
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteableReturns the name of the writeable object- Specified by:
getWriteableNamein interfaceNamedWriteable
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-