|
@@ -70,15 +70,17 @@ public class GisCoordinateUtil {
|
|
|
*/
|
|
|
public static double[] transformLocationToBL(double loctionX,double loctionY, ControlPointCalculateEntity dto){
|
|
|
Point point = new Point(loctionX,loctionY);
|
|
|
-// log.warn("本地转经纬度 平面 start ====");
|
|
|
-// log.info("参数 rotation:{}", dto.getRotation2());
|
|
|
-// log.info("参数 scale:{}", dto.getScale2());
|
|
|
-// log.info("参数 tx:{}", dto.getDx2());
|
|
|
-// log.info("参数 ty:{}", dto.getDy2());
|
|
|
- Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), dto.getRotation2(), dto.getScale2(), dto.getDx2(), dto.getDy2());
|
|
|
-// log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
|
|
|
-// log.warn("本地转经纬度 平面 end ====");
|
|
|
- return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
|
|
|
+
|
|
|
+ Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), dto.getRotation2(), dto.getScale2(), dto.getDx2(), dto.getDy2());
|
|
|
+// log.info("toBL输入参数:{}, {}", resultPoint.getX(), resultPoint.getY());
|
|
|
+ double[] doubles = GisCoordinateTransform.convertByProj4(resultPoint.getX(), resultPoint.getY(), "EPSG:4547", "EPSG:4490");
|
|
|
+ if (doubles == null) {
|
|
|
+ String msg = "坐标转换为空值";
|
|
|
+ log.error(msg);
|
|
|
+ throw new BaseRuntimeException(msg);
|
|
|
+ }
|
|
|
+ return doubles;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -139,69 +141,6 @@ public class GisCoordinateUtil {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
-// /**
|
|
|
-// * 解析json字符串
|
|
|
-// *
|
|
|
-// * @param jsonStr
|
|
|
-// */
|
|
|
-// private static void parseJSON(String jsonStr) {
|
|
|
-//// JSONObject json= JSONObject.fromObject(jsonStr);
|
|
|
-// JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
-// JSONArray points = json.getJSONArray("points");
|
|
|
-// JSONObject aPoint = (JSONObject) points.get(0);
|
|
|
-// JSONObject bPoint = (JSONObject) points.get(1);
|
|
|
-// JSONObject aPointCoordinate = (JSONObject) aPoint.get("coordinate");
|
|
|
-// JSONObject aPointLocation = (JSONObject) aPoint.get("location");
|
|
|
-// JSONObject bPointCoordinate = (JSONObject) bPoint.get("coordinate");
|
|
|
-// JSONObject bPointLocation = (JSONObject) bPoint.get("location");
|
|
|
-// double alon = aPointCoordinate.getDouble("longitude");
|
|
|
-// double alat = aPointCoordinate.getDouble("latitude");
|
|
|
-// double aX = aPointLocation.getDouble("x");
|
|
|
-// double aY = aPointLocation.getDouble("y");
|
|
|
-// double blon = bPointCoordinate.getDouble("longitude");
|
|
|
-// double blat = bPointCoordinate.getDouble("latitude");
|
|
|
-// double bX = bPointLocation.getDouble("x");
|
|
|
-// double bY = bPointLocation.getDouble("y");
|
|
|
-//// calculateVariable(alon, alat, aX, aY, blon, blat, bX, bY);
|
|
|
-// // System.out.println(alon+" "+alat+" "+aX+" "+aY+" "+blon+" "+blat+" "+bX+" "+bY);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 经纬度转本地坐标
|
|
|
- *
|
|
|
- * @param position 经纬度
|
|
|
- * @param dto 控制点
|
|
|
- * @return
|
|
|
- */
|
|
|
-// public static double[] convertGpsToLocation(double[] position, ControlPointEntity dto) {
|
|
|
-// double[] controlLocation1 = dto.getAgeControlLocation1();
|
|
|
-// double[] controlLocation2 = dto.getAgeControlLocation2();
|
|
|
-//
|
|
|
-// double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
|
|
|
-// double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
|
|
|
-// try {
|
|
|
-//// log.info("输入控制点3: {}, {}, {}, {}, {}, {}, {}, {}", controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
|
|
|
-//// GisCoordinateUtil.calculateVariable(controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
|
|
|
-// double[] d = GisCoordinateUtil.transformBLToLocation(position[0], position[1]);
|
|
|
-// return d;
|
|
|
-// } catch (RuntimeException e) {
|
|
|
-// log.error("坐标转换输入参数有误,请检查");
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -276,73 +215,16 @@ public class GisCoordinateUtil {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-// /**
|
|
|
-// * 控制点初始化作用, 只有控制点变化, 才会调用一次, 以后坐标转换都是基于这个值使用
|
|
|
-// * @param alon
|
|
|
-// * @param alat
|
|
|
-// * @param aX
|
|
|
-// * @param aY
|
|
|
-// * @param blon
|
|
|
-// * @param blat
|
|
|
-// * @param bX
|
|
|
-// * @param bY
|
|
|
-// */
|
|
|
-// public static void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
|
|
|
-//
|
|
|
-//
|
|
|
-// try {
|
|
|
-// double[] a= new double[0];
|
|
|
-// a = GisCoordinateTransform.convertByProj4(alon, alat,"EPSG:4490","EPSG:4547");
|
|
|
-// double[] b= GisCoordinateTransform.convertByProj4(blon, blat,"EPSG:4490","EPSG:4547");
|
|
|
-// log.info("经度2、纬度2: {}, {}", alon, alat );
|
|
|
-// log.info("经度4、纬度4: {}, {}", blon, blat );
|
|
|
-// log.info("大地2: {}, {}", a[0], a[1]);
|
|
|
-// log.info("大地4: {}, {}", b[0], b[1]);
|
|
|
-// Point point1 = new Point(a[0],a[1]);
|
|
|
-// Point point2 = new Point(b[0],b[1]);
|
|
|
-// Point newPoint1 = new Point(aX,aY);
|
|
|
-// Point newPoint2 = new Point(bX,bY);
|
|
|
-// log.info("========== start calculateVariable =================");
|
|
|
-// // 2021-09-13 修改:前后对调一下
|
|
|
-// rotation1 = Math.toRadians(AffineTransform.getAngle(point1 , point2 ) - AffineTransform.getAngle(newPoint1 , newPoint2 ));
|
|
|
-// scale1 = AffineTransform.getScale( point1 , newPoint1 , point2 , newPoint2);
|
|
|
-//// log.info("rotation1: {}", rotation1);
|
|
|
-// dx1 = AffineTransform.getXTranslation( point1 ,newPoint1, rotation1, scale1);
|
|
|
-// dy1 = AffineTransform.getYTranslation( point1 ,newPoint1, rotation1, scale1);
|
|
|
-// log.warn("rotation1: {}", rotation1);
|
|
|
-// log.warn("scale1: {}", scale1);
|
|
|
-// log.warn("tx1: {}", dx1);
|
|
|
-// log.warn("ty1: {}", dy1);
|
|
|
-// rotation2 = Math.toRadians(AffineTransform.getAngle(newPoint1 , newPoint2 ) - AffineTransform.getAngle(point1 , point2 ));
|
|
|
-//// log.info("rotation2: {}", rotation2);
|
|
|
-// scale2 = AffineTransform.getScale( newPoint1 , point1 , newPoint2 , point2);
|
|
|
-// dx2 = AffineTransform.getXTranslation( newPoint1 ,point1, rotation2, scale1);
|
|
|
-// dy2 = AffineTransform.getYTranslation( newPoint1 ,point1, rotation2, scale1);
|
|
|
-//
|
|
|
-// log.warn("rotation2: {}", rotation2);
|
|
|
-// log.warn("scale2: {}", scale2);
|
|
|
-// log.warn("tx2: {}", dx2);
|
|
|
-// log.warn("ty2: {}", dy2);
|
|
|
-//
|
|
|
-// log.info("========== end calculateVariable =================");
|
|
|
-// } catch (RuntimeException e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 控制点初始化作用, 只有控制点变化, 才会调用一次, 以后坐标转换都是基于这个值使用
|
|
|
-// * @param alon
|
|
|
-// * @param alat
|
|
|
-// * @param aX
|
|
|
-// * @param aY
|
|
|
-// * @param blon
|
|
|
-// * @param blat
|
|
|
-// * @param bX
|
|
|
-// * @param bY
|
|
|
+ * @param alon
|
|
|
+ * @param alat
|
|
|
+ * @param aX
|
|
|
+ * @param aY
|
|
|
+ * @param blon
|
|
|
+ * @param blat
|
|
|
+ * @param bX
|
|
|
+ * @param bY
|
|
|
*/
|
|
|
// public static void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
|
|
|
public static ControlPointCalculateEntity calculateVariable (ControlPointEntity dto){
|
|
@@ -378,12 +260,8 @@ public class GisCoordinateUtil {
|
|
|
|
|
|
double rotation2 = Math.toRadians(AffineTransform.getAngle(newPoint1 , newPoint2 ) - AffineTransform.getAngle(point1 , point2 ));
|
|
|
double scale2 = AffineTransform.getScale( newPoint1 , point1 , newPoint2 , point2);
|
|
|
-// log.info("输入参数1:{}, {}", newPoint1.getX(), newPoint1.getY());
|
|
|
-// log.info("输入参数2:{}, {}", point1.getX(), point1.getY());
|
|
|
-// log.info("输入参数 rotation2:{}, {}", rotation2);
|
|
|
-// log.info("输入参数 scale2:{}, {}", scale2);
|
|
|
-// double dx2 = AffineTransform.getXTranslation( newPoint1 ,point1, rotation2, scale1);
|
|
|
-// double dy2 = AffineTransform.getYTranslation( newPoint1 ,point1, rotation2, scale1);
|
|
|
+ log.info("scale2: {}", scale2);
|
|
|
+
|
|
|
|
|
|
// 2021-09-13 这里应该使用scale2
|
|
|
double dx2 = AffineTransform.getXTranslation( newPoint1 ,point1, rotation2, scale2);
|
|
@@ -403,16 +281,6 @@ public class GisCoordinateUtil {
|
|
|
entity.setScale2(scale2);
|
|
|
entity.setDx2(dx2);
|
|
|
entity.setDy2(dy2);
|
|
|
-// log.warn("平面坐标 start");
|
|
|
-// log.info("参数 rotation1:{}", rotation1);
|
|
|
-// log.info("参数 scale1:{}", scale1);
|
|
|
-// log.info("参数 dx1:{}", dx1);
|
|
|
-// log.info("参数 dy1:{}", dy1);
|
|
|
-// log.info("参数 rotation2:{}", rotation2);
|
|
|
-// log.info("参数 scale2:{}", scale2);
|
|
|
-// log.info("参数 dx2:{}", dx2);
|
|
|
-// log.info("参数 dy2:{}", dy2);
|
|
|
-// log.warn("平面坐标 end");
|
|
|
|
|
|
return entity;
|
|
|
} catch (RuntimeException e) {
|
|
@@ -422,23 +290,7 @@ public class GisCoordinateUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 控制点赋值,初始化
|
|
|
- */
|
|
|
-// public void initAssign(ControlPointEntity dto){
|
|
|
-// double[] controlLocation1 = dto.getAgeControlLocation1();
|
|
|
-// double[] controlLocation2 = dto.getAgeControlLocation2();
|
|
|
-//
|
|
|
-// double[] controlCoordinate1 = dto.getGpsControlCoordinate1();
|
|
|
-// double[] controlCoordinate2 = dto.getGpsControlCoordinate2();
|
|
|
-//
|
|
|
-// log.info("输入控制点1: {}, {}, {}, {}, {}, {}, {}, {}", controlCoordinate1[0], controlCoordinate1[1], controlLocation1[0], controlLocation1[1], controlCoordinate2[0], controlCoordinate2[1], controlLocation2[0], controlLocation2[1]);
|
|
|
-// GisCoordinateUtil.calculateVariable (
|
|
|
-// controlCoordinate1[0],controlCoordinate1[1],
|
|
|
-// controlLocation1[0],controlLocation1[1],
|
|
|
-// controlCoordinate2[0],controlCoordinate2[1],
|
|
|
-// controlLocation2[0],controlLocation2[1]);
|
|
|
-// }
|
|
|
+
|
|
|
|
|
|
|
|
|
|