|
@@ -6,6 +6,8 @@ import com.skyversation.poiaddr.addquery.AddressQueryEngine;
|
|
|
import com.skyversation.poiaddr.addquery.Constant;
|
|
|
import com.skyversation.poiaddr.bean.AddressResult;
|
|
|
import com.skyversation.poiaddr.bean.GeoJsonBean;
|
|
|
+import com.skyversation.poiaddr.entity.AmapAddressV3;
|
|
|
+import com.skyversation.poiaddr.service.AreaService;
|
|
|
import org.geotools.geojson.geom.GeometryJSON;
|
|
|
import org.geotools.geometry.jts.JTSFactoryFinder;
|
|
|
import org.locationtech.jts.geom.Geometry;
|
|
@@ -301,7 +303,7 @@ public class AddressTools {
|
|
|
* @return 上海市,松江区,车墩镇,乐都路590号
|
|
|
*/
|
|
|
public static String[] parseAddressJZ(String address) {
|
|
|
- if(!StringUtils.hasText(address)){
|
|
|
+ if (!StringUtils.hasText(address)) {
|
|
|
return null;
|
|
|
}
|
|
|
String[] result = new String[4];
|
|
@@ -569,6 +571,39 @@ public class AddressTools {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // TODO 将请求返回的市中心结果入库到pgsql中
|
|
|
+ List<AmapAddressV3> amapAddressV3List = new ArrayList<>();
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ JSONObject item = array.getJSONObject(i);
|
|
|
+ AmapAddressV3 amapAddressV3 = new AmapAddressV3();
|
|
|
+ amapAddressV3.setId(UUID.randomUUID().toString());
|
|
|
+ amapAddressV3.setName(item.get("name").toString());
|
|
|
+ amapAddressV3.setType("测绘院结果");
|
|
|
+ amapAddressV3.setAddress(item.get("address").toString());
|
|
|
+ JSONObject localtion = item.getJSONObject("location");
|
|
|
+ Double wgs84Lng = localtion.getDouble("lng");
|
|
|
+ Double wgs84Lat = localtion.getDouble("lat");
|
|
|
+ double[] points2 = CoordTransform2.getInstance().wgs84ToShcj(wgs84Lng, wgs84Lat);
|
|
|
+ double[] points = CoordTransform2.getInstance().wgs84_to_gcj02(wgs84Lng, wgs84Lat);
|
|
|
+ amapAddressV3.setLocation(points[0] + "," + points[1]);
|
|
|
+ amapAddressV3.setLon(String.valueOf(points2[0]));
|
|
|
+ amapAddressV3.setLat(String.valueOf(points2[1]));
|
|
|
+ amapAddressV3.setCreateTime(new Date());
|
|
|
+ if (item.containsKey("ext_data")) {
|
|
|
+ JSONObject ext_data = item.getJSONObject("ext_data");
|
|
|
+ if (!ext_data.get("region_ss").toString().isEmpty()) {
|
|
|
+ amapAddressV3.setPname(ext_data.get("region_ss").toString());
|
|
|
+ amapAddressV3.setCityname(ext_data.get("region_ss").toString());
|
|
|
+ amapAddressV3.setAdname(item.get("region_qx").toString());
|
|
|
+ amapAddressV3.setStreetTTown(item.get("region_jd").toString());
|
|
|
+ amapAddressV3.setResidentialCommittee(item.get("region_jw").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ amapAddressV3List.add(amapAddressV3);
|
|
|
+ }
|
|
|
+ if (amapAddressV3List.size() > 0) {
|
|
|
+ AreaService.getInstance().saveAmapAddressV3(amapAddressV3List);
|
|
|
+ }
|
|
|
return bestMatch;
|
|
|
}
|
|
|
|
|
@@ -735,7 +770,7 @@ public class AddressTools {
|
|
|
/***
|
|
|
* 初始化上海市84坐标系下的,区划、街镇、村居矢量数据
|
|
|
*/
|
|
|
- public void initSHQH(){
|
|
|
+ public void initSHQH() {
|
|
|
List<List<GeoJsonBean>> lis = new ArrayList<>();
|
|
|
lis.add(qxPolygonList);
|
|
|
lis.add(jzPolygonList);
|
|
@@ -757,8 +792,8 @@ public class AddressTools {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void initPolygon(String[] path, List<List<GeoJsonBean>> list){
|
|
|
- for(int j = 0; j < path.length; j ++){
|
|
|
+ private void initPolygon(String[] path, List<List<GeoJsonBean>> list) {
|
|
|
+ for (int j = 0; j < path.length; j++) {
|
|
|
BufferedReader br = null;
|
|
|
try {
|
|
|
File file = ResourceUtils.getFile(path[j]);
|
|
@@ -773,7 +808,7 @@ public class AddressTools {
|
|
|
|
|
|
JSONArray featrues = json.getJSONArray("features");
|
|
|
|
|
|
- for(int i = 0; i < featrues.size(); i ++){
|
|
|
+ for (int i = 0; i < featrues.size(); i++) {
|
|
|
Map<String, GeoJsonBean> map = new HashMap<>();
|
|
|
JSONObject properties = featrues.getJSONObject(i).getJSONObject("properties");
|
|
|
JSONObject geoJson = new JSONObject();
|
|
@@ -797,7 +832,7 @@ public class AddressTools {
|
|
|
System.out.println("<<<<<<<<------ 初始化行政区划完成 ------>>>>>>>>>");
|
|
|
}
|
|
|
|
|
|
- public JSONObject isQXInPolygon(double lon, double lat){
|
|
|
+ public JSONObject isQXInPolygon(double lon, double lat) {
|
|
|
Geometry point = null;
|
|
|
try {
|
|
|
point = reader.read("POINT (" + lon + " " + lat + ")");
|
|
@@ -805,8 +840,8 @@ public class AddressTools {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
- for(GeoJsonBean bean : qxPolygonList){
|
|
|
- if(bean.getMultiPolygon().contains(point)){
|
|
|
+ for (GeoJsonBean bean : qxPolygonList) {
|
|
|
+ if (bean.getMultiPolygon().contains(point)) {
|
|
|
return bean.getProperties();
|
|
|
}
|
|
|
}
|
|
@@ -814,7 +849,7 @@ public class AddressTools {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public JSONObject isJZInPolygon(double lon, double lat){
|
|
|
+ public JSONObject isJZInPolygon(double lon, double lat) {
|
|
|
Geometry point = null;
|
|
|
try {
|
|
|
point = reader.read("POINT (" + lon + " " + lat + ")");
|
|
@@ -822,15 +857,15 @@ public class AddressTools {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
- for(GeoJsonBean bean : jzPolygonList){
|
|
|
- if(bean.getMultiPolygon().contains(point)){
|
|
|
+ for (GeoJsonBean bean : jzPolygonList) {
|
|
|
+ if (bean.getMultiPolygon().contains(point)) {
|
|
|
return bean.getProperties();
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public JSONObject isCJInPolygon(double lon, double lat){
|
|
|
+ public JSONObject isCJInPolygon(double lon, double lat) {
|
|
|
Geometry point = null;
|
|
|
try {
|
|
|
point = reader.read("POINT (" + lon + " " + lat + ")");
|
|
@@ -838,15 +873,15 @@ public class AddressTools {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
- for(GeoJsonBean bean : cjPolygonList){
|
|
|
- if(bean.getMultiPolygon().contains(point)){
|
|
|
+ for (GeoJsonBean bean : cjPolygonList) {
|
|
|
+ if (bean.getMultiPolygon().contains(point)) {
|
|
|
return bean.getProperties();
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public JSONObject isCJSH2000InPolygon(double x, double y){
|
|
|
+ public JSONObject isCJSH2000InPolygon(double x, double y) {
|
|
|
Geometry point = null;
|
|
|
try {
|
|
|
point = reader.read("POINT (" + x + " " + y + ")");
|
|
@@ -854,8 +889,8 @@ public class AddressTools {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
- for(GeoJsonBean bean : cjSh2000PolygonList){
|
|
|
- if(bean.getMultiPolygon().contains(point)){
|
|
|
+ for (GeoJsonBean bean : cjSh2000PolygonList) {
|
|
|
+ if (bean.getMultiPolygon().contains(point)) {
|
|
|
return bean.getProperties();
|
|
|
}
|
|
|
}
|