优化镇分词经纬度获取

This commit is contained in:
沈健
2021-09-26 18:14:13 +08:00
parent abcba9c17a
commit f207b8b53a
@@ -1,6 +1,7 @@
package com.fangjia.script.temp.shenjian.poi package com.fangjia.script.temp.shenjian.poi
import com.fangjia.core.util.CosineSimilarAlgorithm import com.fangjia.core.util.CosineSimilarAlgorithm
import com.fangjia.script.gj.EsUtils
import com.fangjia.script.statistics.poi.AmapPoi import com.fangjia.script.statistics.poi.AmapPoi
import com.fangjia.script.temp.shenjian.util.GaoDeUtils import com.fangjia.script.temp.shenjian.util.GaoDeUtils
import com.fangjia.script.util.MongoUtils import com.fangjia.script.util.MongoUtils
@@ -20,12 +21,10 @@ 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)))
.append("province_name", '江苏省')
)
//dealLocation() //dealLocation()
executorService.shutdown() executorService.shutdown()
} }
@@ -41,10 +40,6 @@ class CommitteeLatLng {
def area = obj.area_name def area = obj.area_name
def name = obj.name def name = obj.name
// if (!name.contains("社区居委会")) {
// return ;
// }
if (city == "市辖区") { if (city == "市辖区") {
city = obj.province_name city = obj.province_name
} else if (city == "省直辖县级行政区划" || city == "自治区直辖县级行政区划") { } else if (city == "省直辖县级行政区划" || city == "自治区直辖县级行政区划") {
@@ -57,17 +52,22 @@ class CommitteeLatLng {
if (obj.name.contains("虚拟生活区") || obj.name.contains("管理区") || obj.name.contains("虚拟社区")) { if (obj.name.contains("虚拟生活区") || obj.name.contains("管理区") || obj.name.contains("虚拟社区")) {
name = obj.street_name name = obj.street_name
} }
if (name.contains("社区居委会")) { // if (name.contains("社区居委会")) {
name = name.replace("居委会", "") // name = name.replace("居委会", "")
// }
if (name.contains("村村委会")) {
name = name.replace("村委会", "")
} else if (name.contains("村委会")) {
name = name.replace("村委会", "村")
} }
String address = province_name + city + area + " " + obj.street_name + " " + name; String address = province_name + " " + city + " " + area + " " + obj.street_name + " " + name;
//String address = province_name + city + area + name //String address = province_name + city + area + name
List<AmapPoi> amapPoi = GaoDeUtils.searchPoi(city, address, area, "130106|130105|130104") List<AmapPoi> amapPoi = GaoDeUtils.searchPoi(city, address, area, "130106|130105|130104")
if (amapPoi && amapPoi.size() > 0) { if (amapPoi && amapPoi.size() > 0) {
def poi = amapPoi[0] def poi = amapPoi[0]
double similarity = CosineSimilarAlgorithm.getSimilarity(poi.name, name) double similarity = CosineSimilarAlgorithm.getSimilarity(poi.name, name)
if (similarity < 0.7) { if (similarity <= 0.8) {
amapPoi = GaoDeUtils.searchPoi(city, address, area, "") amapPoi = GaoDeUtils.searchPoi(city, address, area, "")
} }
poi = amapPoi[0] poi = amapPoi[0]