@Test public void testCreateFromSingleFeature() throws Exception { JsonFeatureFactory factory = new JsonFeatureFactory(); FeatureCollection c = factory .createCollection( JsonTestUtil .parse("{ \"type\": \"Feature\",\n" + " \"geometry\": {\"type\": \"Point\", \"coordinates\": [102.0, 0.5]},\n" + " \"properties\": {\"prop0\": \"value0\"}\n" + " }"), null); Assert.assertEquals(1, c.getFeatures().size()); Feature f1 = c.getFeatures().get(0); Assert.assertEquals("value0", f1.getAttributeValue("prop0")); Assert.assertEquals("POINT (102.0 0.5)", WktService.toWkt(f1.getGeometry())); }
public FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer) { FeatureCollection dto = new FeatureCollection(layer); String type = JsonService.getStringValue(jsonObject, "type"); if ("FeatureCollection".equals(type)) { JSONArray features = JsonService.getChildArray(jsonObject, "features"); for (int i = 0; i < features.size(); i++) { dto.getFeatures().add(createFeature((JSONObject) features.get(i), layer)); } } else if ("Feature".equals(type)) { dto.getFeatures().add(createFeature(jsonObject, layer)); } return dto; }
JsonFeatureFactory { public FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer) { FeatureCollection dto = new FeatureCollection(layer); String type = JsonService.getStringValue(jsonObject, "type"); if ("FeatureCollection".equals(type)) { JSONArray features = JsonService.getChildArray(jsonObject, "features"); for (int i = 0; i < features.size(); i++) { dto.getFeatures().add(createFeature((JSONObject) features.get(i), layer)); } } else if ("Feature".equals(type)) { dto.getFeatures().add(createFeature(jsonObject, layer)); } return dto; } }
JsonFeatureFactory { public FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer) { FeatureCollection dto = new FeatureCollection(layer); String type = JsonService.getStringValue(jsonObject, "type"); if ("FeatureCollection".equals(type)) { JSONArray features = JsonService.getChildArray(jsonObject, "features"); for (int i = 0; i < features.size(); i++) { dto.getFeatures().add(createFeature((JSONObject) features.get(i), layer)); } } else if ("Feature".equals(type)) { dto.getFeatures().add(createFeature(jsonObject, layer)); } return dto; }  }
JsonFeatureFactory { public FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer) { FeatureCollection dto = new FeatureCollection(layer); String type = JsonService.getStringValue(jsonObject, "type"); if ("FeatureCollection".equals(type)) { JSONArray features = JsonService.getChildArray(jsonObject, "features"); for (int i = 0; i < features.size(); i++) { dto.getFeatures().add(createFeature((JSONObject) features.get(i), layer)); } } else if ("Feature".equals(type)) { dto.getFeatures().add(createFeature(jsonObject, layer)); } return dto; }  FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer); }
JsonFeatureFactory { public FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer) { FeatureCollection dto = new FeatureCollection(layer); String type = JsonService.getStringValue(jsonObject, "type"); if ("FeatureCollection".equals(type)) { JSONArray features = JsonService.getChildArray(jsonObject, "features"); for (int i = 0; i < features.size(); i++) { dto.getFeatures().add(createFeature((JSONObject) features.get(i), layer)); } } else if ("Feature".equals(type)) { dto.getFeatures().add(createFeature(jsonObject, layer)); } return dto; }  FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer);  }