Skip to content

Commit

Permalink
Add staticDataUrl property to Feature.
Browse files Browse the repository at this point in the history
Add copy contructor for geojson Feature.
  • Loading branch information
bertrik committed Feb 16, 2024
1 parent 6d39a3e commit d3961b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public Feature(GeoJsonGeometry geometry) {
this.geometry = geometry;
}

// copy-constructor
public Feature(Feature feature) {
this(feature.geometry);
properties.putAll(feature.properties);
}

public GeoJsonGeometry getGeometry() {
return geometry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ public final class VerkeersDrukteResource {
public FeatureCollection getStatic() {
FeatureCollection featureCollection = new FeatureCollection();
for (FeatureCollection.Feature f : handler.getStaticData().getFeatures()) {
// copy feature with all original properties
FeatureCollection.Feature feature = new FeatureCollection.Feature(f.getGeometry());
f.getProperties().forEach(feature::addProperty);
// add extra property with dynamic data URL
FeatureCollection.Feature feature = new FeatureCollection.Feature(f);
String location = (String) f.getProperties().getOrDefault("dgl_loc", "");
if (!location.isEmpty()) {
String staticDataUrl = config.getBaseUrl() + TRAFFIC_PATH + STATIC_PATH + "/" + location;
feature.addProperty("staticDataUrl", staticDataUrl);
String dynamicDataUrl = config.getBaseUrl() + TRAFFIC_PATH + DYNAMIC_PATH + "/" + location;
feature.addProperty("dynamicDataUrl", dynamicDataUrl);
}
Expand Down

0 comments on commit d3961b2

Please sign in to comment.