- java.lang.Object
-
- All Implemented Interfaces:
Bounded
,GeoArea
,GeoAreaShape
,GeoBounds
,GeoMembershipShape
,GeoOutsideDistance
,GeoPolygon
,GeoShape
,Membership
,PlanetObject
,SerializableObject
class GeoConvexPolygon extends GeoBasePolygon
GeoConvexPolygon objects are generic building blocks of more complex structures. The only restrictions on these objects are: (1) they must be convex; (2) they must have a maximum extent no larger than PI. Violating either one of these limits will cause the logic to fail.
-
-
Field Summary
Fields Modifier and Type Field Description protected GeoPoint[]
edgePoints
A point which is on the boundary of the polygonprotected SidedPlane[]
edges
A list of edgesprotected SidedPlane[]
endBounds
A list of edge ending bounding planesprotected java.util.List<GeoPolygon>
holes
The list of holes.protected boolean
isDone
Set to true when the polygon is completeprotected java.util.BitSet
isInternalEdges
A bitset describing, for each edge, whether it is internal or notprotected java.util.Map<SidedPlane,SidedPlane>
nextBrotherMap
Map from edge to its next non-coplanar brotherprotected GeoPoint[][]
notableEdgePoints
The set of notable points for each edgeprotected java.util.List<GeoPoint>
points
The list of polygon pointsprotected java.util.Map<SidedPlane,SidedPlane>
prevBrotherMap
Map from edge to its previous non-coplanar brotherprotected SidedPlane[]
startBounds
A list of edge starting bounding planes-
Fields inherited from class org.apache.lucene.spatial3d.geom.GeoBaseAreaShape
ALL_INSIDE, NONE_INSIDE, SOME_INSIDE
-
Fields inherited from class org.apache.lucene.spatial3d.geom.BasePlanetObject
planetModel
-
-
Constructor Summary
Constructors Constructor Description GeoConvexPolygon(PlanetModel planetModel, double startLatitude, double startLongitude)
Create a convex polygon, with a starting latitude and longitude.GeoConvexPolygon(PlanetModel planetModel, double startLatitude, double startLongitude, java.util.List<GeoPolygon> holes)
Create a convex polygon, with a starting latitude and longitude.GeoConvexPolygon(PlanetModel planetModel, java.io.InputStream inputStream)
Constructor for deserialization.GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList)
Create a convex polygon from a list of points.GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList, java.util.BitSet internalEdgeFlags, boolean returnEdgeInternal)
Create a convex polygon from a list of points, keeping track of which boundaries are internal.GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList, java.util.List<GeoPolygon> holes)
Create a convex polygon from a list of points.GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList, java.util.List<GeoPolygon> holes, java.util.BitSet internalEdgeFlags, boolean returnEdgeInternal)
Create a convex polygon from a list of points, keeping track of which boundaries are internal.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPoint(double latitude, double longitude, boolean isInternalEdge)
Add a point to the polygon.void
done(boolean isInternalReturnEdge)
Finish the polygon, by connecting the last added point with the starting point.boolean
equals(java.lang.Object o)
void
getBounds(Bounds bounds)
Compute bounds for the shape.GeoPoint[]
getEdgePoints()
Return a sample point that is on the outside edge/boundary of the shape.int
hashCode()
boolean
intersects(GeoShape shape)
Assess whether a shape intersects with any of the edges of this shape.boolean
intersects(Plane p, GeoPoint[] notablePoints, Membership... bounds)
Assess whether a plane, within the provided bounds, intersects with the shape's edges.boolean
isWithin(double x, double y, double z)
Check if a point is within this shape.protected boolean
isWithinHoles(GeoPoint point)
Check if a point is within the provided holes.protected int
legalIndex(int index)
Compute a legal point index from a possibly illegal one, that may have wrapped.protected boolean
localIsWithin(double x, double y, double z)
protected boolean
localIsWithin(Vector v)
protected double
outsideDistance(DistanceStyle distanceStyle, double x, double y, double z)
Called by acomputeOutsideDistance
method if X/Y/Z is not within this shape.java.lang.String
toString()
void
write(java.io.OutputStream outputStream)
Serialize to output stream.-
Methods inherited from class org.apache.lucene.spatial3d.geom.GeoBaseAreaShape
getRelationship, isGeoAreaShapeInsideShape, isShapeInsideGeoAreaShape
-
Methods inherited from class org.apache.lucene.spatial3d.geom.GeoBaseMembershipShape
computeOutsideDistance, computeOutsideDistance, isWithin
-
Methods inherited from class org.apache.lucene.spatial3d.geom.BasePlanetObject
getPlanetModel
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.spatial3d.geom.GeoArea
getRelationship
-
Methods inherited from interface org.apache.lucene.spatial3d.geom.GeoOutsideDistance
computeOutsideDistance, computeOutsideDistance
-
Methods inherited from interface org.apache.lucene.spatial3d.geom.Membership
isWithin
-
Methods inherited from interface org.apache.lucene.spatial3d.geom.PlanetObject
getPlanetModel
-
-
-
-
Field Detail
-
points
protected final java.util.List<GeoPoint> points
The list of polygon points
-
isInternalEdges
protected final java.util.BitSet isInternalEdges
A bitset describing, for each edge, whether it is internal or not
-
holes
protected final java.util.List<GeoPolygon> holes
The list of holes. If a point is in the hole, it is *not* in the polygon
-
edges
protected SidedPlane[] edges
A list of edges
-
startBounds
protected SidedPlane[] startBounds
A list of edge starting bounding planes
-
endBounds
protected SidedPlane[] endBounds
A list of edge ending bounding planes
-
notableEdgePoints
protected GeoPoint[][] notableEdgePoints
The set of notable points for each edge
-
edgePoints
protected GeoPoint[] edgePoints
A point which is on the boundary of the polygon
-
isDone
protected boolean isDone
Set to true when the polygon is complete
-
prevBrotherMap
protected java.util.Map<SidedPlane,SidedPlane> prevBrotherMap
Map from edge to its previous non-coplanar brother
-
nextBrotherMap
protected java.util.Map<SidedPlane,SidedPlane> nextBrotherMap
Map from edge to its next non-coplanar brother
-
-
Constructor Detail
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList)
Create a convex polygon from a list of points. The first point must be on the external edge.- Parameters:
planetModel
- is the planet model.pointList
- is the list of points to create the polygon from.
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList, java.util.List<GeoPolygon> holes)
Create a convex polygon from a list of points. The first point must be on the external edge.- Parameters:
planetModel
- is the planet model.pointList
- is the list of points to create the polygon from.holes
- is the list of GeoPolygon objects that describe holes in the complex polygon. Null == no holes.
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList, java.util.BitSet internalEdgeFlags, boolean returnEdgeInternal)
Create a convex polygon from a list of points, keeping track of which boundaries are internal. This is used when creating a polygon as a building block for another shape.- Parameters:
planetModel
- is the planet model.pointList
- is the set of points to create the polygon from.internalEdgeFlags
- is a bitset describing whether each edge is internal or not.returnEdgeInternal
- is true when the final return edge is an internal one.
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, java.util.List<GeoPoint> pointList, java.util.List<GeoPolygon> holes, java.util.BitSet internalEdgeFlags, boolean returnEdgeInternal)
Create a convex polygon from a list of points, keeping track of which boundaries are internal. This is used when creating a polygon as a building block for another shape.- Parameters:
planetModel
- is the planet model.pointList
- is the set of points to create the polygon from.holes
- is the list of GeoPolygon objects that describe holes in the complex polygon. Null == no holes.internalEdgeFlags
- is a bitset describing whether each edge is internal or not.returnEdgeInternal
- is true when the final return edge is an internal one.
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, double startLatitude, double startLongitude)
Create a convex polygon, with a starting latitude and longitude. Accepts only values in the following ranges: lat:-PI/2 -> PI/2
, lon:-PI -> PI
- Parameters:
planetModel
- is the planet model.startLatitude
- is the latitude of the first point.startLongitude
- is the longitude of the first point.
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, double startLatitude, double startLongitude, java.util.List<GeoPolygon> holes)
Create a convex polygon, with a starting latitude and longitude. Accepts only values in the following ranges: lat:-PI/2 -> PI/2
, lon:-PI -> PI
- Parameters:
planetModel
- is the planet model.startLatitude
- is the latitude of the first point.startLongitude
- is the longitude of the first point.holes
- is the list of GeoPolygon objects that describe holes in the complex polygon. Null == no holes.
-
GeoConvexPolygon
public GeoConvexPolygon(PlanetModel planetModel, java.io.InputStream inputStream) throws java.io.IOException
Constructor for deserialization.- Parameters:
planetModel
- is the planet model.inputStream
- is the input stream.- Throws:
java.io.IOException
-
-
Method Detail
-
addPoint
public void addPoint(double latitude, double longitude, boolean isInternalEdge)
Add a point to the polygon. Accepts only values in the following ranges: lat:-PI/2 -> PI/2
, lon:-PI -> PI
- Parameters:
latitude
- is the latitude of the next point.longitude
- is the longitude of the next point.isInternalEdge
- is true if the edge just added with this point should be considered "internal", and not intersected as part of the intersects() operation.
-
done
public void done(boolean isInternalReturnEdge)
Finish the polygon, by connecting the last added point with the starting point.- Parameters:
isInternalReturnEdge
- is true if the return edge (back to start) is an internal one.
-
isWithinHoles
protected boolean isWithinHoles(GeoPoint point)
Check if a point is within the provided holes.- Parameters:
point
- point to check.- Returns:
- true if the point is within any of the holes.
-
legalIndex
protected int legalIndex(int index)
Compute a legal point index from a possibly illegal one, that may have wrapped.- Parameters:
index
- is the index.- Returns:
- the normalized index.
-
write
public void write(java.io.OutputStream outputStream) throws java.io.IOException
Description copied from interface:SerializableObject
Serialize to output stream.- Specified by:
write
in interfaceSerializableObject
- Overrides:
write
in classBasePlanetObject
- Parameters:
outputStream
- is the output stream to write to.- Throws:
java.io.IOException
-
isWithin
public boolean isWithin(double x, double y, double z)
Description copied from interface:Membership
Check if a point is within this shape.- Parameters:
x
- is x coordinate of point to check.y
- is y coordinate of point to check.z
- is z coordinate of point to check.- Returns:
- true if the point is within this shape
-
localIsWithin
protected boolean localIsWithin(Vector v)
-
localIsWithin
protected boolean localIsWithin(double x, double y, double z)
-
getEdgePoints
public GeoPoint[] getEdgePoints()
Description copied from interface:GeoShape
Return a sample point that is on the outside edge/boundary of the shape.- Returns:
- samples of all edge points from distinct edge sections. Typically one point is returned, but zero or two are also possible.
-
intersects
public boolean intersects(Plane p, GeoPoint[] notablePoints, Membership... bounds)
Description copied from interface:GeoShape
Assess whether a plane, within the provided bounds, intersects with the shape's edges. Any overlap, even a single point, is considered to be an intersection. Note well that this method is allowed to return "true" if there are internal edges of a composite shape which intersect the plane. Doing this can cause getRelationship() for most GeoBBox shapes to return OVERLAPS rather than the more correct CONTAINS, but that cannot be helped for some complex shapes that are built out of overlapping parts.- Parameters:
p
- is the plane to assess for intersection with the shape's edges or bounding curves.notablePoints
- represents the intersections of the plane with the supplied bounds. These are used to disambiguate when two planes are identical and it needs to be determined whether any points exist that fulfill all the bounds.bounds
- are a set of bounds that define an area that an intersection must be within in order to qualify (provided by a GeoArea).- Returns:
- true if there's such an intersection, false if not.
-
intersects
public boolean intersects(GeoShape shape)
Description copied from interface:GeoAreaShape
Assess whether a shape intersects with any of the edges of this shape. Note well that this method must return false if the shape contains or is disjoint with the given shape. It is permissible to return true if the shape is within the specified shape, if it is difficult to compute intersection with edges.- Parameters:
shape
- is the shape to assess for intersection with this shape's edges.- Returns:
- true if there's such an intersection, false if not.
-
getBounds
public void getBounds(Bounds bounds)
Description copied from interface:Bounded
Compute bounds for the shape.- Specified by:
getBounds
in interfaceBounded
- Overrides:
getBounds
in classGeoBaseBounds
- Parameters:
bounds
- is the input bounds object. The input object will be modified.
-
outsideDistance
protected double outsideDistance(DistanceStyle distanceStyle, double x, double y, double z)
Description copied from class:GeoBaseMembershipShape
Called by acomputeOutsideDistance
method if X/Y/Z is not within this shape.- Specified by:
outsideDistance
in classGeoBaseMembershipShape
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classBasePlanetObject
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBasePlanetObject
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-