public static List<SimpleFeature> toSimpleFeature(List<SimpleFeature> simpleFeatureList){ List<SimpleFeature> resultList = new ArrayList<>(); for (SimpleFeature simpleFeature: simpleFeatureList) { Geometry geometry = (Geometry) simpleFeature.getDefaultGeometry(); if (geometry instanceof MultiLineString || geometry instanceof MultiPolygon || geometry instanceof MultiPoint) { for (int i = 0; i < geometry.getNumGeometries(); i += 1) { SimpleFeature clone = SimpleFeatureBuilder.deep(simpleFeature); clone.setDefaultGeometry(geometry.getGeometryN(i)); resultList.add(clone); } } else if (geometry instanceof LineString || geometry instanceof Polygon || geometry instanceof Point) { resultList.add(simpleFeature); } } return resultList; }
参考:https://blog.csdn.net/qq_18298439/article/details/119798641
标签:instanceof,geotools,geometry,clone,resultList,simpleFeature,SimpleFeature,LineSt From: https://www.cnblogs.com/2008nmj/p/17165306.html