Class FeatureMate


  • public class FeatureMate
    extends Object
    A wrapper for features that helps out with lots of stuff.
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Constructor Summary

      Constructors 
      Constructor Description
      FeatureMate​(org.opengis.feature.simple.SimpleFeature feature)
      Constructor.
    • Constructor Detail

      • FeatureMate

        public FeatureMate​(org.opengis.feature.simple.SimpleFeature feature)
        Constructor.
        Parameters:
        feature - the feature to wrap.
    • Method Detail

      • getFeature

        public org.opengis.feature.simple.SimpleFeature getFeature()
      • useBuffer

        public void useBuffer​(double buffer)
        Apply a buffer to the geometry and use that as new Geometry.
        Parameters:
        buffer - the buffer to apply.
      • getGeometry

        public org.locationtech.jts.geom.Geometry getGeometry()
        Getter for the geometry.
        Returns:
        the geometry of the feature.
      • getEnvelope

        public org.locationtech.jts.geom.Envelope getEnvelope()
        Getter for the Envelope.
        Returns:
        the envelope.
      • getAttributesNames

        public List<String> getAttributesNames()
        Getter for the list of attribute names.
        Returns:
        the list of attribute names.
      • getAttribute

        public <T> T getAttribute​(String attrName,
                                  Class<T> adaptee)
        Gets an attribute from the feature table, adapting to the supplied class.
        Parameters:
        attrName - the attribute name to pick.
        adaptee - the class to adapt to.
        Returns:
        the adapted value if possible.
      • intersects

        public boolean intersects​(org.locationtech.jts.geom.Geometry geometry,
                                  boolean usePrepared)
        Check for intersection.
        Parameters:
        geometry - the geometry to check against.
        usePrepared - use prepared geometry.
        Returns:
        true if the geometries intersect.
      • covers

        public boolean covers​(org.locationtech.jts.geom.Geometry geometry,
                              boolean usePrepared)
        Check for cover.
        Parameters:
        geometry - the geometry to check against.
        usePrepared - use prepared geometry.
        Returns:
        true if the current geometries covers the supplied one.
      • intersection

        public org.locationtech.jts.geom.Geometry intersection​(org.locationtech.jts.geom.Geometry geometry)
        Proxy for the intersection method.
        Parameters:
        geometry - the geometry to intersect.
        Returns:
        the intersection geometry.
      • convertToLine

        public void convertToLine()
                           throws IllegalArgumentException
        Tries to convert the internal geometry to a LineString.

        This works only for Polygon and Lines features.

        From this moment on the internal geometry (as got by the getGeometry()) will be the line type.

        To get the original geometry one can simply call resetGeometry().

        Throws:
        IllegalArgumentException - in the case the geometry is a point.
      • convertToPoint

        public void convertToPoint()
        Tries to convert the internal geometry to a Point.

        From this moment on the internal geometry (as got by the getGeometry()) will be the point type.

        To get the original geometry one can simply call resetGeometry().

      • resetGeometry

        public void resetGeometry()
        Resets the geometry, so that at the next call of getGeometry() the original geometry is reread.