From 0acd3bbf62b49bfcc9329d0e77a85107ec97d6df Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Mon, 12 Jul 2021 08:39:11 +0200 Subject: [PATCH] Introduce GeoJsonUtils. --- .../src/org/argeo/geo/GeoJsonUtils.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 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 index 0000000..0d58480 --- /dev/null +++ b/environment/org.argeo.geo.ui/src/org/argeo/geo/GeoJsonUtils.java @@ -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 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() { + } +} -- 2.30.2