rain
2024-03-27 560a36b86d97fbb2dc7cc98966944d21ec299ca0
src/main/java/com/dji/sample/patches/utils/ShapeFileUtil.java
@@ -54,10 +54,11 @@
            Filter filter = Filter.INCLUDE;
            FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);
            return collection;
        }catch (Exception e){
        } catch (Exception e) {
            throw e;
        }
    }
    /**
     * @param zipFile:
     * @return JSONObject
@@ -67,15 +68,15 @@
     */
    public static List<String> shpToGeoJson(File zipFile) throws IOException {
        FeatureJSON fjson = new FeatureJSON();
        JSONObject geoJsonObject=new JSONObject();
        geoJsonObject.put("type","FeatureCollection");
        List<String> strings=new ArrayList<>();
        JSONObject geoJsonObject = new JSONObject();
        geoJsonObject.put("type", "FeatureCollection");
        List<String> strings = new ArrayList<>();
        try {
            // 获取FeatureCollection
            FeatureCollection collection = getFeatureCollectionByShpFile(zipFile);
            FeatureIterator iterator = collection.features();
            List<JSONObject> array  = new ArrayList<JSONObject>();
            List<JSONObject> array = new ArrayList<JSONObject>();
            //遍历feature转为json对象
            while (iterator.hasNext()) {
                SimpleFeature feature = (SimpleFeature) iterator.next();
@@ -91,10 +92,10 @@
            }
            iterator.close();
            //添加到geojsonObject
            geoJsonObject.put("features",array);
            geoJsonObject.put("features", array);
            iterator.close();
        }catch (Exception e){
        } catch (Exception e) {
            throw e;
        }
        return strings;