zrj
2024-11-08 4dc18cd2c9d0c44cf8d84cd4687564f26e294eab
src/main/java/org/springblade/common/utils/ShapeFileUtil.java
@@ -44,14 +44,15 @@
                         String fileName,
                         String geomType,
                         String saveFolder) {
      String path = saveFolder + "/" + fileName;
      //创建保存shp文件夹
      File dir = new File(saveFolder);
      File dir = new File(path);
      if (!dir.exists()) {
         FileUtil.mkdir(dir);
      }
      //shp文件路径
      String shpFileName = fileName + ".shp";
      String fileUrl = saveFolder + shpFileName;
      String fileUrl = path+ "/" + shpFileName;
      File file = new File(fileUrl);
      FeatureWriter<SimpleFeatureType, SimpleFeature> writer = null;
@@ -73,7 +74,6 @@
         String geomProperty = "the_geom";
         String idProperty = "ID";
         String nameProperty = "name";
         String descriptionProperty = "desc";
         //设置图形类型
         if ("Polygon".equals(geomType)) {
@@ -94,7 +94,6 @@
         //设置对应属性类型
         tb.add(idProperty, String.class);
         tb.add(nameProperty, String.class);
         tb.add(descriptionProperty, String.class);
         //设置默认geometry
         tb.setDefaultGeometry(geomProperty);
@@ -111,11 +110,11 @@
            //属性赋值  geometry要赋值wkt格式的
            feature.setAttribute(geomProperty, new WKTReader().read((MapUtil.getStr(map, "geometry"))));
            feature.setAttribute(idProperty, MapUtil.getStr(map, idProperty));
            feature.setAttribute(nameProperty, MapUtil.getStr(map, "名称"));
            String description = MapUtil.getStr(map, "描述");
            if (CharSequenceUtil.isNotBlank(description)) {
               feature.setAttribute(descriptionProperty, description);
            }
            feature.setAttribute(nameProperty, MapUtil.getStr(map, nameProperty));
//            String description = MapUtil.getStr(map, "描述");
//            if (CharSequenceUtil.isNotBlank(description)) {
//               feature.setAttribute(descriptionProperty, description);
//            }
         }
         writer.write();
      } catch (IOException | FactoryException | ParseException e) {