Introduce GeoJsonUtils.
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 12 Jul 2021 06:39:11 +0000 (08:39 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 12 Jul 2021 06:39:11 +0000 (08:39 +0200)
environment/org.argeo.geo.ui/src/org/argeo/geo/GeoJsonUtils.java [new file with mode: 0644]

diff --git a/environment/org.argeo.geo.ui/src/org/argeo/geo/GeoJsonUtils.java b/environment/org.argeo.geo.ui/src/org/argeo/geo/GeoJsonUtils.java
new file mode 100644 (file)
index 0000000..0d58480
--- /dev/null
@@ -0,0 +1,24 @@
+package org.argeo.geo;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/** Geo data utilities. */
+public class GeoJsonUtils {
+
+       /** Add these properties to all features. */
+       public static void addProperties(JsonNode tree, Map<String, String> map) {
+               for (JsonNode feature : tree.get("features")) {
+                       ObjectNode properties = (ObjectNode) feature.get("properties");
+                       for (String key : map.keySet()) {
+                               properties.put(key, map.get(key));
+                       }
+               }
+       }
+
+       /** Singleton. */
+       private GeoJsonUtils() {
+       }
+}