use of com.google.maps.android.data.Geometry in project android-maps-utils by googlemaps.
the class GeoJsonParser method parseFeature.
/**
* Parses a single GeoJSON feature which contains a geometry and properties member both of
* which can be null. Also parses the bounding box and id members of the feature if they exist.
*
* @param geoJsonFeature feature to parse
* @return GeoJsonFeature object
*/
private static GeoJsonFeature parseFeature(JSONObject geoJsonFeature) {
String id = null;
LatLngBounds boundingBox = null;
Geometry geometry = null;
HashMap<String, String> properties = new HashMap<String, String>();
try {
if (geoJsonFeature.has(FEATURE_ID)) {
id = geoJsonFeature.getString(FEATURE_ID);
}
if (geoJsonFeature.has(BOUNDING_BOX)) {
boundingBox = parseBoundingBox(geoJsonFeature.getJSONArray(BOUNDING_BOX));
}
if (geoJsonFeature.has(FEATURE_GEOMETRY) && !geoJsonFeature.isNull(FEATURE_GEOMETRY)) {
geometry = parseGeometry(geoJsonFeature.getJSONObject(FEATURE_GEOMETRY));
}
if (geoJsonFeature.has(PROPERTIES) && !geoJsonFeature.isNull(PROPERTIES)) {
properties = parseProperties(geoJsonFeature.getJSONObject("properties"));
}
} catch (JSONException e) {
Log.w(LOG_TAG, "Feature could not be successfully parsed " + geoJsonFeature.toString());
return null;
}
return new GeoJsonFeature(geometry, id, properties, boundingBox);
}
Aggregations