由于项目需要离线本地化,通过离线经纬度解析出省份城市信息
一通查询资料,有非JAVA的,有功能过多过于笨重的,有资源需要收费的
emmm 干脆还是自己动手丰衣足食
技术点:JAVA java.awt.Polygon.contains方法 查询坐标是否包含再多边形中
资源:https://datav.aliyun.com/tools/atlas/index.html 下载所需要的省份城市信息,下载中国城市级别可以参考下面文末下载地图命令 也整理一份到资料中;特别说明,如果解析城市北京上海重庆天津澳门香港位城市级别需要使用中国100000_full.json中数据作为城市级别,否则会解析为区级别 比如朝阳区。
思路:
根据阿里云给出的地图围栏信息生成省份城市的地图多边形围栏,查询判断经纬度是否再多边形范围内,即可查询到经纬度属于哪个城市
注意:
1.省份可能存在多个多边形围栏,多个多边形围栏对应相同省份城市
2.直辖市港澳需要特殊处理 处理方式见代码map中直辖市港澳台.json
测试初步代码+地图数据见附件
代码可能存在一些问题,仅作为思路验证,运行效率笔记本 4W随机经纬度/秒
代码数据资源地址:https://download.csdn.net/download/u014080107/21740668
中国地图下载命令-计算省份使用
wget https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json;
中国城市地图下载命令-计算城市使用
wget https://geo.datav.aliyun.com/areas_v3/bound/110000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/120000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/130000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/140000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/150000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/210000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/220000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/230000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/310000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/320000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/330000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/340000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/350000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/360000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/370000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/410000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/420000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/430000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/440000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/450000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/460000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/500000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/510000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/520000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/530000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/540000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/610000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/620000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/630000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/640000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/650000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/710000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/810000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/820000_full.json;
wget https://geo.datav.aliyun.com/areas_v3/bound/100000_JD_full.json;