查高德地图优化
This commit is contained in:
+100
-10
@@ -1,14 +1,18 @@
|
||||
package com.fangjia.script.gj.data_handle
|
||||
|
||||
import com.fangjia.core.util.HttpRequest
|
||||
import com.fangjia.script.BaseBatch
|
||||
import com.fangjia.script.BatchOwner
|
||||
import com.fangjia.script.Watcher
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.common.DataHandleUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.rabbitmq.client.impl.AMQImpl
|
||||
import groovy.json.JsonSlurper
|
||||
import net.sf.json.JSONObject
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.CountDownLatch
|
||||
@@ -36,6 +40,8 @@ class AddDistrictShapeBatch extends BaseBatch{
|
||||
|
||||
@Override
|
||||
public void process(Object args) {
|
||||
|
||||
// findGaoDeDatas2("苏州市","吴中区", "水岸清华瀚宫" )
|
||||
def citys = CommonDatautils.findAllCity()
|
||||
def index = 1
|
||||
for(def c : citys){
|
||||
@@ -228,7 +234,7 @@ class AddDistrictShapeBatch extends BaseBatch{
|
||||
|
||||
def fenceMap = null
|
||||
for(def name : alias){
|
||||
fenceMap = findGaoDeDatas(fullCityName, fullDistName, name)
|
||||
fenceMap = findGaoDeDatas2(fullCityName, fullDistName, name)
|
||||
if(!fenceMap){
|
||||
continue
|
||||
}
|
||||
@@ -244,15 +250,14 @@ class AddDistrictShapeBatch extends BaseBatch{
|
||||
o.put("data_id", fenceMap.id)
|
||||
o.put("comm_id", d._id.toString())
|
||||
def resultMap = [:]
|
||||
|
||||
def shape = fenceMap.shape
|
||||
def points_x = fenceMap.shape.polygon.x
|
||||
def points_y = fenceMap.shape.polygon.y
|
||||
def list = []
|
||||
for(def i=0;i<points_x.size();i++){
|
||||
list << [points_x[i], points_y[i]]
|
||||
}
|
||||
resultMap.coordinates = list
|
||||
// def shape = fenceMap.shape
|
||||
// def points_x = fenceMap.shape.polygon.x
|
||||
// def points_y = fenceMap.shape.polygon.y
|
||||
// def list = []
|
||||
// for(def i=0;i<points_x.size();i++){
|
||||
// list << [points_x[i], points_y[i]]
|
||||
// }
|
||||
resultMap.coordinates = fenceMap.coordinates
|
||||
resultMap.type = "polygon"
|
||||
o.put("shape", resultMap)
|
||||
|
||||
@@ -276,6 +281,91 @@ class AddDistrictShapeBatch extends BaseBatch{
|
||||
})
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
def findGaoDeDatas2(city, region, name){
|
||||
def header = [:]
|
||||
header["Authorization"] = "Basic ${Base64.getEncoder().encodeToString("elastic:goojia123456".getBytes("UTF-8"))}".toString()
|
||||
String seawaterUrl = "http://192.168.0.206:9200/amap_poi_detail/_search"
|
||||
def body = """
|
||||
{
|
||||
"_source": {
|
||||
"includes": ["name", "shape", "id"]
|
||||
},
|
||||
"query": {
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"term": {
|
||||
"cityname" : "${city}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"term": {
|
||||
"adname" : "${region}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": {
|
||||
"name": {"query": "${name}","operator": "and"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": {
|
||||
"type": "住宅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"exists": {
|
||||
"field": "shape"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
HttpRequest request = new HttpRequest()
|
||||
String res = request.postWithBody(seawaterUrl, JSONObject.fromObject(body.toString()), header, "UTF-8")
|
||||
def response = new JsonSlurper().parseText(res)
|
||||
def obj = null
|
||||
def fenceMap = [:]
|
||||
if(response && response.hits){
|
||||
def hits = response.hits.hits
|
||||
if(hits){
|
||||
def d = hits[0]
|
||||
def source = d._source
|
||||
def newName = source.name.replace("-","").replace("·","").replace("(建设中)","")
|
||||
if(newName == name){
|
||||
fenceMap.id = source.id
|
||||
def list = []
|
||||
def points_arr = source.shape.coordinates
|
||||
for(def points : points_arr){
|
||||
def rets = []
|
||||
for(def point : points){
|
||||
def lng = DataHandleUtils.getDoubleRound(6, point[0].toString().toDouble())
|
||||
def lat = DataHandleUtils.getDoubleRound(6, point[1].toString().toDouble())
|
||||
rets << [lng, lat]
|
||||
}
|
||||
list << rets
|
||||
}
|
||||
if(list.size()==1){
|
||||
fenceMap.coordinates = list[0]
|
||||
}else{
|
||||
fenceMap.coordinates = list
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return fenceMap
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def findSeaweedFenceExists(commid){
|
||||
def q = new BasicDBObject()
|
||||
q.put("comm_id", commid)
|
||||
|
||||
Reference in New Issue
Block a user