CoordinateUtil.java
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
a = CommonConstant.MQ_B2_X - CommonConstant.LT_B2_X;//原点偏移x
b = CommonConstant.MQ_B2_Y - CommonConstant.LT_B2_Y;//原点偏移y
}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;
a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x
b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y
}else{
fd_x = 0.00;
fd_y = 0.00;
a = 0.00;
b = 0.00;
}
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_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);
map.put("x",x);
map.put("y",y);
return map;
}
}