&& !geometry.getFeatures().isEmpty()) { final Feature fg = geometry.getFeatures().get(0); fg.setProperty("formattedAddress", formattedAddress); fg.setProperty("partialMatch", Boolean.valueOf(partialMatch)); fg.setProperty("placeId", placeId); if (postcodeLocalities == null) { fg.setProperty("postcodeLocalities", null); } else { fg.setProperty("postcodeLocalities", Arrays .copyOf(postcodeLocalities, postcodeLocalities.length)); fg.setProperty("types", types); fg.setProperty("addressComponents", addressComponents);
private Feature buildFeature() { Feature feature = new Feature(); feature.setGeometry(new Point(Math.random() * 360 - 180, Math.random() * 180 - 90)); feature.setProperty("key", instanceIdSeq.getAndIncrement()); feature.setProperty("field", "some-field"); feature.setProperty("empty", "no"); feature.setProperty("valid", "yes"); return feature; } }
/** * Convert a Point and LocationType into a Feature. * * @param point the Point * @param locationType the LocationType * @return the Feature */ private static Feature createLocation(final Point point, final LocationType locationType) { final Feature location = new Feature(); location.setGeometry(point); location.setProperty("locationType", locationType); location.setId("location"); return location; }
/** * Create a GeoJSON Point from a LatLng. * * @param latLng the LatLng * @param locationType the location type * @return the GeoServiceLatLng */ default Feature toLocationFeature(final LatLng latLng, final LocationType locationType) { if (latLng == null) { final Feature feature = new Feature(); feature.setProperty("locationType", locationType); feature.setId("location"); return feature; } final Point point = new Point(latLng.lng, latLng.lat); final Feature feature = new Feature(); feature.setGeometry(point); feature.setProperty("locationType", locationType); feature.setId("location"); return feature; } }