From 56c25bcb0dc03aae78aba23f32ebbf548b866332 Mon Sep 17 00:00:00 2001
From: xing <xingjs@qq.com>
Date: 星期三, 22 二月 2023 14:11:09 +0800
Subject: [PATCH] 20230221@xingjs@提交官网一张图相关内容接口

---
 src/main/java/com/lf/server/helper/GdbHelper.java |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/lf/server/helper/GdbHelper.java b/src/main/java/com/lf/server/helper/GdbHelper.java
index bc38afb..e813e7d 100644
--- a/src/main/java/com/lf/server/helper/GdbHelper.java
+++ b/src/main/java/com/lf/server/helper/GdbHelper.java
@@ -242,7 +242,7 @@
     /**
      * 璁剧疆鍊�
      */
-    private static <T> void setValue(T t, Feature f, Field field, Integer i) throws Exception {
+    public static <T> void setValue(T t, Feature f, Field field, Integer i) throws Exception {
         switch (field.getType().getName()) {
             case "java.math.BigDecimal":
                 double dd = f.GetFieldAsDouble(i);
@@ -313,7 +313,7 @@
     /**
      * 鑾峰彇 Timestamp
      */
-    private static Timestamp getTimestamp(Feature f, int index) {
+    public static Timestamp getTimestamp(Feature f, int index) {
         int[] pnYear = new int[1];
         int[] pnMonth = new int[1];
         int[] pnDay = new int[1];
@@ -339,7 +339,7 @@
     /**
      * 鑾峰彇 LocalDate
      */
-    private static LocalDate getLocalDate(Feature f, int index) {
+    public static LocalDate getLocalDate(Feature f, int index) {
         int[] pnYear = new int[1];
         int[] pnMonth = new int[1];
         int[] pnDay = new int[1];
@@ -390,8 +390,7 @@
                     }
 
                     List<Field> fields = new ArrayList<>();
-                    // fields.add(getGeomField(clazz))
-                    getFields(clazz, fields);
+                    getFields(clazz, fields, StaticData.GDB_EXCLUDE_FIELDS);
                     addLayerField(layer, fields);
 
                     setLayerData(layer, fields, map.get(key));
@@ -421,15 +420,17 @@
             return null;
         }
 
+        Integer srid = null;
         String geomType = null;
-        SpatialReference sr = new SpatialReference();
         if (baseMapper instanceof GeomBaseMapper) {
             GeomBaseMapper geomMapper = (GeomBaseMapper) baseMapper;
             geomType = geomMapper.selectGeometryType(tab);
 
-            Integer srid = geomMapper.selectSrid(tab);
-            sr.ImportFromEPSG(null == srid ? 4490 : srid);
+            srid = geomMapper.selectSrid(tab);
         }
+
+        SpatialReference sr = new SpatialReference();
+        sr.ImportFromEPSG(null == srid ? 4490 : srid);
 
         return dataSource.CreateLayer(tab, sr, getGeomType(geomType), null);
     }
@@ -439,7 +440,7 @@
      */
     private static Integer getGeomType(String geomType) {
         if (StringHelper.isEmpty(geomType)) {
-            return ogr.wkbUnknown;
+            return ogr.wkbPoint;
         }
 
         switch (geomType) {
@@ -463,11 +464,11 @@
     /**
      * 鑾峰彇瀛楁
      */
-    private static void getFields(Class clazz, List<Field> list) {
+    public static void getFields(Class clazz, List<Field> list, List<String> excludeFields) {
         try {
             Field[] fields = clazz.getDeclaredFields();
             for (Field f : fields) {
-                if (StaticData.GDB_EXCLUDE_FIELDS.contains(f.getName())) {
+                if (excludeFields.contains(f.getName())) {
                     continue;
                 }
 
@@ -476,7 +477,7 @@
             }
 
             if (!StaticData.OBJECT.equals(clazz.getSuperclass().getName())) {
-                getFields(clazz.getSuperclass(), list);
+                getFields(clazz.getSuperclass(), list, excludeFields);
             }
         } catch (Exception ex) {
             //
@@ -530,8 +531,10 @@
 
             if (t instanceof BaseGeoEntity) {
                 BaseGeoEntity geoEntity = (BaseGeoEntity) t;
-                Geometry geom = Geometry.CreateFromWkt(geoEntity.getGeom());
-                f.SetGeometry(geom);
+                if (!StringHelper.isEmpty(geoEntity.getGeom())) {
+                    Geometry geom = Geometry.CreateFromWkt(geoEntity.getGeom());
+                    f.SetGeometry(geom);
+                }
             }
 
             setFeatureData(f, fields, t);

--
Gitblit v1.9.3