Introduce GeoJsonUtils.
[gpl/argeo-suite.git] / environment / org.argeo.geo.ui / src / org / argeo / geo / GeoJsonUtils.java
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() {
+       }
+}