| | |
| | | } |
| | | |
| | | T t = (T) clazz.newInstance(); |
| | | if (readFeature(t, f, map, gField)) { |
| | | list.add(t); |
| | | } |
| | | readFeature(t, f, map, gField); |
| | | list.add(t); |
| | | } while (true); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | /** |
| | | * 读取Feature |
| | | */ |
| | | private static <T> boolean readFeature(T t, Feature f, Map<Integer, Field> map, Field gField) { |
| | | try { |
| | | for (Integer i : map.keySet()) { |
| | | private static <T> void readFeature(T t, Feature f, Map<Integer, Field> map, Field gField) { |
| | | for (Integer i : map.keySet()) { |
| | | try { |
| | | Field field = map.get(i); |
| | | setValue(t, f, field, i); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | if (null != gField) { |
| | | setGeom(t, f, gField); |
| | | } |
| | | |
| | | return true; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return false; |
| | | if (null != gField) { |
| | | setGeom(t, f, gField); |
| | | } |
| | | } |
| | | |
| | |
| | | * wkbNone = 100, |
| | | * wkbLinearRing = 101 |
| | | */ |
| | | private static <T> void setGeom(T t, Feature f, Field gField) throws Exception { |
| | | String geo = "null"; |
| | | if (null != f.GetGeometryRef()) { |
| | | String wkt = f.GetGeometryRef().ExportToWkt(); |
| | | // noinspection AlibabaRemoveCommentedCode |
| | | switch (f.GetGeometryRef().GetGeometryType()) { |
| | | //case 1: |
| | | // wkt = wkt.replace("POINT", "MULTIPOINT"); |
| | | // break; |
| | | case 2: |
| | | wkt = wkt.replace("LINESTRING (", "MULTILINESTRING ((") + ")"; |
| | | break; |
| | | case 3: |
| | | wkt = wkt.replace("POLYGON (", "MULTIPOLYGON ((") + ")"; |
| | | break; |
| | | default: |
| | | break; |
| | | private static <T> void setGeom(T t, Feature f, Field gField) { |
| | | try { |
| | | String geo = "null"; |
| | | if (null != f.GetGeometryRef()) { |
| | | String wkt = f.GetGeometryRef().ExportToWkt(); |
| | | // noinspection AlibabaRemoveCommentedCode |
| | | switch (f.GetGeometryRef().GetGeometryType()) { |
| | | //case 1: |
| | | // wkt = wkt.replace("POINT", "MULTIPOINT"); |
| | | // break; |
| | | case 2: |
| | | wkt = wkt.replace("LINESTRING (", "MULTILINESTRING ((") + ")"; |
| | | break; |
| | | case 3: |
| | | wkt = wkt.replace("POLYGON (", "MULTIPOLYGON ((") + ")"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | geo = String.format("ST_GeomFromText('%s')", wkt); |
| | | } |
| | | geo = String.format("ST_GeomFromText('%s')", wkt); |
| | | } |
| | | |
| | | gField.set(t, geo); |
| | | gField.set(t, geo); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | float fSecond = pfSecond[0]; |
| | | int s = (int) fSecond; |
| | | int ns = (int) (1000000000 * fSecond - s); |
| | | |
| | | if (pnYear[0] > StaticData.I2050 || pnMonth[0] > StaticData.I12 || pnDay[0] > StaticData.I31 || pnHour[0] > StaticData.I24 || pnMinute[0] > StaticData.I60) { |
| | | return null; |
| | | } |
| | | |
| | | LocalDateTime localDateTime = LocalDateTime.of( |
| | | LocalDate.of(pnYear[0], pnMonth[0], pnDay[0]), |
| | |
| | | int[] pnTzFlag = new int[1]; |
| | | |
| | | f.GetFieldAsDateTime(index, pnYear, pnMonth, pnDay, pnHour, pnMinute, pfSecond, pnTzFlag); |
| | | if (pnYear[0] > StaticData.I2050 || pnMonth[0] > StaticData.I12 || pnDay[0] > StaticData.I31) { |
| | | return null; |
| | | } |
| | | |
| | | return LocalDate.of(pnYear[0], pnMonth[0], pnDay[0]); |
| | | } |