@Test public void testParseGeoJson() throws Exception { JSONObject validGeoJsonObject = new JSONObject( "{ \"type\": \"MultiLineString\",\n" + " \"coordinates\": [\n" + " [ [100.0, 0.0], [101.0, 1.0] ],\n" + " [ [102.0, 2.0], [103.0, 3.0] ]\n" + " ]\n" + " }"); GeoJsonParser parser = new GeoJsonParser(validGeoJsonObject); GeoJsonLineString ls1 = new GeoJsonLineString( new ArrayList<>(Arrays.asList(new LatLng(0, 100), new LatLng(1, 101)))); GeoJsonLineString ls2 = new GeoJsonLineString( new ArrayList<>(Arrays.asList(new LatLng(2, 102), new LatLng(3, 103)))); GeoJsonMultiLineString geoJsonMultiLineString = new GeoJsonMultiLineString(new ArrayList<>(Arrays.asList(ls1, ls2))); GeoJsonFeature geoJsonFeature = new GeoJsonFeature(geoJsonMultiLineString, null, null, null); List<GeoJsonFeature> geoJsonFeatures = new ArrayList<>(Arrays.asList(geoJsonFeature)); assertEquals(geoJsonFeatures.get(0).getId(), parser.getFeatures().get(0).getId()); }
private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures.addAll(parseFeatureCollection(mGeoJsonFile)); } else if (isGeometry(type)) { feature = parseGeometryToFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } catch (JSONException e) { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } }
GeoJsonParser { private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures.addAll(parseFeatureCollection(mGeoJsonFile)); } else if (isGeometry(type)) { feature = parseGeometryToFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } catch (JSONException e) { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } }
GeoJsonParser { private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures.addAll(parseFeatureCollection(mGeoJsonFile)); } else if (isGeometry(type)) { feature = parseGeometryToFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } catch (JSONException e) { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } GeoJsonParser(JSONObject geoJsonFile); }
GeoJsonParser { private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures.addAll(parseFeatureCollection(mGeoJsonFile)); } else if (isGeometry(type)) { feature = parseGeometryToFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } catch (JSONException e) { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } GeoJsonParser(JSONObject geoJsonFile); static Geometry parseGeometry(JSONObject geoJsonGeometry); }
GeoJsonParser { private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures.addAll(parseFeatureCollection(mGeoJsonFile)); } else if (isGeometry(type)) { feature = parseGeometryToFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } catch (JSONException e) { Log.w(LOG_TAG, "GeoJSON file could not be parsed."); } } GeoJsonParser(JSONObject geoJsonFile); static Geometry parseGeometry(JSONObject geoJsonGeometry);  }