新增小区geohash
This commit is contained in:
+7
-7
@@ -2,10 +2,9 @@ package com.fangjia.script.temp.shenjian
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray
|
import com.alibaba.fastjson.JSONArray
|
||||||
import com.alibaba.fastjson.JSONObject
|
import com.alibaba.fastjson.JSONObject
|
||||||
import com.fangjia.script.lixue.util.DBUtils
|
|
||||||
import com.fangjia.script.statistics.poi.AmapPoi
|
import com.fangjia.script.statistics.poi.AmapPoi
|
||||||
import com.mongodb.BasicDBObject
|
import com.fangjia.script.temp.shenjian.util.SeaweedUtils
|
||||||
import com.mongodb.DBObject
|
import org.elasticsearch.geometry.utils.Geohash
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shenjian* @since 2021/5/18
|
* @author shenjian* @since 2021/5/18
|
||||||
@@ -13,10 +12,11 @@ import com.mongodb.DBObject
|
|||||||
class Temp {
|
class Temp {
|
||||||
|
|
||||||
static void main(String[] args) {
|
static void main(String[] args) {
|
||||||
String jsonStr = "[{\"id\":\"B0FFLCY016\",\"parent\":[],\"childtype\":[],\"name\":\"杭州馨悦坊公寓\",\"type\":\"住宿服务;住宿服务相关;住宿服务相关\",\"typecode\":\"100000\",\"biz_type\":\"hotel\",\"address\":\"18号大街伊萨卡浩泽园\",\"location\":\"120.383947,30.289931\",\"tel\":[],\"pname\":\"浙江省\",\"cityname\":\"杭州市\",\"adname\":\"钱塘区\",\"importance\":[],\"shopid\":[],\"shopinfo\":\"0\",\"poiweight\":[],\"distance\":\"992\",\"biz_ext\":{\"rating\":[],\"cost\":[],\"hotel_ordering\":\"0\",\"lowest_price\":[],\"star\":[],\"open_time\":[],\"opentime2\":[]},\"photos\":[{\"title\":\"Logo\",\"url\":\"http://store.is.autonavi.com/showpic/7e9c5bdeeba929eb4742102b7c9bd47c\",\"provider\":[]},{\"title\":\"客房\",\"url\":\"http://store.is.autonavi.com/showpic/e4e5771e4de5083877931fda2e360f74\",\"provider\":[]},{\"title\":[],\"url\":\"http://store.is.autonavi.com/showpic/5401e1e105bcbacf550896c7575ee315\",\"provider\":[]}]}]"
|
String str = SeaweedUtils.encodeByGeoHash(106.569161, 29.498502)
|
||||||
JSONArray jsonArray = JSONObject.parseArray(jsonStr)
|
println(str)
|
||||||
List<AmapPoi> ret = JSONObject.parseArray(jsonArray.toJSONString(), AmapPoi.class);
|
str = Geohash.stringEncode(106.569161, 29.498502, 10)
|
||||||
print(ret.size())
|
println(str)
|
||||||
|
// wm5zc4131rmf
|
||||||
}
|
}
|
||||||
|
|
||||||
// 万友七季城C区 经度纬度不同106.569161 29.498502 原始106.56881 29.50058 距离231.7003米
|
// 万友七季城C区 经度纬度不同106.569161 29.498502 原始106.56881 29.50058 距离231.7003米
|
||||||
|
|||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package com.fangjia.script.temp.shenjian.seaweed
|
||||||
|
|
||||||
|
import com.fangjia.script.temp.shenjian.util.SeaweedUtils
|
||||||
|
import com.fangjia.script.util.DbUtils
|
||||||
|
import com.mongodb.BasicDBObject
|
||||||
|
import com.mongodb.DBObject
|
||||||
|
|
||||||
|
import java.util.concurrent.CountDownLatch
|
||||||
|
import java.util.concurrent.ExecutorService
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小区geohash导出
|
||||||
|
*
|
||||||
|
* @author shenjian
|
||||||
|
* @since 2021/5/25
|
||||||
|
*/
|
||||||
|
class SeaweedGeoHashExport {
|
||||||
|
|
||||||
|
static void main(String[] args) {
|
||||||
|
Set<String> set = new HashSet<>()
|
||||||
|
|
||||||
|
DBObject query = new BasicDBObject()
|
||||||
|
query.append("cat", "district").append("visible", 0)
|
||||||
|
|
||||||
|
DBObject filter = new BasicDBObject()
|
||||||
|
filter.put("lng", 1)
|
||||||
|
filter.put("lat", 1)
|
||||||
|
DbUtils.seaweed.find(query, filter).batchSize(20000).each {objTemp ->
|
||||||
|
final def obj = objTemp
|
||||||
|
if (obj.lng && obj.lat) {
|
||||||
|
def lon = obj.lng
|
||||||
|
def lat = obj.lat
|
||||||
|
set.add(SeaweedUtils.encodeByGeoHash(SeaweedUtils.formatLatLng(lon), SeaweedUtils.formatLatLng(lat),7))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def ret = []
|
||||||
|
ret << ['小区geohash']
|
||||||
|
for (String val : set) {
|
||||||
|
ret << [val]
|
||||||
|
}
|
||||||
|
com.fangjia.script.util.ExcelUtils.write("F:\\数据\\基础建设\\geohash.xlsx", ret, "geohash");
|
||||||
|
}
|
||||||
|
}
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
package com.fangjia.script.temp.shenjian.seaweed
|
|
||||||
|
|
||||||
import com.fangjia.script.util.DbUtils
|
|
||||||
import com.mongodb.BasicDBObject
|
|
||||||
import com.mongodb.DBObject
|
|
||||||
|
|
||||||
class Temp {
|
|
||||||
|
|
||||||
static main (args){
|
|
||||||
DBObject query = new BasicDBObject()
|
|
||||||
query.append("cat", "district").append("visible", 0).append("city", "±±¾©")
|
|
||||||
|
|
||||||
DBObject filter = new BasicDBObject()
|
|
||||||
filter.append("build_structure", 1)
|
|
||||||
|
|
||||||
Set<String> set = new HashSet<>()
|
|
||||||
|
|
||||||
DbUtils.seaweed.find(query, filter).batchSize(10000).each({ dbo ->
|
|
||||||
if (dbo.build_structure) {
|
|
||||||
set.add(dbo.build_structure)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
set.each {val ->
|
|
||||||
println(val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+17
@@ -5,6 +5,7 @@ import com.fangjia.script.datastore.FieldValidatorUtils
|
|||||||
import com.fangjia.script.util.MongoUtils
|
import com.fangjia.script.util.MongoUtils
|
||||||
import com.mongodb.BasicDBObject
|
import com.mongodb.BasicDBObject
|
||||||
import com.mongodb.DBCollection
|
import com.mongodb.DBCollection
|
||||||
|
import org.elasticsearch.geometry.utils.Geohash
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
@@ -184,6 +185,22 @@ class SeaweedUtils {
|
|||||||
return com.fangjia.script.common.DataHandleUtils.getDoubleRound(6, latOrLng / 10000000000d)
|
return com.fangjia.script.common.DataHandleUtils.getDoubleRound(6, latOrLng / 10000000000d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小区经纬度geohash编码
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
static def encodeByGeoHash(double lon, double lat, int level=7) {
|
||||||
|
return Geohash.stringEncode(lon, lat, level)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小区经纬度geohash解码
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
static def decodeByGeoHash(String geohash) {
|
||||||
|
return Geohash.decodeLongitude(geohash) + "," + Geohash.decodeLatitude(geohash)
|
||||||
|
}
|
||||||
|
|
||||||
static void main(String[] args) {
|
static void main(String[] args) {
|
||||||
def alias = ["金杏一村","金杏一村","金杏一村","金杏一村","金杏一村", "金杏二村"]
|
def alias = ["金杏一村","金杏一村","金杏一村","金杏一村","金杏一村", "金杏二村"]
|
||||||
println(formatAlias(alias))
|
println(formatAlias(alias))
|
||||||
|
|||||||
Reference in New Issue
Block a user