src/main/java/com/dji/sample/patches/dao/ShpToDataSourceMapper.java
@@ -2,7 +2,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dji.sample.patches.model.entity.PatchesEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @Mapper src/main/java/com/dji/sample/patches/utils/FormatConversionUtil.java
@@ -2,15 +2,13 @@ import java.util.List; import static org.locationtech.jts.io.WKTConstants.POLYGON; public class FormatConversionUtil { public static String[] formatConversion(List<String> s) { String str = s.toString().trim(); String ses = str.substring(1, str.length() - 2); String see = ses.replaceAll("\\[\\[\\[\\[", "((") .replaceAll("].\\[", " ") .replaceAll("]]]", "))"); .replaceAll("].\\[", " ") .replaceAll("]]]", "))"); String[] arr1 = see.split("],"); return arr1; } src/main/java/com/dji/sample/patches/utils/MultipartFileTOFileUtil.java
@@ -9,11 +9,11 @@ public class MultipartFileTOFileUtil { public File multipartFile2File (MultipartFile multipartFile) { public File multipartFile2File(MultipartFile multipartFile) { String tmpFileDir = null; // 创建临时文件 String randomFileName = UUID.randomUUID().toString(); tmpFileDir = "D:/tmp/"+randomFileName; tmpFileDir = "D:/tmp/" + randomFileName; File file = new File(tmpFileDir); InputStream inputStream = null; FileOutputStream outputStream = null; 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;