|
@@ -47,19 +47,27 @@ public class GisCoordinateUtil {
|
|
|
* @param loctionY
|
|
|
* @return
|
|
|
*/
|
|
|
-// public static double[] transformLocationToBL(double loctionX,double loctionY){
|
|
|
-// Point point = new Point(loctionX,loctionY);
|
|
|
-// log.warn("本地转经纬度 平面 start ====");
|
|
|
-// log.info("参数 rotation:{}", rotation2);
|
|
|
-// log.info("参数 scale:{}", scale2);
|
|
|
-// log.info("参数 tx:{}", dx2);
|
|
|
-// log.info("参数 ty:{}", dy2);
|
|
|
-// Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation2, scale2, dx2, dy2);
|
|
|
-// log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
|
|
|
-// log.warn("本地转经纬度 平面 end ====");
|
|
|
-// return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
|
|
|
-// }
|
|
|
+ public static double[] transformLocationToBL(double loctionX,double loctionY){
|
|
|
+ Point point = new Point(loctionX,loctionY);
|
|
|
+ log.warn("本地转经纬度 平面 start ====");
|
|
|
+ log.info("参数 rotation:{}", rotation2);
|
|
|
+ log.info("参数 scale:{}", scale2);
|
|
|
+ log.info("参数 tx:{}", dx2);
|
|
|
+ log.info("参数 ty:{}", dy2);
|
|
|
+ Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation2, scale2, dx2, dy2);
|
|
|
+ log.info("本地坐标转平面坐标输出结果:{}, {}", resultPoint.getX(),resultPoint.getY());
|
|
|
+ log.warn("本地转经纬度 平面 end ====");
|
|
|
+ return GisCoordinateTransform.convertByProj4(resultPoint.getX(),resultPoint.getY(),"EPSG:4547","EPSG:4490");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ /**
|
|
|
+ * 本地坐标转经纬度
|
|
|
+ * 这里可以获取平面坐标, 结果是很大的
|
|
|
+ * @param loctionX
|
|
|
+ * @param loctionY
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public static double[] transformLocationToBL(double loctionX,double loctionY, ControlPointCalculateEntity dto){
|
|
|
Point point = new Point(loctionX,loctionY);
|
|
|
log.warn("本地转经纬度 平面 start ====");
|
|
@@ -80,17 +88,17 @@ public class GisCoordinateUtil {
|
|
|
* @param lat 纬度 十进制度
|
|
|
* @return
|
|
|
*/
|
|
|
-// public static double[] transformBLToLocation(double lon,double lat){
|
|
|
-// double[] gauss= GisCoordinateTransform.convertByProj4(lon, lat,"EPSG:4490","EPSG:4547");
|
|
|
-// log.info("经纬度转本地坐标,大地坐标:{}, {}", gauss[0],gauss[1]);
|
|
|
-// Point point = new Point(gauss[0],gauss[1]);
|
|
|
-// Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation1, scale1, dx1, dy1);
|
|
|
-//
|
|
|
-// double[] location=new double[2];
|
|
|
-// location[0]=resultPoint.getX();
|
|
|
-// location[1]=resultPoint.getY();
|
|
|
-// return location;
|
|
|
-// }
|
|
|
+ public static double[] transformBLToLocation(double lon,double lat){
|
|
|
+ double[] gauss= GisCoordinateTransform.convertByProj4(lon, lat,"EPSG:4490","EPSG:4547");
|
|
|
+ log.info("经纬度转本地坐标,大地坐标:{}, {}", gauss[0],gauss[1]);
|
|
|
+ Point point = new Point(gauss[0],gauss[1]);
|
|
|
+ Point resultPoint = AffineTransform.transformBoePoint(new Point(point.getX(), point.getY()), rotation1, scale1, dx1, dy1);
|
|
|
+
|
|
|
+ double[] location=new double[2];
|
|
|
+ location[0]=resultPoint.getX();
|
|
|
+ location[1]=resultPoint.getY();
|
|
|
+ return location;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public static double[] transformBLToLocation(double lon,double lat, ControlPointCalculateEntity dto){
|
|
@@ -112,52 +120,52 @@ public class GisCoordinateUtil {
|
|
|
*
|
|
|
* @param controlPointsFileUrl 控制点文件路径
|
|
|
*/
|
|
|
- public static void parseControlPointsFile(String controlPointsFileUrl) {
|
|
|
- String jsonStr = "";
|
|
|
- try {
|
|
|
- File file = new File(controlPointsFileUrl);
|
|
|
- FileReader fileReader = new FileReader(file);
|
|
|
- Reader reader = new InputStreamReader(new FileInputStream(file), "Utf-8");
|
|
|
- int ch = 0;
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- while ((ch = reader.read()) != -1) {
|
|
|
- sb.append((char) ch);
|
|
|
- }
|
|
|
- fileReader.close();
|
|
|
- reader.close();
|
|
|
- jsonStr = sb.toString();
|
|
|
- parseJSON(jsonStr);
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("文件内部格式错误!");
|
|
|
- }
|
|
|
- }
|
|
|
+// public static void parseControlPointsFile(String controlPointsFileUrl) {
|
|
|
+// String jsonStr = "";
|
|
|
+// try {
|
|
|
+// File file = new File(controlPointsFileUrl);
|
|
|
+// FileReader fileReader = new FileReader(file);
|
|
|
+// Reader reader = new InputStreamReader(new FileInputStream(file), "Utf-8");
|
|
|
+// int ch = 0;
|
|
|
+// StringBuffer sb = new StringBuffer();
|
|
|
+// while ((ch = reader.read()) != -1) {
|
|
|
+// sb.append((char) ch);
|
|
|
+// }
|
|
|
+// fileReader.close();
|
|
|
+// reader.close();
|
|
|
+// jsonStr = sb.toString();
|
|
|
+// parseJSON(jsonStr);
|
|
|
+// } catch (Exception e) {
|
|
|
+// System.out.println("文件内部格式错误!");
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
- /**
|
|
|
- * 解析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);
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 解析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);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|