Skip to content

Commit

Permalink
fix: 重新整理了一遍边界数据文件, 修复了边界错误的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
Clarmy committed Feb 15, 2022
1 parent 1abd10b commit dd65032
Show file tree
Hide file tree
Showing 38 changed files with 98 additions and 57 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ dmypy.json
.pyre/
*.ipynb


.DS_Store
shapefile
standard
amap_raw
exclude_data
tmp/
tmp/

scripts
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/100000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/110000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/120000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/130000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/140000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/150000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/210000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/220000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/230000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/310000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/320000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/330000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/340000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/350000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/360000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/370000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/410000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/420000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/430000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/440000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/450000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/460000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/500000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/510000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/520000.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/530000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/540000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/610000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/620000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/630000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/640000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/650000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/710000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/810000.geojson
Diff not rendered.
1 change: 1 addition & 0 deletions cnmaps/data/geojson.min/default/820000.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "Feature", "geometry": {"type": "MultiPolygon", "coordinates": [[[[113.559955, 22.214293], [113.561361, 22.213486], [113.562169, 22.212804], [113.562759, 22.211744], [113.576986, 22.185634], [113.581604, 22.177155], [113.588071, 22.165273], [113.596934, 22.141094], [113.598861, 22.135844], [113.59867, 22.13535], [113.59255, 22.12809], [113.575163, 22.112652], [113.573922, 22.111887], [113.571291, 22.1111], [113.555979, 22.109143], [113.554573, 22.109143], [113.548618, 22.110384], [113.548444, 22.113763], [113.548209, 22.11977], [113.54821, 22.123562], [113.548487, 22.128066], [113.549065, 22.137482], [113.549147, 22.138811], [113.549181, 22.13984], [113.549185, 22.139979], [113.549313, 22.143811], [113.549009, 22.145858], [113.547098, 22.148627], [113.542732, 22.152188], [113.542368, 22.152486], [113.537472, 22.158759], [113.534816, 22.164189], [113.53472, 22.16438], [113.532368, 22.168204], [113.529078, 22.172164], [113.527472, 22.175251], [113.526665, 22.178538], [113.526665, 22.18196], [113.526917, 22.182759], [113.527802, 22.185584], [113.529646, 22.189114], [113.530354, 22.190467], [113.53119, 22.192026], [113.532602, 22.19466], [113.533983, 22.197659], [113.534009, 22.197713], [113.534382, 22.200316], [113.534382, 22.203334], [113.534182, 22.204482], [113.534427, 22.205234], [113.534929, 22.206416], [113.53487, 22.206948], [113.533601, 22.210829], [113.533196, 22.211973], [113.533178, 22.21224], [113.533355, 22.212559], [113.53412, 22.213058], [113.534833, 22.213342], [113.535812, 22.213592], [113.537159, 22.213736], [113.538192, 22.213663], [113.539326, 22.213443], [113.540219, 22.213216], [113.540776, 22.213092], [113.541018, 22.213025], [113.541193, 22.213004], [113.54137, 22.213099], [113.542029, 22.214495], [113.542747, 22.215934], [113.543095, 22.216437], [113.543553, 22.216786], [113.544056, 22.217033], [113.544468, 22.217133], [113.544885, 22.217145], [113.547991, 22.21679], [113.548469, 22.216815], [113.550187, 22.216628], [113.550979, 22.216541], [113.553965, 22.215793], [113.559955, 22.214293]]], [[[113.572643, 22.215343], [113.579899, 22.215343], [113.585168, 22.213768], [113.585749, 22.213255], [113.585852, 22.212742], [113.585715, 22.211989], [113.58202, 22.206104], [113.581575, 22.20518], [113.581472, 22.204393], [113.581472, 22.19861], [113.581164, 22.197788], [113.57894, 22.196283], [113.57196, 22.19642], [113.571309, 22.19683], [113.571001, 22.19748], [113.571002, 22.203058], [113.571241, 22.205248], [113.571138, 22.207951], [113.570898, 22.208499], [113.570043, 22.209012], [113.569564, 22.209492], [113.569427, 22.2111], [113.569769, 22.212229], [113.571138, 22.214316], [113.571788, 22.215069], [113.572643, 22.215343]]]]}, "properties": {"name": "澳门特别行政区", "adcode": "820000", "citycode": "1853", "level": "province", "centerX": 113.53790825, "centerY": 22.1897568974}}
74 changes: 37 additions & 37 deletions cnmaps/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,79 @@
'default': {
# 数据源:谢栋灿. 高德行政区边界获取与整理(shp格式)[EB/OL]. [2017.11.05]. http://i.xdc.at/2017/11/05/amap-district-to-shapefile/.
('皖', '安徽', '安徽省', 'Anhui'):
'Anhui',
'340000',
('京', '北京', '北京市', 'Beijing'):
'Beijing',
'110000',
('渝', '重庆', '重庆市', 'Chongqing'):
'Chongqing',
'500000',
('闽', '福建', '福建省', 'Fujian'):
'Fujian',
'350000',
('甘', '甘肃', '甘肃省', 'Gansu'):
'Gansu',
'620000',
('粤', '广东', '广东省', 'Guangdong'):
'Guangdong',
'440000',
('桂', '广西', '广西省', 'Guangxi'):
'Guangxi',
'450000',
('贵', '黔', '贵州', '贵州省', 'Guizhou'):
'Guizhou',
'520000',
('琼', '海南', '海南省', 'Hainan'):
'Hainan',
'460000',
('冀', '河北', '河北省', 'Hebei'):
'Hebei',
'130000',
('黑', '黑龙江', '黑龙江省', 'Heilongjiang'):
'Heilongjiang',
'230000',
('豫', '河南', '河南省', 'Henan'):
'Henan',
'410000',
('港', '香港', '香港特别行政区', 'HongKong'):
'HongKong',
'810000',
('鄂', '湖北', '湖北省', 'Hubei'):
'Hubei',
'420000',
('湘', '湖南', '湖南省', 'Hunan'):
'Hunan',
'430000',
('蒙', '内蒙古', '内蒙古自治区', 'InnerMongolia'):
'InnerMongolia',
'150000',
('苏', '江苏', '江苏省', 'Jiangsu'):
'Jiangsu',
'320000',
('赣', '江西', '江西省', 'Jiangxi'):
'Jiangxi',
'360000',
('吉', '吉林', '吉林省', 'Jilin'):
'Jilin',
'220000',
('辽', '辽宁', '辽宁省', 'Liaoning'):
'Liaoning',
'210000',
('澳', '澳门', '澳门特别行政区', 'Macao'):
'Macao',
'820000',
('南海', '九段线', 'MaritimeBoundary'):
'MaritimeBoundary',
('中国', '国界线', 'ChinaLand'):
('中国', '国界线', '简化中国', 'ChinaLand'):
'ChinaLand',
('中国2', '国界线2', 'ChinaLand2'):
'ChinaLand2',
('中国2', '国界线2', '完整中国', 'ChinaLand2'):
'100000',
('宁', '宁夏', '宁夏回族自治区', 'Ningxia'):
'Ningxia',
'640000',
('青', '青海', '青海省', 'Qinghai'):
'Qinghai',
'630000',
('陕', '陕西', '陕西省', 'Shaanxi'):
'Shaanxi',
'610000',
('鲁', '山东', '山东省', 'Shandong'):
'Shandong',
'370000',
('沪', '上海', '上海市', 'Shanghai'):
'Shanghai',
'310000',
('晋', '山西', '山西省', 'Shanxi'):
'Shanxi',
'140000',
('川', '四川', '四川省', 'Sichuan'):
'Sichuan',
'510000',
('津', '天津', '天津市', 'Tianjin'):
'Tianjin',
'120000',
('藏', '西藏', '西藏自治区', 'Tibet'):
'Tibet',
'540000',
('新', '新疆', '新疆维吾尔自治区', 'Xinjiang'):
'Xinjiang',
'650000',
('云', '滇', '云南', '云南省', 'Yunnan'):
'Yunnan',
'530000',
('浙', '浙江', '浙江省', 'Zhejiang'):
'Zhejiang',
'330000',
('台', '台湾', '台湾省', 'Taiwan'):
'Taiwan'
'710000'
},
'geography': {
# 数据源:张镱锂, 李炳元, 郑度. 青藏高原范围与界线地理信息系统数据[J/DB/OL]. 全球变化数据仓储电子杂志(中英文), 2014. https://doi.org/10.3974/geodb.2014.01.12.V1.
Expand Down
41 changes: 23 additions & 18 deletions tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def test_map_operator():
assert isinstance(
get_map('四川').union(get_map('重庆')) + get_map('贵州'), MapPolygon)
assert round((get_map('四川') + get_map('重庆') + get_map('贵州')).area,
2) == 69.22
2) == 69.45

