Class ShapeProperties

java.lang.Object
org.apache.sis.internal.feature.j2d.ShapeProperties

final class ShapeProperties extends Object
Provides some information about a Shape object.
Since:
1.0
Version:
1.1
  • Field Details

    • geometry

      private final Shape geometry
      The geometry.
    • isPolygon

      private boolean isPolygon
      true if last call to coordinates(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

      public ShapeProperties(Shape geometry)
      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 of source at the end of target, 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 in target 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 as addPoint(double[], double[], int) but for single-precision numbers.
    • coordinates

      private List<?> coordinates(double flatness)
      Returns coordinates of the given geometry as a list of (x,y) tuples in float[] or double[] 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 is true.
    • coordinatesAsDoubles

      public List<double[]> coordinatesAsDoubles()
      Returns coordinates of the given geometry as a list of (x,y) tuples in double[] 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

      private List<double[]> coordinatesAsDoubles(PathIterator it)
      coordinates(double) implementation for the double-precision case. The isPolygon 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

      private List<float[]> coordinatesAsFloats(PathIterator it)
      coordinates(double) implementation for the single-precision case. The isPolygon 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

      public String toWKT(double flatness)
      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: