新增板块所属区域更新
This commit is contained in:
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package com.fangjia.script.temp.shenjian.geo
|
||||||
|
|
||||||
|
import com.fangjia.script.gj.location.Point
|
||||||
|
import com.fangjia.script.util.MongoUtils
|
||||||
|
import com.fangjia.script.xh.InsidePolygon
|
||||||
|
import com.mongodb.BasicDBList
|
||||||
|
import com.mongodb.BasicDBObject
|
||||||
|
import com.mongodb.DBCollection
|
||||||
|
|
||||||
|
DBCollection collection = MongoUtils.getCollectionByName("fangjia_crawl", "block", "192.168.0.85", 28017)
|
||||||
|
|
||||||
|
collection.find(new BasicDBObject()).forEach({ obj ->
|
||||||
|
if (obj.type == 'block') {
|
||||||
|
if (obj.region instanceof String) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BasicDBList reigon = (BasicDBList)obj.region
|
||||||
|
int count = 0
|
||||||
|
List<String> info = new ArrayList<>()
|
||||||
|
for (String s : reigon) {
|
||||||
|
info.add(s)
|
||||||
|
}
|
||||||
|
if (info.size() > 1) {
|
||||||
|
boolean find = false
|
||||||
|
for (String s : info) {
|
||||||
|
if (find) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
collection.find(new BasicDBObject("type", "region").append("name", s)).limit(1).forEach({obj2 ->
|
||||||
|
String border = obj2.border
|
||||||
|
String points = border.replaceAll(",", "-").replaceAll(";", "-")
|
||||||
|
List<com.fangjia.script.looplineinfo.Point> pointList = InsidePolygon.createPoint(points);
|
||||||
|
com.fangjia.script.looplineinfo.Point point = new com.fangjia.script.looplineinfo.Point(obj.lng, obj.lat)
|
||||||
|
if (InsidePolygon.aboutZone(point, pointList)) {
|
||||||
|
collection.update(new BasicDBObject("_id", obj._id),
|
||||||
|
new BasicDBObject('$set', new BasicDBObject("region", obj2.name)));
|
||||||
|
find = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
collection.update(new BasicDBObject("_id", obj._id),
|
||||||
|
new BasicDBObject('$set', new BasicDBObject("region", info.get(0))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user