Class GeoJsonParser


  • public class GeoJsonParser
    extends java.lang.Object
    Parses a JSONObject and places data into their appropriate GeoJsonFeature objects. Returns an array of GeoJsonFeature objects parsed from the GeoJSON file.
    • Constructor Summary

      Constructors 
      Constructor Description
      GeoJsonParser​(org.json.JSONObject geoJsonFile)
      Creates a new GeoJsonParser
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.android.gms.maps.model.LatLngBounds getBoundingBox()
      Gets the array containing the coordinates of the bounding box for the FeatureCollection.
      java.util.ArrayList<GeoJsonFeature> getFeatures()
      Gets the array of GeoJsonFeature objects
      static Geometry parseGeometry​(org.json.JSONObject geoJsonGeometry)
      Parses a single GeoJSON geometry object containing a coordinates array or a geometries array if it has type GeometryCollection.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeoJsonParser

        public GeoJsonParser​(org.json.JSONObject geoJsonFile)
        Creates a new GeoJsonParser
        Parameters:
        geoJsonFile - GeoJSON file to parse
    • Method Detail

      • parseGeometry

        public static Geometry parseGeometry​(org.json.JSONObject geoJsonGeometry)
        Parses a single GeoJSON geometry object containing a coordinates array or a geometries array if it has type GeometryCollection. FeatureCollections, styles, bounding boxes, and properties are not processed by this method. If you want to parse GeoJSON including FeatureCollections, styles, bounding boxes, and properties into an array of GeoJsonFeatures then instantiate GeoJsonParser and call getFeatures().
        Parameters:
        geoJsonGeometry - geometry object to parse
        Returns:
        Geometry object
      • getFeatures

        public java.util.ArrayList<GeoJsonFeature> getFeatures()
        Gets the array of GeoJsonFeature objects
        Returns:
        array of GeoJsonFeatures
      • getBoundingBox

        public com.google.android.gms.maps.model.LatLngBounds getBoundingBox()
        Gets the array containing the coordinates of the bounding box for the FeatureCollection. If the FeatureCollection did not have a bounding box or if the GeoJSON file did not contain a FeatureCollection then null will be returned.
        Returns:
        LatLngBounds object containing bounding box of FeatureCollection, null if no bounding box