优化经纬度获取
This commit is contained in:
+15
-4
@@ -20,7 +20,7 @@ import java.util.concurrent.Executors
|
|||||||
class CommitteeLatLng {
|
class CommitteeLatLng {
|
||||||
|
|
||||||
static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017)
|
static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017)
|
||||||
static ExecutorService executorService = Executors.newFixedThreadPool(1)
|
static ExecutorService executorService = Executors.newFixedThreadPool(20)
|
||||||
|
|
||||||
static void main(String[] args) {
|
static void main(String[] args) {
|
||||||
dealPoi(new BasicDBObject("status_location", new BasicDBObject('$ne', 0)))
|
dealPoi(new BasicDBObject("status_location", new BasicDBObject('$ne', 0)))
|
||||||
@@ -37,10 +37,10 @@ class CommitteeLatLng {
|
|||||||
def city = obj.city_name
|
def city = obj.city_name
|
||||||
if (city == "市辖区") {
|
if (city == "市辖区") {
|
||||||
city = obj.province_name
|
city = obj.province_name
|
||||||
|
} else if (city == "省直辖县级行政区划") {
|
||||||
|
city = obj.area_name
|
||||||
}
|
}
|
||||||
def address = obj.province_name + city + obj.area_name + obj.street_name + obj.name;
|
def address = obj.province_name + city + obj.area_name + obj.street_name + obj.name;
|
||||||
// 不准确
|
|
||||||
// def location = GaoDeUtils.parserByGaode(city, address);
|
|
||||||
List<AmapPoi> amapPoi = GaoDeUtils.searchPoi(city, address, obj.area_name, "130106|130105|130104")
|
List<AmapPoi> amapPoi = GaoDeUtils.searchPoi(city, address, obj.area_name, "130106|130105|130104")
|
||||||
if (amapPoi && amapPoi.size() > 0) {
|
if (amapPoi && amapPoi.size() > 0) {
|
||||||
def poi = amapPoi[0]
|
def poi = amapPoi[0]
|
||||||
@@ -55,7 +55,18 @@ class CommitteeLatLng {
|
|||||||
villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 0)
|
villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 0)
|
||||||
.append("location", new BasicDBObject("lat", lat).append("lon", lng)).append("flag_location", "关键字搜索获取经纬度")))
|
.append("location", new BasicDBObject("lat", lat).append("lon", lng)).append("flag_location", "关键字搜索获取经纬度")))
|
||||||
} else {
|
} else {
|
||||||
villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 2).append("flag_location", "经纬度为空")))
|
amapPoi = GaoDeUtils.searchPoi(city, address, obj.area_name, "")
|
||||||
|
if (amapPoi && amapPoi.size() > 0) {
|
||||||
|
def poi = amapPoi[0]
|
||||||
|
String[] locations = poi.location.split(",")
|
||||||
|
def lng = Double.valueOf(locations[0])
|
||||||
|
def lat = Double.valueOf(locations[1])
|
||||||
|
villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 0)
|
||||||
|
.append("location", new BasicDBObject("lat", lat).append("lon", lng)).append("flag_location", "关键字搜索获取经纬度")))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 2).append("flag_location", "经纬度为空")))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
println("已处理小区:" + obj)
|
println("已处理小区:" + obj)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user