|
@@ -9,9 +9,9 @@ import org.locationtech.jts.geom.Coordinate;
|
|
import org.locationtech.jts.geom.Envelope;
|
|
import org.locationtech.jts.geom.Envelope;
|
|
import org.locationtech.jts.geom.GeometryFactory;
|
|
import org.locationtech.jts.geom.GeometryFactory;
|
|
import org.locationtech.jts.geom.Polygon;
|
|
import org.locationtech.jts.geom.Polygon;
|
|
-import org.locationtech.jts.geom.PrecisionModel;
|
|
|
|
import org.locationtech.jts.util.GeometricShapeFactory;
|
|
import org.locationtech.jts.util.GeometricShapeFactory;
|
|
import org.opengis.referencing.FactoryException;
|
|
import org.opengis.referencing.FactoryException;
|
|
|
|
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
|
import org.opengis.referencing.operation.TransformException;
|
|
import org.opengis.referencing.operation.TransformException;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -29,7 +29,7 @@ public class GeomUtil {
|
|
/**
|
|
/**
|
|
* geom工厂
|
|
* geom工厂
|
|
*/
|
|
*/
|
|
- private static final GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4490);
|
|
|
|
|
|
+ private static final GeometryFactory geometryFactory = new GeometryFactory();
|
|
/**
|
|
/**
|
|
* 形状工厂
|
|
* 形状工厂
|
|
*/
|
|
*/
|
|
@@ -51,9 +51,12 @@ public class GeomUtil {
|
|
double lng = centre.getX();
|
|
double lng = centre.getX();
|
|
//纬度
|
|
//纬度
|
|
double lat = centre.getY();
|
|
double lat = centre.getY();
|
|
|
|
+ //坐标系
|
|
|
|
+ CoordinateReferenceSystem crs = CRS.decode("EPSG:" + crsCode);
|
|
|
|
+ if (crs == null) return null;
|
|
|
|
|
|
//创建大地计算器,并设置坐标系
|
|
//创建大地计算器,并设置坐标系
|
|
- GeodeticCalculator gc = new GeodeticCalculator(CRS.decode("EPSG:4490"));
|
|
|
|
|
|
+ GeodeticCalculator gc = new GeodeticCalculator(crs);
|
|
|
|
|
|
//计算东点(90度),正东移动
|
|
//计算东点(90度),正东移动
|
|
gc.setStartingGeographicPoint(lng, lat);
|
|
gc.setStartingGeographicPoint(lng, lat);
|
|
@@ -101,7 +104,7 @@ public class GeomUtil {
|
|
//创建圆
|
|
//创建圆
|
|
Polygon circle = shapeFactory.createCircle();
|
|
Polygon circle = shapeFactory.createCircle();
|
|
//设置坐标系
|
|
//设置坐标系
|
|
- circle.setSRID(4490);
|
|
|
|
|
|
+ circle.setSRID(Integer.parseInt(crsCode));
|
|
|
|
|
|
return circle;
|
|
return circle;
|
|
} catch (TransformException | FactoryException e) {
|
|
} catch (TransformException | FactoryException e) {
|