Package com.kheops.jmap.spatial
Interface Geometry
- All Superinterfaces:
Cloneable
,Serializable
- All Known Subinterfaces:
AnnotationTypeGeometry
,Curve
,EllipseTypeGeometry
,LineTypeGeometry
,PointTypeGeometry
,PolygonTypeGeometry
,Surface
- All Known Implementing Classes:
Annotation
,Complex
,DefaultGeometry
,Ellipse
,GeometryCollection
,Line
,LinearRing
,LineString
,MultiAnnotation
,MultiCurve
,MultiLineString
,MultiPoint
,MultiPolygon
,MultiSurface
,OrientedRectangle
,OrientedRectangle.Double
,OrientedRectangle.Float
,Point
,Point.Double
,Point.Float
,PointM
,Polygon
,Rectangle
,Rectangle.Double
,Rectangle.Float
This interface is implemented by all geometry classes in JMap.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final short
Constant for geometry id of typeAnnotation
.static final short
Constant for geometry id of typeComplex
.static final short
Constant for geometry id of typeEllipse
.static final short
Constant for geometry id of typeLine
.static final short
Constant for geometry id of typeLinearRing
.static final short
Constant for geometry id of typeLineString
.static final short
Constant for geometry id of typeMultiAnnotation
.static final short
Constant for geometry id of typeMultiLineString
.static final short
Constant for geometry id of typeMultiPoint
.static final short
Constant for geometry id of typeMultiPolygon
.static final short
Constant for geometry id of typePoint
.static final short
Constant for geometry id of typePolygon
.static final short
Constant for geometry id of typeRectangle
. -
Method Summary
Modifier and TypeMethodDescriptiondefault double
area()
Returns the geometry area.asText()
boundary()
Returns the boundary of this geometry as a line string.clone()
Clones this geometry.void
Updates the geometry bounds from the current geometry.Returns the minimum bounding rectangle of this geometry.This method returns a point that is typically centered on the geometry.short
Returns the geometry class id.int
Returns the geometry type for this geometry.default double
length()
Returns the geometry length.Point[]
Returns this geometry as an array of Point.int
sizeOf()
Returns an approximation in bytes of the memory used by this geometry.boolean
spatiallyEquals
(Geometry geometry) Tests if this geometry is equal to the argument, on a topological point of view
it means that they represent the same geometry, even if it is described differently (direction of the rings, order of the rings)
it does not remove additional points on lineString (3 points aligned), one must use smoother.removeExtraPoints() before in order to achieve that.boolean
spatiallyEquals
(Geometry geometry, PrecisionModel precisionModel) Tests if this geometry is equal to the argument, on a topological point of view.toString()
Returns information about the current geometry.Creates a clone of the current geometry and returns the new instance transformed with the specified geometry transformation.
The returned geometry can be of any geometry types after the transformation.void
translate
(double dx, double dy) Translate this geometry with the specified values.
-
Field Details
-
GEOMETRY_POINT
static final short GEOMETRY_POINTConstant for geometry id of typePoint
.- See Also:
-
GEOMETRY_MULTI_POINT
static final short GEOMETRY_MULTI_POINTConstant for geometry id of typeMultiPoint
.- See Also:
-
GEOMETRY_LINESTRING
static final short GEOMETRY_LINESTRINGConstant for geometry id of typeLineString
.- See Also:
-
GEOMETRY_MULTI_LINESTRING
static final short GEOMETRY_MULTI_LINESTRINGConstant for geometry id of typeMultiLineString
.- See Also:
-
GEOMETRY_LINE
static final short GEOMETRY_LINEConstant for geometry id of typeLine
.- See Also:
-
GEOMETRY_POLYGON
static final short GEOMETRY_POLYGONConstant for geometry id of typePolygon
.- See Also:
-
GEOMETRY_MULTI_POLYGON
static final short GEOMETRY_MULTI_POLYGONConstant for geometry id of typeMultiPolygon
.- See Also:
-
GEOMETRY_LINEAR_RING
static final short GEOMETRY_LINEAR_RINGConstant for geometry id of typeLinearRing
.- See Also:
-
GEOMETRY_COMPLEX
static final short GEOMETRY_COMPLEXConstant for geometry id of typeComplex
.- See Also:
-
GEOMETRY_RECTANGLE
static final short GEOMETRY_RECTANGLEConstant for geometry id of typeRectangle
.- See Also:
-
GEOMETRY_ANNOTATION
static final short GEOMETRY_ANNOTATIONConstant for geometry id of typeAnnotation
.- See Also:
-
GEOMETRY_ELLIPSE
static final short GEOMETRY_ELLIPSEConstant for geometry id of typeEllipse
.- See Also:
-
GEOMETRY_MULTI_ANNOTATION
static final short GEOMETRY_MULTI_ANNOTATIONConstant for geometry id of typeMultiAnnotation
.- See Also:
-
-
Method Details
-
getBounds
Rectangle getBounds()Returns the minimum bounding rectangle of this geometry.- Returns:
- the bounding box of this geometry.
-
serialize
Point[] serialize()Returns this geometry as an array of Point.- Returns:
- this geometry as an array of Point.
-
clone
Geometry clone()Clones this geometry.- Returns:
- a deep copy of the current geometry.
-
spatiallyEquals
Tests if this geometry is equal to the argument, on a topological point of view
it means that they represent the same geometry, even if it is described differently (direction of the rings, order of the rings)
it does not remove additional points on lineString (3 points aligned), one must use smoother.removeExtraPoints() before in order to achieve that.- Parameters:
geometry
- the geometry to be tested.- Returns:
- whether both geometries are spatial equals.
-
spatiallyEquals
Tests if this geometry is equal to the argument, on a topological point of view.- Parameters:
geometry
- the geometry to be tested.precisionModel
- the precision model to use while comparing geometries.- Returns:
- whether both geometries are spatially equals.
-
boundary
Geometry boundary()Returns the boundary of this geometry as a line string.- Returns:
- a line string which defines the boundary of the current geometry.
-
toString
String toString()Returns information about the current geometry. -
translate
void translate(double dx, double dy) Translate this geometry with the specified values.- Parameters:
dx
- translation on the X-axis.dy
- translation on the Y-axis.
-
sizeOf
int sizeOf()Returns an approximation in bytes of the memory used by this geometry.- Returns:
- the memory used by this geometry.
-
getGeometryId
short getGeometryId()Returns the geometry class id. This method is useful for geometry serialization.- Returns:
- the geometry id.
-
getGeometryType
int getGeometryType()Returns the geometry type for this geometry.- Returns:
- the geometry type.
- See Also:
-
transform
Creates a clone of the current geometry and returns the new instance transformed with the specified geometry transformation.
The returned geometry can be of any geometry types after the transformation.- Parameters:
tr
- the transformation to apply.- Returns:
- the newly created and transformed geometry instance.
-
createBounds
void createBounds()Updates the geometry bounds from the current geometry. -
getCenteredPoint
Point getCenteredPoint()This method returns a point that is typically centered on the geometry. If the geometry is a point, the point is returned. If it is a line, a point on the curve interpolated at 50% is returned. If the geometry is a surface, the centroid is returned if it is inside the polygon, if not, a point inside the polygon (but likely not exactly in the center) will be returned. If the geometry is a collection, the method is called on the first part of the collection.- Returns:
- a point likely at the center of the geometry
-
asText
String asText() -
area
default double area()Returns the geometry area. If the geometry is not a surface, then 0 shall be returned.- Returns:
- the geometry area.
-
length
default double length()Returns the geometry length. If the geometry is a surface, then the geometry perimeter shall be returned.- Returns:
- the geometry length.
-