| | |
| | | */ |
| | | private static Field getGeomField(Class clazz) { |
| | | try { |
| | | Field gField = clazz.getDeclaredField("geom"); |
| | | Field gField = clazz.getSuperclass().getDeclaredField("geom"); |
| | | gField.setAccessible(true); |
| | | |
| | | return gField; |
| | |
| | | * wkbLinearRing = 101 |
| | | */ |
| | | private static <T> void setGeom(T t, Feature f, Field gField) throws Exception { |
| | | Geometry geometry = f.GetGeometryRef(); |
| | | if (null != geometry) { |
| | | String wkt = geometry.ExportToWkt(); |
| | | switch (geometry.GetGeometryType()) { |
| | | String geo = "null"; |
| | | if (null != f.GetGeometryRef()) { |
| | | String wkt = f.GetGeometryRef().ExportToWkt(); |
| | | switch (f.GetGeometryRef().GetGeometryType()) { |
| | | case 2: |
| | | wkt = wkt.replace("LINESTRING (", "MULTILINESTRING ((") + ")"; |
| | | break; |
| | |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | gField.set(t, String.format("ST_GeomFromText('%s')", wkt)); |
| | | geo = String.format("ST_GeomFromText('%s')", wkt); |
| | | } |
| | | |
| | | gField.set(t, geo); |
| | | } |
| | | |
| | | /** |