主程序:
import LoadGeo;
filePath = 'E:\districtMap\\';
uri = "https://geo.datav.aliyun.com/areas_v3/bound/"
uriSuffix = "_full.json";
def getUrl(countryCode):
return uri + countryCode + uriSuffix;
def loadAndWrite():
countryCode = "100000";
treeLoadAndWrite(countryCode);# 从全国始,直至各省、市、区
print("Fin!")
def treeLoadAndWrite(adCode):
mapDatas = LoadGeo.request_data(getUrl(adCode));
try:
if mapDatas is not None:
LoadGeo.writeJsonFile(filePath, adCode, mapDatas);
if 'features' in mapDatas:
for md in mapDatas.get('features'):
subAdCode = LoadGeo.getAdcode(md);
print(subAdCode);
treeLoadAndWrite(subAdCode);
except:
pass
loadAndWrite();# 程序入口
相应的解析脚本LoadGeo.py: