Class Feature


  • public class Feature
    extends Object
    A GeoJSON feature.

    This class provides factory methods to create single-use GeoJSON feature builders for different geometries.

    See GeoJson for examples.

    Author:
    U.S. Geological Survey
    • Method Detail

      • point

        public static Feature.Builder point​(Location location)
        Create a single-use point feature builder.
        Parameters:
        location - of point
      • lineString

        public static Feature.Builder lineString​(LocationList line)
        Create a single-use line string feature builder.
        Parameters:
        line - locations
      • multiLineString

        public static Feature.Builder multiLineString​(List<LocationList> multiLine)
        Create a single-use multi-line string feature builder.
        Parameters:
        multiLine - locations
      • polygon

        public static Feature.Builder polygon​(LocationList exterior,
                                              LocationList... interiors)
        Create a single-use polygon feature builder.
        Parameters:
        exterior - linear ring boundary of polygon
        interiors - optional interior linear rings
      • idAsString

        public Optional<String> idAsString()
        The 'id' of this feature as a Optional<String>. If this feature does not contain an 'id' member, return Optional.empty().
      • idAsInt

        public OptionalInt idAsInt()
        The 'id' of this feature as a OptionalInt. If this feature does not contain an 'id' member, return OptionalInt.empty().
      • bbox

        public Optional<double[]> bbox()
        The bounding box value array; If bbox is null, returns Optional.empty(), else returns an Optional<double[]> copy of the bbox value array.
      • properties

        public Properties properties()
        Get the property map associated with this feature as a Properties helper object. May be null or empty.
      • type

        public GeoJson.Type type()
        The GeoJSON geometry type of this feature, one of: [POINT, LINE_STRING, POLYGON, MULTI_LINE_STRING].
        See Also:
        GeoJson.Type
      • toJson

        public String toJson()
        Return the serialized form of this GeoJSON feature.
      • toJsonTree

        public com.google.gson.JsonElement toJsonTree()
        Returns the Feature as a JsonElement.
      • write

        public void write​(Path path)
                   throws IOException
        Write the serialized form of this GeoJSON feature to the file at path.
        Throws:
        IOException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object