/** * Creates a Json Feature from a {@link LocationIterableProperties} * * @deprecated use {@link #create(GeometryWithProperties)} instead * @param object * {@link LocationIterableProperties} * @return a GeoJson Feature */ @Deprecated public JsonObject create(final LocationIterableProperties object) { final GeometryWithProperties geometryWithProperties = toGeometryWithProperties(object); return create(geometryWithProperties); }
/** * Converts iterable of deprecated LocationIterableProperties to iterable of * GeometryWithProperties. * * @param objects * iterable of LocationIterableProperties * @return iterable of GeometryWithProperties */ protected static final Iterable<GeometryWithProperties> toGeometriesWithProperties( final Iterable<LocationIterableProperties> objects) { final Iterable<GeometryWithProperties> geometriesWithProperties = Iterables .translate(objects, locationIterableProperties -> { return toGeometryWithProperties(locationIterableProperties); }); return geometriesWithProperties; }
@Test public void testToGeometryWithProperties() { final Map<String, String> stringProperties = new HashMap<>(); stringProperties.put("prop1", "val1"); stringProperties.put("prop2", "val2"); final LocationIterableProperties locationIterableProperties = new LocationIterableProperties( PolyLine.TEST_POLYLINE, stringProperties); final GeometryWithProperties geometryWithProperties = GeoJsonBuilder .toGeometryWithProperties(locationIterableProperties); Assert.assertEquals(PolyLine.TEST_POLYLINE, geometryWithProperties.getGeometry()); for (final Entry<String, String> stringPropertiesEntry : stringProperties.entrySet()) { Assert.assertEquals(stringPropertiesEntry.getValue(), geometryWithProperties.getProperties().get(stringPropertiesEntry.getKey())); } } }