diff --git a/giscat-vector/giscat-vector-pojo/src/main/java/org/wowtools/giscat/vector/pojo/converter/ProtoFeatureConverter.java b/giscat-vector/giscat-vector-pojo/src/main/java/org/wowtools/giscat/vector/pojo/converter/ProtoFeatureConverter.java index ca5995f..61be6b5 100644 --- a/giscat-vector/giscat-vector-pojo/src/main/java/org/wowtools/giscat/vector/pojo/converter/ProtoFeatureConverter.java +++ b/giscat-vector/giscat-vector-pojo/src/main/java/org/wowtools/giscat/vector/pojo/converter/ProtoFeatureConverter.java @@ -550,6 +550,19 @@ public static byte[] feature2Proto(Feature feature) { return featureCollection2Proto(fc); } + private static ProtoFeature.Map.Builder putPropertiesToCell(Map properties,ToProtoKeyValueCell keyValueCell) { + ProtoFeature.Map.Builder propertiesBuilder = ProtoFeature.Map.newBuilder(); + properties.forEach((k, v) -> { + if (null == v) { + return; + } + PropertiesSetter setter = getPropertiesSetter(v); + setter.setKey(propertiesBuilder, keyValueCell, k); + setter.setValue(propertiesBuilder, keyValueCell, v); + }); + return propertiesBuilder; + } + /** * FeatureCollection 转 ProtoFeature bytes * @@ -563,15 +576,7 @@ public static byte[] featureCollection2Proto(FeatureCollection featureCollection //properties转换 Map properties = feature.getProperties(); if (null != properties) { - ProtoFeature.Map.Builder propertiesBuilder = ProtoFeature.Map.newBuilder(); - properties.forEach((k, v) -> { - if (null == v) { - return; - } - PropertiesSetter setter = getPropertiesSetter(v); - setter.setKey(propertiesBuilder, keyValueCell, k); - setter.setValue(propertiesBuilder, keyValueCell, v); - }); + ProtoFeature.Map.Builder propertiesBuilder = putPropertiesToCell(properties, keyValueCell); builder.addPropertiess(propertiesBuilder); } else { builder.addPropertiess(nullMap); @@ -885,15 +890,7 @@ public void setValue(ProtoFeature.List.Builder propertiesBuilder, ToProtoKeyValu private ProtoFeature.Map.Builder createMapBuilder(ToProtoKeyValueCell keyValueCell, Object value) { Map subProperties = (Map) value; - ProtoFeature.Map.Builder subBuilder = ProtoFeature.Map.newBuilder(); - subProperties.forEach((k, v) -> { - if (null == v) { - return; - } - PropertiesSetter setter = getPropertiesSetter(v); - setter.setKey(subBuilder, keyValueCell, k); - setter.setValue(subBuilder, keyValueCell, v); - }); + ProtoFeature.Map.Builder subBuilder = putPropertiesToCell(subProperties, keyValueCell); return subBuilder; } };