Package com.kheops.jmap.spatial
Class LineString
java.lang.Object
com.kheops.jmap.spatial.DefaultGeometry
com.kheops.jmap.spatial.LineString
- All Implemented Interfaces:
Curve,Geometry,LineTypeGeometry,Serializable,Cloneable
- Direct Known Subclasses:
Line,LinearRing
This class represents a line made of several points.
2 Points are allowed to be equal, but a lineString can't be made of a single Point (because of topology reasons)
2 Points are allowed to be equal, but a lineString can't be made of a single Point (because of topology reasons)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RectangleThe Bounding boxprotected Point[]the Points defining the LineStringFields inherited from interface com.kheops.jmap.spatial.Geometry
GEOMETRY_ANNOTATION, GEOMETRY_COMPLEX, GEOMETRY_ELLIPSE, GEOMETRY_LINE, GEOMETRY_LINEAR_RING, GEOMETRY_LINESTRING, GEOMETRY_MULTI_ANNOTATION, GEOMETRY_MULTI_LINESTRING, GEOMETRY_MULTI_POINT, GEOMETRY_MULTI_POLYGON, GEOMETRY_POINT, GEOMETRY_POLYGON, GEOMETRY_RECTANGLE -
Constructor Summary
ConstructorsConstructorDescriptionLineString(double[] tab) Constructor easier to use for testing warning : coords.length must be even number, because points are entered as x,yLineString(Point[] coords) Constructs a LineString going to each points -
Method Summary
Modifier and TypeMethodDescriptiondoublearea()Returns the geometry area.boundary()Returns the boundary, ie the startPoint() and endPoint()clone()Clones this geometry.voidcreates the bounding box
called in the constructor, not needed from outsideendPoint()The last point of the curvebooleanReturns the minimum bounding rectangle of this geometry.This method returns a point that is typically centered on the geometry.Point[]shortReturns the geometry class id.intReturns the geometry type for this geometry.inthashCode()booleanisClosed()Tests if the curve is closed (endPoint equals startPoint)booleanisRing()Tests if the curve is closed and simple (doesn't intersect itself)doublelength()The length of the curveintReturns the number of Point in this LineStringpointN(int N) Returns the Nth Point of this LineStringpointOnLine(double interpolation) This method finds the point being at a certain percentage of the path between the starting point and the final point.Point[]Describe this LineString with his Points Respects the order of the PointsvoidintsizeOf()Returns an approximation in bytes of the memory used by this geometry.booleanspatiallyEquals(Geometry o, PrecisionModel precisionModel) Tests if this geometry is equal to the argument, on a topological point of view.booleanspatiallyEquals(LineString lineString, PrecisionModel precisionModel) The first point of the curvetoString()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.voidtranslate(double dx, double dy) Translate this geometry with the specified values.Methods inherited from class com.kheops.jmap.spatial.DefaultGeometry
asText, spatiallyEqualsMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.kheops.jmap.spatial.Geometry
asText, spatiallyEquals
-
Field Details
-
bounds
The Bounding box -
coords
the Points defining the LineString
-
-
Constructor Details
-
LineString
public LineString() -
LineString
Constructs a LineString going to each points- Parameters:
coords-
-
LineString
public LineString(double[] tab) Constructor easier to use for testing warning : coords.length must be even number, because points are entered as x,y- Parameters:
tab-
-
-
Method Details
-
boundary
Returns the boundary, ie the startPoint() and endPoint() -
createBounds
public void createBounds()creates the bounding box
called in the constructor, not needed from outside- Specified by:
createBoundsin interfaceGeometry
-
getCoords
-
setCoords
-
numPoints
public int numPoints()Returns the number of Point in this LineString- Returns:
-
pointN
Returns the Nth Point of this LineString- Parameters:
N-- Returns:
- the Nth Point of this LineString
-
getBounds
Description copied from interface:GeometryReturns the minimum bounding rectangle of this geometry. -
clone
Clones this geometry. -
serialize
Describe this LineString with his Points Respects the order of the Points -
length
public double length()The length of the curve -
area
public double area()Description copied from interface:GeometryReturns the geometry area. If the geometry is not a surface, then 0 shall be returned. -
startPoint
The first point of the curve- Specified by:
startPointin interfaceCurve- Returns:
-
endPoint
The last point of the curve -
isClosed
public boolean isClosed()Tests if the curve is closed (endPoint equals startPoint)- Specified by:
isClosedin interfaceCurve- Specified by:
isClosedin interfaceLineTypeGeometry- Returns:
-
isRing
public boolean isRing()Tests if the curve is closed and simple (doesn't intersect itself) -
hashCode
public int hashCode() -
equals
-
spatiallyEquals
Tests if this geometry is equal to the argument, on a topological point of view.- Specified by:
spatiallyEqualsin interfaceGeometry- Parameters:
o- the geometry to be tested.precisionModel- the precision model to use while comparing geometries.- Returns:
- whether both geometries are spatially equals.
-
spatiallyEquals
-
toString
Description copied from interface:GeometryReturns information about the current geometry. -
lineIterator
- Specified by:
lineIteratorin interfaceLineTypeGeometry
-
translate
public void translate(double dx, double dy) Translate this geometry with the specified values. -
getGeometryId
public short getGeometryId()Returns the geometry class id. This method is useful for geometry serialization.- Specified by:
getGeometryIdin interfaceGeometry- Returns:
- the geometry id.
-
getGeometryType
public int getGeometryType()Returns the geometry type for this geometry.- Specified by:
getGeometryTypein interfaceGeometry- 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. -
pointOnLine
This method finds the point being at a certain percentage of the path between the starting point and the final point.- Parameters:
interpolation- the interpolation expressed as a percentage (between 0 and 1)- Returns:
- the reulsting 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.- Specified by:
getCenteredPointin interfaceGeometry- Returns:
- a point likely at the center of the geometry
-
sizeOf
public int sizeOf()Returns an approximation in bytes of the memory used by this geometry.
-