# 逻辑与操作符(交集)
assert isinstance(
get_map('青藏高原', map_set='geography') & get_map('四川'), MapPolygon)

assert round((get_map('青藏高原', map_set='geography') & get_map('四川')).area,
2) == 23.92
2) == 24.13
assert isinstance(get_map('福建') & get_map('广东'), MapPolygon)

# & 和 + 混合
Expand All @@ -63,14 +64,14 @@ def test_map_operator():
get_map('云南'), MapPolygon)
assert isinstance(
get_map('中国') - get_map('山西') + get_map('山西'), MapPolygon)
assert round((get_map('中国') - get_map('山西')).area, 2) == 945.33
assert round((get_map('中国') - get_map('山西')).area, 2) == 945.3


def test_province_orthogonality():
"""检验省边界地图的正交性"""
name_keys = set(NAMES['default'].keys()) - set(
[('南海', '九段线', 'MaritimeBoundary'), ('中国', '国界线', 'ChinaLand'),
('中国2', '国界线2', 'ChinaLand2')])
[('南海', '九段线', 'MaritimeBoundary'), ('中国', '国界线', '简化中国', 'ChinaLand'),
('中国2', '国界线2', '完整中国', 'ChinaLand2')])
province_names = [nk[0] for nk in name_keys]

couples = sorted([couple for couple in combinations(province_names, r=2)])
Expand All @@ -82,8 +83,8 @@ def test_province_orthogonality():
def test_province_union():
"""检验所有省量量相加是否会报错"""
name_keys = set(NAMES['default'].keys()) - set(
[('南海', '九段线', 'MaritimeBoundary'), ('中国', '国界线', 'ChinaLand'),
('中国2', '国界线2', 'ChinaLand2')])
[('南海', '九段线', 'MaritimeBoundary'), ('中国', '国界线', '简化中国', 'ChinaLand'),
('中国2', '国界线2', '完整中国', 'ChinaLand2')])
province_names = [nk[0] for nk in name_keys]

