9372cbec 张雷

人员定位代码优化修改

1 个父辈 3fd840a0
......@@ -2,13 +2,10 @@ package com.jkdata.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.jkdata.tool.CommonConstant;
import com.jkdata.tool.*;
import com.jkdata.entity.ThirdPosition;
import com.jkdata.mapper.ThirdMapper;
import com.jkdata.service.IThirdService;
import com.jkdata.tool.MD5Util;
import com.jkdata.tool.RedisUtil;
import com.jkdata.tool.UUIDGenerator;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -89,49 +86,23 @@ public class IThirdServiceImpl implements IThirdService {
//B1定位坐标
private void changCoordinateB1(ThirdPosition thirdPosition) {
Map<String,Double> map = new HashMap<>();//初始化
String x1 = thirdPosition.getPositionx();
String y1 = thirdPosition.getPositiony();
double fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X;
double fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y;
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
double a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x
double b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y
System.out.println("偏移a:"+a+",b:"+b);
double x = Double.valueOf(fd_x) + a;
double y = Double.valueOf(fd_y) + b;
System.out.println("新坐标为:X:"+x+",Y:-"+y);
//原点偏移
// double new_fd_x = 10*(Double.valueOf(x)-CommonConstant.MQ_B1_X)+CommonConstant.MQ_B1_X;
// double new_fd_y = 10*(Double.valueOf(y)+CommonConstant.MQ_B1_Y)-CommonConstant.MQ_B1_Y;
// System.out.println("新放大后的坐标为:X:"+new_fd_x+",Y:"+new_fd_y);
thirdPosition.setPositionx(String.valueOf(x));
thirdPosition.setPositiony(String.valueOf(y));
map = CoordinateUtil.changCoordinate("B1",x1,y1);
thirdPosition.setPositionx(String.valueOf(map.get("x")));
thirdPosition.setPositiony(String.valueOf(map.get("y")));
addPositionInfo(thirdPosition);//添加转换后坐标信息
}
//B2定位坐标
private void changCoordinateB2(ThirdPosition thirdPosition) {
Map<String,Double> map = new HashMap<>();//初始化
String x1 = thirdPosition.getPositionx();
String y1 = thirdPosition.getPositiony();
double fd_x = CommonConstant.BLC2*(Double.valueOf(x1)-CommonConstant.LT_B2_X)+CommonConstant.LT_B2_X;
double fd_y = CommonConstant.BLC2*(Double.valueOf(y1)+CommonConstant.LT_B2_Y)-CommonConstant.LT_B2_Y;
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
double a = CommonConstant.MQ_B2_X - CommonConstant.LT_B2_X;//原点偏移x
double b = CommonConstant.MQ_B2_Y - CommonConstant.LT_B2_Y;//原点偏移y
System.out.println("偏移a:"+a+",b:"+b);
double x = Double.valueOf(fd_x) + a;
double y = Double.valueOf(fd_y) + b;
System.out.println("新坐标为:X:"+x+",Y:-"+y);
thirdPosition.setPositionx(String.valueOf(x));
thirdPosition.setPositiony(String.valueOf(y));
map = CoordinateUtil.changCoordinate("B2",x1,y1);
thirdPosition.setPositionx(String.valueOf(map.get("x")));
thirdPosition.setPositiony(String.valueOf(map.get("y")));
addPositionInfo(thirdPosition);//添加转换后坐标信息
}
......@@ -214,7 +185,7 @@ public class IThirdServiceImpl implements IThirdService {
@Override
public String getSafeArea() {
String get = HttpUtil.get(CommonConstant.SAFE_AREA_URL+"?buildingId=10");
String get = HttpUtil.get(CommonConstant.SAFE_AREA_URL+"?buildingId="+CommonConstant.BLD_ID);
return get;
}
......
package com.jkdata.tool;
import java.util.HashMap;
import java.util.Map;
public class CoordinateUtil {
public static Map<String,Double> changCoordinate (String floor, String x1, String y1){
Map<String,Double> map = new HashMap<>();//初始化
map.put("x", 0.00);
map.put("y", 0.00);
double fd_x = 0.00;//放大的X坐标
double fd_y = 0.00;//放大的Y坐标
double a = 0.00;//X偏移量
double b = 0.00;//Y偏移量
if("B2".equals(floor)){
fd_x = CommonConstant.BLC2*(Double.valueOf(x1)-CommonConstant.LT_B2_X)+CommonConstant.LT_B2_X;
fd_y = CommonConstant.BLC2*(Double.valueOf(y1)+CommonConstant.LT_B2_Y)-CommonConstant.LT_B2_Y;
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
a = CommonConstant.MQ_B2_X - CommonConstant.LT_B2_X;//原点偏移x
b = CommonConstant.MQ_B2_Y - CommonConstant.LT_B2_Y;//原点偏移y
System.out.println("偏移a:"+a+",b:"+b);
}else if("B1".equals(floor)){
fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X;
fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y;
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x
b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y
System.out.println("偏移a:"+a+",b:"+b);
}else{
fd_x = 0.00;
fd_y = 0.00;
a = 0.00;
b = 0.00;
}
double x = Double.valueOf(fd_x) + a;
double y = Double.valueOf(fd_y) + b;
System.out.println("新坐标为:X:"+x+",Y:-"+y);
map.put("x",x);
map.put("y",y);
return map;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!