增加网格坐标转换test代码
This commit is contained in:
parent
fce4568d81
commit
b5e2f02b3a
@ -2,6 +2,9 @@ package cn.com.tenlion.usercenter;
|
||||
|
||||
import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO;
|
||||
import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import ink.wgink.util.LatLngTransformUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -9,6 +12,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -30,4 +34,46 @@ class SmartCityUsercenterApplicationTests {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String baseDir = "/Users/wanggeng/Desktop/";
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(new File(baseDir + "/gridPoint.json")));
|
||||
StringBuilder sourceJsonArraySB = new StringBuilder();
|
||||
for (String line; (line = bufferedReader.readLine()) != null; ) {
|
||||
sourceJsonArraySB.append(line);
|
||||
}
|
||||
JSONArray sourceJsonArray = JSONArray.parseArray(sourceJsonArraySB.toString());
|
||||
JSONArray map84GridJsonArray = new JSONArray();
|
||||
// 遍历
|
||||
for (int i = 0; i < sourceJsonArray.size(); i++) {
|
||||
JSONObject gridJSONObject = sourceJsonArray.getJSONObject(i);
|
||||
JSONObject map84GridJSONObject = new JSONObject();
|
||||
map84GridJSONObject.put("areaCode", gridJSONObject.getString("areaCode"));
|
||||
map84GridJSONObject.put("areaName", gridJSONObject.getString("areaName"));
|
||||
map84GridJSONObject.put("fillColor", gridJSONObject.getString("fillColor"));
|
||||
map84GridJSONObject.put("gridCode", gridJSONObject.getString("gridCode"));
|
||||
map84GridJSONObject.put("gridName", gridJSONObject.getString("gridName"));
|
||||
map84GridJSONObject.put("gridId", gridJSONObject.getString("gridId"));
|
||||
|
||||
JSONArray pointArray = gridJSONObject.getJSONArray("pointArray");
|
||||
JSONArray map84PointArray = new JSONArray();
|
||||
for (int j = 0; j < pointArray.size(); j++) {
|
||||
JSONObject point = pointArray.getJSONObject(j);
|
||||
double lat = point.getDoubleValue("lat");
|
||||
double lng = point.getDoubleValue("lng");
|
||||
double[] latLng = LatLngTransformUtil.bd09_To_gps84(lat, lng);
|
||||
|
||||
JSONObject map84Point = new JSONObject();
|
||||
map84Point.put("lat", String.valueOf(latLng[0]));
|
||||
map84Point.put("lng", String.valueOf(latLng[1]));
|
||||
map84PointArray.add(map84Point);
|
||||
}
|
||||
|
||||
map84GridJSONObject.put("pointArray", map84PointArray);
|
||||
|
||||
map84GridJsonArray.add(map84GridJSONObject);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(map84GridJsonArray.toJSONString());
|
||||
System.out.println(sb);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user