From 21e0b93688de2a98abe3b7b9c0cfed6efdc21183 Mon Sep 17 00:00:00 2001
From: zhitong.yu <xynz17@163.com>
Date: 星期五, 27 十二月 2024 17:31:32 +0800
Subject: [PATCH] 通用版本V2.0 修复被检测漏洞
---
src/main/java/com/hxzk/controller/SystemController.java | 365 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 311 insertions(+), 54 deletions(-)
diff --git a/src/main/java/com/hxzk/controller/SystemController.java b/src/main/java/com/hxzk/controller/SystemController.java
index 8017658..37a20f5 100644
--- a/src/main/java/com/hxzk/controller/SystemController.java
+++ b/src/main/java/com/hxzk/controller/SystemController.java
@@ -1,6 +1,10 @@
package com.hxzk.controller;
+
+import Jama.Matrix;
+import Jama.SingularValueDecomposition;
import cn.hutool.json.JSONObject;
+import cn.hx.tools;
import com.hxzk.pojo.TbSystem;
import com.hxzk.pojo.tb_jingwei;
import com.hxzk.service.SystemService;
@@ -18,18 +22,20 @@
import java.util.Date;
import java.util.List;
+import static cn.hx.tools.dd2ddmm;
+
+
@RestController
@RequestMapping("/")
public class SystemController {
- static double e2;
- static double e4;
- static double e6;
- static double E0;
- static double N0;
-
- static double a = 6378.137;
- static double e = 0.0818192;
- static double k0 = 0.9996;
+ static double a=6378.137;//鍦扮悆鍗婂緞
+ static double e=0.0818192;//鍦扮悆鏇茬巼
+ static double k0=0.9996;
+ static double e2=e*e;//e鐨勫钩鏂�
+ static double e4=e2*e2;//e鐨�4娆℃柟
+ static double e6=e4*e2;//e鐨�6娆℃柟
+ static double E0=500;
+ static double N0=0;
@Autowired
SystemService systemService;
@@ -43,7 +49,25 @@
systemService.updaping(baoliu28);
}
+ @GetMapping({"ddmm2d"})
+ public String dfConversion(String df) {
+ return tools.ddmm2d(df);
+ }
+ @GetMapping({"dd2ddmm"})
+ public String dudegreeConversion(String du) {
+ return tools.dd2ddmm(du);
+ }
+
+ @GetMapping({"toplane"})
+ public String zuobiao(String posPlane, String posPointCloud, String posPointCloudCheck) {
+ return toplane(posPlane, posPointCloud, posPointCloudCheck);
+ }
+
+ @GetMapping({"gnssToxy"})
+ public String[] coordinate(String gnssa, String gnssb, String gnsslat, String gnsslog) {
+ return tools.gnssToxy(gnssa, gnssb, gnsslat, gnsslog);
+ }
public String gettime(){
Date now = new Date();
// 鍒涘缓鏃ユ湡鏍煎紡鍖栧璞★紝璁剧疆鏍煎紡涓� "yyyy-MM-dd HH:mm"
@@ -53,6 +77,7 @@
return formattedDate;
}
+
@RequestMapping(value = {"jingweijuli.do"}, method = {RequestMethod.POST, RequestMethod.GET})
public ModelAndView tojisuan1(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
@@ -106,10 +131,40 @@
@ResponseBody
@RequestMapping(value = {"jisuanjingwei.do"}, method = {RequestMethod.POST, RequestMethod.GET})
- public JSONObject jisuanjingwei(String str) {
+ public static JSONObject jisuanjingwei(String str) {
+
+// 3954.4464;11618.4476;3954.4464;11624.969
JSONObject json = new JSONObject();
String disab = disab(str);
- String[] split = str.split(";");
+ String[] split = str.split("");
+ String qishi = split[1] + "/" + split[0];
+ String zhongzhi = split[3] + "/" + split[2];
+ tb_jingwei jingwei = new tb_jingwei();
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String format = simpleDateFormat.format(new Date());
+ jingwei.setQishi(qishi);
+ jingwei.setZhongzhi(zhongzhi);
+ jingwei.setJieguo(disab);
+ jingwei.setAddtime(format);
+ json.put("jieguo", disab);
+ return json;
+
+ }
+
+ @ResponseBody
+ @RequestMapping(
+ value = {"jisuanbaowen.do"},
+ method = {RequestMethod.POST, RequestMethod.GET}
+ )
+ public static JSONObject jisuanbaowen(String gnggA, String gnggB) {
+ String weiduA = gnggA.split(",")[2];
+ String jingduA = gnggA.split(",")[4];
+ String weiduB = gnggB.split(",")[2];
+ String jingduB = gnggB.split(",")[4];
+ String str = weiduA + ";" + jingduA + ";" + weiduB + ";" + jingduB;
+ JSONObject json = new JSONObject();
+ String disab = disab(str);
+ String[] split = str.split("");
String qishi = split[1] + "/" + split[0];
String zhongzhi = split[3] + "/" + split[2];
tb_jingwei jingwei = new tb_jingwei();
@@ -124,6 +179,48 @@
}
+ @ResponseBody
+ @RequestMapping(value = {"jisuandubaowen.do"}, method = {RequestMethod.POST, RequestMethod.GET})
+ public static JSONObject jisuandubaowen(String dugnggA ,String dugnggB) {
+ String weiduA = dd2ddmm(dugnggA.split(";")[0]);
+ String jingduA = dd2ddmm(dugnggA.split(";")[1]);
+ String weiduB = dd2ddmm(dugnggB.split(";")[0]);
+ String jingduB = dd2ddmm(dugnggB.split(";")[1]);
+
+// String weiduA = gnggA.split(",")[2];
+// String jingduA = gnggA.split(",")[4];
+// String weiduB = gnggB.split(",")[2];
+// String jingduB = gnggB.split(",")[4];
+ String str = weiduA + ";" + jingduA + ";" + weiduB + ";" + jingduB;
+ JSONObject json = new JSONObject();
+ String disab = disab(str);
+ String[] split = str.split("");
+ String qishi = split[1] + "/" + split[0];
+ String zhongzhi = split[3] + "/" + split[2];
+ tb_jingwei jingwei = new tb_jingwei();
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String format = simpleDateFormat.format(new Date());
+ jingwei.setQishi(qishi);
+ jingwei.setZhongzhi(zhongzhi);
+ jingwei.setJieguo(disab);
+ jingwei.setAddtime(format);
+ json.put("jieguo", disab);
+ return json;
+ }
+
+
+ @PostMapping({"HouTai"})
+ public ModelAndView HouTai(String username) {
+ ModelAndView modelAndView = new ModelAndView();
+ if (username != null) {
+ modelAndView.setViewName("/HouTai/HouTai.jsp");
+ } else {
+ modelAndView.setViewName("/index.jsp");
+ }
+
+ return modelAndView;
+ }
+
public static String todufen(String Du, String Fen, String Miao) {
@@ -143,20 +240,44 @@
return a;
}
+
public static String disab(String jwd) {
+ System.out.println("鎵撳嵃鏁版嵁============銆嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨��");
DecimalFormat df = new DecimalFormat("0.00");
String[] bb = jwd.split(";");
double jd0 = Double.parseDouble(bb[1]);
double wd0 = Double.parseDouble(bb[0]);
double jd1 = Double.parseDouble(bb[3]);
double wd1 = Double.parseDouble(bb[2]);
- double[] a = run_gps2xyurt(wd0, jd0, wd1, jd1);
- double disa = a[0] * a[0] + a[1] * a[1];
- double dis = Math.sqrt(Math.abs(disa)) * 100.0;
- String temp = df.format(dis);
+// double[] a = run_gps2xyurt(wd0, jd0, wd1, jd1);
+// double disa = a[0] * a[0] + a[1] * a[1];
+// double dis = Math.sqrt(Math.abs(disa)) * 100.0;
+// String temp = df.format(dis);
+
+// double num1 = Double.parseDouble(jd0);
+// double num2 = Double.parseDouble(gnssb);
+// double num3 = Double.parseDouble(gnsslat);
+// double num4 = Double.parseDouble(gnsslog);
+ String temp = distance2(jd0,wd0,jd1,wd1);
+ System.out.println(jwd + "鐨勮窛绂绘槸锛�" + temp);
+// return distance2(jd0,wd0,jd1,wd1);
return temp;
}
+ // public static String disab(String jwd) {
+ // DecimalFormat df = new DecimalFormat("0.00");
+ // String[] bb = jwd.split(";");
+ // double jd0 = Double.parseDouble(bb[1]);
+ // double wd0 = Double.parseDouble(bb[0]);
+ // double jd1 = Double.parseDouble(bb[3]);
+ // double wd1 = Double.parseDouble(bb[2]);
+ // double[] a = run_gps2xyurt(wd0, jd0, wd1, jd1);
+ // double disa = a[0] * a[0] + a[1] * a[1];
+ // double dis = Math.sqrt(Math.abs(disa)) * 100.0;
+ // String temp = df.format(dis);
+ // return temp;
+ // }
+
public static double[] run_gps2xyurt(double lat0, double lon0, double lat, double lon) {
int[] realxy = new int[2];
double[] xycs = initiize_ublox_zeropoint(lat0, lon0, 0.0);
@@ -171,59 +292,195 @@
xy[1] = s * x + c * y;
return xy;
}
- public static double[] initiize_ublox_zeropoint(double lat, double lon, double th) {
- double[] xycs = new double[]{ubloxraw2xy(lat, lon)[0], ubloxraw2xy(lat, lon)[1], 0.0, 0.0};
- double th1 = th * Math.PI / 180.0;
- xycs[2] = Math.cos(th1);
- xycs[3] = Math.sin(th1);
- return xycs;
+ public static String toplane(String posPlane1, String posPointCloud1, String posPointCloudCheck1) {
+ double[][] posPlane = string2doubleArr(posPlane1, 1);
+ double[][] posPointCloud = string2doubleArr(posPointCloud1, 100);
+ double[][] posPointCloudCheck = string2doubleArr(posPointCloudCheck1, 100);
+ String returnDate = "";
+ double[][] var7 = posPlane;
+ int var8 = posPlane.length;
+
+ for(int var9 = 0; var9 < var8; ++var9) {
+ double[] row = var7[var9];
+ row[1] = -row[1];
+ }
+
+ Matrix A = new Matrix(posPlane);
+ Matrix B = new Matrix(posPointCloud);
+ Matrix C = new Matrix(posPointCloudCheck);
+ Matrix[] matrices = rigidTransform3D(A, B);
+ if (matrices == null) {
+ return "閫夌偣鏈夐棶棰�,璇烽噸鏂伴�夌偣";
+ } else {
+ Matrix R = matrices[0];
+ Matrix T = matrices[1];
+ Matrix posPlaneCheckCalc = R.transpose().times(C.transpose().minus(T));
+ Matrix transpose = posPlaneCheckCalc.transpose();
+ double[][] transposeArray = transpose.getArray();
+
+ for(int i = 0; i < transposeArray.length; ++i) {
+ for(int j = 0; j < transposeArray[0].length; ++j) {
+ double v = 0.0;
+ if (j == 1) {
+ v = -transposeArray[i][j];
+ } else {
+ v = transposeArray[i][j];
+ }
+
+ returnDate = returnDate + v + ";";
+ }
+ }
+
+ return returnDate;
+ }
}
+ public static Matrix[] rigidTransform3D(Matrix A, Matrix B) {
+ Matrix centroid_A = mean(A);
+ Matrix centroid_B = mean(B);
+ int N = A.getRowDimension();
+ Matrix H = A.minus(repmat(centroid_A, N, 1)).transpose().times(B.minus(repmat(centroid_B, N, 1)));
+ SingularValueDecomposition svd = H.svd();
+ Matrix U = svd.getU();
+ Matrix S = svd.getS();
+ Matrix V = svd.getV();
+ Matrix R = V.times(U.transpose());
+ if (R.det() < 0.0) {
+ return null;
+ } else {
+ Matrix T = R.times(centroid_A.transpose()).times(-1.0).plus(centroid_B.transpose());
+ return new Matrix[]{R, T};
+ }
+ }
+
+ private static Matrix mean(Matrix matrix) {
+ int m = matrix.getRowDimension();
+ int n = matrix.getColumnDimension();
+ double[] columnMeans = new double[n];
+
+ for(int j = 0; j < n; ++j) {
+ for(int i = 0; i < m; ++i) {
+ columnMeans[j] += matrix.get(i, j);
+ }
+
+ columnMeans[j] /= (double)m;
+ }
+
+ return (new Matrix(columnMeans, n)).transpose();
+ }
+
+ private static Matrix repmat(Matrix matrix, int N, int M) {
+ Matrix result = new Matrix(N, M * matrix.getColumnDimension());
+
+ for(int i = 0; i < N; ++i) {
+ result.setMatrix(i, i, 0, matrix.getColumnDimension() - 1, matrix);
+ }
+
+ return result;
+ }
+
+ private static double[][] string2doubleArr(String input, int num) {
+ String[] rows = input.split(";");
+ double[][] result = new double[rows.length][];
+
+ for(int i = 0; i < rows.length; ++i) {
+ String[] columns = rows[i].trim().split(",\\s*");
+ result[i] = new double[columns.length];
+
+ for(int j = 0; j < columns.length; ++j) {
+ result[i][j] = Double.parseDouble(columns[j]) * (double)num;
+ }
+ }
+
+ return result;
+ }
+
+ public static String distance2(double lon_y0, double lat_x0, double lon, double lat) {
+ double[] xycs = initiize_ublox_zeropoint(lat_x0, lon_y0, 0.0);
+ double x0 = xycs[0];
+ double y0 = xycs[1];
+ double c = xycs[2];
+ double s = xycs[3];
+ double[] xy = new double[2];
+ double x = ubloxraw2xy(lat, lon)[0] - x0;
+ double y = ubloxraw2xy(lat, lon)[1] - y0;
+ xy[0] = c * x - s * y;
+ xy[1] = s * x + c * y;
+ double disd = Math.sqrt(xy[0] * xy[0] + xy[1] * xy[1]) * 100.0;
+ return disd + "";
+ }
public static double[] ubloxraw2xy(double lat, double lon) {
- double[] xy = new double[3];
+ double[] xy=new double[3];
double lond = ublox_dm2d(lon);
double latd = ublox_dm2d(lat);
double[] dxy = utm(latd, lond);
- xy[0] = dxy[0] * 1000.0;
- xy[1] = dxy[1] * 1000.0;
- xy[2] = dxy[2];
+ xy[0]= dxy[0]* 1000;
+ xy[1]= dxy[1]* 1000;
+ xy[2]= dxy[2];
return xy;
+
}
+ /**鍒濆鍖栧師鐐逛綅缃拰鏂瑰悜
+ * 杈撳嚭鍘熺偣浠ョ背涓哄崟浣嶇殑xy鍧愭爣, cos鍊�, sin鍊�*/
+ public static double[] initiize_ublox_zeropoint(double lat, double lon, double th){
+ double[] xycs=new double[4];
+ xycs[0]=ubloxraw2xy(lat,lon)[0];
+ xycs[1]=ubloxraw2xy(lat,lon)[1];
+ double th1=th*Math.PI/180;//x杞翠笌姝e寳鏂瑰悜澶硅th(鍗曚綅鏄害)
+ xycs[2]=Math.cos(th1);
+ xycs[3]=Math.sin(th1);
+ return xycs;
+ }
+
+ /**杈撳叆ublox鐨勫害鍒嗙粡绾害锛岃緭鍑簒y,鍗曚綅绫�*/
public static double ublox_dm2d(double ddmm_dot_m) {
- double d0 = Math.floor(ddmm_dot_m / 100.0);
- double d = d0 + (ddmm_dot_m - d0 * 100.0) / 60.0;
+ double d0=Math.floor(ddmm_dot_m/100);//鍙栨暣
+ double d=d0+(ddmm_dot_m-d0*100)/60;
return d;
}
- public static double[] utm(double lat, double lon) {
- double[] dxy = new double[3];
- double zonenum1 = lon / 6.0;
- if (zonenum1 > 0.0) {
- zonenum1 = Math.floor(zonenum1);
- } else {
- zonenum1 = Math.ceil(zonenum1);
+ public static double[] utm(double lat,double lon) {
+ double[] dxy=new double[3];
+
+ double zonenum1=lon/6;
+ //floor鏄湴鏉跨殑鎰忔�濓紝琛ㄧず鍚戜笅鍙栨暣
+ if(zonenum1>0) {
+ zonenum1=Math.floor(zonenum1);
+ }else {//鍚戜笂鍙栨暣
+ zonenum1=Math.ceil(zonenum1);//鍚戜笂鍙栨暣
}
- double Zonenum = zonenum1 + 31.0;
- double lambda0 = ((Zonenum - 1.0) * 6.0 - 180.0 + 3.0) * Math.PI / 180.0;
- double phi = lat * Math.PI / 180.0;
- double lambda = lon * Math.PI / 180.0;
- double v = 1.0 / Math.sqrt(1.0 - e2 * Math.pow(Math.sin(phi), 2.0));
- double A = (lambda - lambda0) * Math.cos(phi);
- double A2 = A * A;
- double A3 = A2 * A;
- double A4 = A3 * A;
- double A5 = A4 * A;
- double A6 = A5 * A;
- double T = Math.tan(phi) * Math.tan(phi);
- double T2 = T * T;
- double C = e2 * Math.cos(phi) * Math.cos(phi) / (1.0 - e2);
- double C2 = C * C;
- double s = (1.0 - e2 / 4.0 - 3.0 * e4 / 64.0 - 5.0 * e6 / 256.0) * phi - (3.0 * e2 / 8.0 + 3.0 * e4 / 32.0 + 45.0 * e6 / 1024.0) * Math.sin(2.0 * phi) + (15.0 * e4 / 256.0 + 45.0 * e6 / 1024.0) * Math.sin(4.0 * phi) - 35.0 * e6 / 3072.0 * Math.sin(6.0 * phi);
- dxy[0] = E0 + k0 * a * v * (A + (1.0 - T + C) * A3 / 6.0 + (5.0 - 18.0 * T + T2) * A5 / 120.0);
- dxy[1] = N0 + k0 * a * (s + v * Math.tan(phi) * (A2 / 2.0 + (5.0 - T + 9.0 * C + 4.0 * C2) * A4 / 24.0 + (61.0 - 58.0 * T + T2) * A6 / 720.0));
- dxy[2] = Zonenum;
+ double Zonenum=zonenum1+31;
+
+ double lambda0=((Zonenum-1)*6-180+3)*(Math.PI)/180;
+
+ double phi=lat*(Math.PI)/180;
+
+ double lambda=lon*(Math.PI)/180;
+
+ double v=1/Math.sqrt((1-e2*Math.pow(Math.sin(phi),2)));
+
+ double A=(lambda-lambda0)* Math.cos(phi);
+ double A2=A*A;
+ double A3=A2*A;
+ double A4=A3*A;
+ double A5=A4*A;
+ double A6=A5*A;
+
+ double T=Math.tan(phi)* Math.tan(phi);
+ double T2=T*T;
+
+ double C=e2* Math.cos(phi)* Math.cos(phi)/(1-e2);
+ double C2=C*C;
+
+ double s=(1-e2/4-3*e4/64-5*e6/256)* phi-
+ (3*e2/8+3*e4/32+45*e6/1024)* Math.sin(2*phi)+
+ (15*e4/256+45*e6/1024)* Math.sin(4* phi)-35*e6/3072* Math.sin(6*phi);
+
+ dxy[0]=E0+k0*a*v*(A+(1-T+C)*A3/6+(5-18*T+T2)*A5/120);
+
+ dxy[1]=N0+k0*a*(s+v* Math.tan(phi)*(A2/2+(5-T+9*C+4*C2)*A4/24+(61-58*T+T2)*A6/720));
+ dxy[2]=Zonenum;
return dxy;
}
-
}
--
Gitblit v1.10.0