couples = sorted([couple for couple in combinations(province_names, r=2)])
Expand All @@ -95,8 +96,8 @@ def test_province_union():
def test_province_difference():
"""检验所有省量量相减是否会报错"""
name_keys = set(NAMES['default'].keys()) - set(
[('南海', '九段线', 'MaritimeBoundary'), ('中国', '国界线', 'ChinaLand'),
('中国2', '国界线2', 'ChinaLand2')])
[('南海', '九段线', 'MaritimeBoundary'), ('中国', '国界线', '简化中国', 'ChinaLand'),
('中国2', '国界线2', '完整中国', 'ChinaLand2')])
province_names = [nk[0] for nk in name_keys]

couples = sorted([couple for couple in product(province_names, repeat=2)])
Expand All @@ -106,14 +107,18 @@ def test_province_difference():


def test_get_extent():
extent = [(109.661377, 117.304153, 20.217283, 25.518644332885742),
(108.66138099701756, 118.3032636214493, 19.21844606457509,
26.51787665743222),
(107.66138499403512, 119.30237424289862, 18.219609129150186,
27.51742946075122),
(106.66138899105268, 120.30148486434793, 17.220772193725278,
28.516822024683957),
(105.66139298807025, 121.30059548579725, 16.22193525830037,
29.51502654056799)]
extent = [(109.650798, 117.313723, 20.214186, 25.519625),
(108.65117139025172, 118.31362977796758, 19.214262701394475,
26.51899149752301),
(107.65154478050344, 119.31353655593516, 18.214339402788948,
27.51850580083624),
(106.65191817075515, 120.31344333390275, 17.21441610418342,
28.51849570125436),
(105.65229156100688, 121.31335011187034, 16.21449280557789,
29.518790750222323)]
for i in range(5):
assert get_map('广东').get_extent(buffer=i) == extent[i]


if __name__ == '__main__':
test_map_operator()

0 comments on commit dd65032

Please sign in to comment.