| | |
| | | * @description 通过shp压缩文件,将其转换为GeoJson格式 |
| | | * @date 2023/7/18 16:04 |
| | | */ |
| | | public static JSONObject shpToGeoJson(File zipFile) throws IOException { |
| | | 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<>(); |
| | | try { |
| | | // 获取FeatureCollection |
| | | FeatureCollection collection = getFeatureCollectionByShpFile(zipFile); |
| | |
| | | byte[] b = temp.getBytes("iso8859-1"); |
| | | temp = new String(b, "gbk"); |
| | | JSONObject json = JSONObject.parseObject(temp); |
| | | String str2 = json.getJSONObject("geometry").get("coordinates").toString(); |
| | | strings.add(str2); |
| | | array.add(json); |
| | | } |
| | | iterator.close(); |
| | |
| | | }catch (Exception e){ |
| | | throw e; |
| | | } |
| | | return geoJsonObject; |
| | | return strings; |
| | | } |
| | | |
| | | } |