public SimpleFeature convertFeature(SimpleFeature old, SimpleFeatureType targetFeatureType) { SimpleFeatureBuilder fb = new SimpleFeatureBuilder(targetFeatureType); SimpleFeature newFeature = fb.buildFeature(old.getID()); FeatureDataConverter.DEFAULT.convert(old, newFeature); Map<Object, Object> userData = old.getUserData(); Object folderObject = userData.get("Folder"); if (folderObject != null) { String serializedFolders = serializeFolders(folderObject); newFeature.setAttribute("Folder", serializedFolders); } @SuppressWarnings("unchecked") Map<String, String> untypedExtendedData = (Map<String, String>) userData .get("UntypedExtendedData"); if (untypedExtendedData != null) { for (Entry<String, String> entry : untypedExtendedData.entrySet()) { if (targetFeatureType.getDescriptor(entry.getKey()) != null) { newFeature.setAttribute(entry.getKey(), entry.getValue()); } } } return newFeature; }
public SimpleFeature convertFeature(SimpleFeature old, SimpleFeatureType targetFeatureType) { SimpleFeatureBuilder fb = new SimpleFeatureBuilder(targetFeatureType); SimpleFeature newFeature = fb.buildFeature(old.getID()); FeatureDataConverter.DEFAULT.convert(old, newFeature); Map<Object, Object> userData = old.getUserData(); Object folderObject = userData.get("Folder"); if (folderObject != null) { String serializedFolders = serializeFolders(folderObject); newFeature.setAttribute("Folder", serializedFolders); } @SuppressWarnings("unchecked") Map<String, String> untypedExtendedData = (Map<String, String>) userData.get("UntypedExtendedData"); if (untypedExtendedData != null) { for (Entry<String, String> entry : untypedExtendedData.entrySet()) { if (targetFeatureType.getDescriptor(entry.getKey()) != null) { newFeature.setAttribute(entry.getKey(), entry.getValue()); } } } return newFeature; }