| | |
| | | import org.geotools.geometry.jts.JTS; |
| | | import org.geotools.referencing.CRS; |
| | | import org.locationtech.jts.geom.Geometry; |
| | | import org.locationtech.jts.io.ParseException; |
| | | import org.locationtech.jts.io.WKTReader; |
| | | import org.opengis.referencing.FactoryException; |
| | | import org.opengis.referencing.crs.CRSAuthorityFactory; |
| | |
| | | Geometry geometry = reader.read(wkt); |
| | | geometry.setSRID(srid); |
| | | return geometry; |
| | | } catch (ParseException e) { |
| | | System.out.println("WKT解析错误: " + e.getMessage()); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static Geometry coordinateTransform(Geometry sourceGeometry, int targetSrid) { |
| | | if (sourceGeometry == null || sourceGeometry.getSRID() == 0 || targetSrid == 0) { |
| | | return null; |