Class ShapeProperties
java.lang.Object
org.apache.sis.internal.feature.j2d.ShapeProperties
Provides some information about a
Shape
object.- Since:
- 1.0
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Shape
The geometry.private boolean
true
if last call tocoordinates(double)
found only closed shapes. -
Constructor Summary
ConstructorsConstructorDescriptionShapeProperties
(Shape geometry) Creates a new inspector for the given geometry. -
Method Summary
Modifier and TypeMethodDescriptionprivate static double[]
addPoint
(double[] source, double[] target, int index) Appends the two first coordinates ofsource
at the end oftarget
, expanding the target array if necessary.private static float[]
addPoint
(float[] source, float[] target, int index) Same asaddPoint(double[], double[], int)
but for single-precision numbers.private List
<?> coordinates
(double flatness) Returns coordinates of the given geometry as a list of (x,y) tuples infloat[]
ordouble[]
arrays.List
<double[]> Returns coordinates of the given geometry as a list of (x,y) tuples indouble[]
arrays.private List
<double[]> coordinates(double)
implementation for the double-precision case.private List
<float[]> coordinates(double)
implementation for the single-precision case.toWKT
(double flatness) Returns a WKT representation of the geometry.
-
Field Details
-
geometry
The geometry. -
isPolygon
private boolean isPolygontrue
if last call tocoordinates(double)
found only closed shapes. In such case, the shapes are presumed polygons. Note that we do not verify if some polygons are actually holes inside other polygons.
-
-
Constructor Details
-
ShapeProperties
Creates a new inspector for the given geometry.- Parameters:
geometry
- the shape for which to inspect properties.
-
-
Method Details
-
addPoint
private static double[] addPoint(double[] source, double[] target, int index) Appends the two first coordinates ofsource
at the end oftarget
, expanding the target array if necessary.- Parameters:
source
- array of coordinates to add. Only the two first values are used.target
- where to add the two coordinates.index
- index intarget
where to add the two coordinates.- Returns:
target
, possible as a new array if it was necessary to expand it.
-
addPoint
private static float[] addPoint(float[] source, float[] target, int index) Same asaddPoint(double[], double[], int)
but for single-precision numbers. -
coordinates
Returns coordinates of the given geometry as a list of (x,y) tuples infloat[]
ordouble[]
arrays. This method guarantees that all arrays have at least 2 points (4 coordinates). It should be invoked only for small or medium shapes. For large shapes, the path iterator should be used directly without copy to arrays.- Parameters:
flatness
- maximal distance between the approximated segments and any point on the curve.- Returns:
- coordinate tuples. They are presumed polygons if
isPolygon
istrue
.
-
coordinatesAsDoubles
Returns coordinates of the given geometry as a list of (x,y) tuples indouble[]
arrays. This method guarantees that all arrays have at least 2 points (4 coordinates). It should be invoked only for small or medium shapes. For large shapes, the path iterator should be used directly without copy to arrays.- Returns:
- coordinate tuples as (x,y) tuples.
- Throws:
IllegalPathStateException
- if the given path iterator contains curves.
-
coordinatesAsDoubles
coordinates(double)
implementation for the double-precision case. TheisPolygon
field needs to be set before to invoke this method.- Parameters:
it
- path iterator of the geometry for which to get the coordinate tuples.- Returns:
- coordinate tuples as (x,y) tuples.
- Throws:
IllegalPathStateException
- if the given path iterator contains curves.
-
coordinatesAsFloats
coordinates(double)
implementation for the single-precision case. TheisPolygon
field needs to be set before to invoke this method.- Parameters:
it
- path iterator of the geometry for which to get the coordinate tuples.- Returns:
- coordinate tuples as (x,y) tuples.
- Throws:
IllegalPathStateException
- if the given path iterator contains curves.
-
toWKT
Returns a WKT representation of the geometry. Current implementation assumes that all closed shapes are polygons and that polygons have no hole (i.e. if a polygon is followed by more data, this method assumes that the additional data is a disjoint polygon).- Parameters:
flatness
- maximal distance between the approximated segments and any point on the curve.- Returns:
- Well Known Text representation of the geometry.
- See Also:
-