Skip to content

Commit de966ce

Browse files
authored
Merge pull request #42 from eukarya-inc/fixes-41
fixes #41 fixes range missing case
2 parents 4c05b20 + e42263e commit de966ce

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

Diff for: plateauutils/mesh_geocorder/polygon_to_meshcode_list.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,19 @@ def _meshcode_range(start_mesh: int, end_mesh: int) -> list:
9696
list
9797
メッシュコードのリスト
9898
"""
99-
start_pos = str(start_mesh)
100-
end_pos = str(end_mesh)
101-
matrix = []
102-
# 開始メッシュコードと終了メッシュコードの各桁の範囲をリストに格納
103-
for i in range(len(start_pos)):
104-
if int(start_pos[i]) <= int(end_pos[i]):
105-
matrix.append(range(int(start_pos[i]), int(end_pos[i]) + 1))
106-
else:
107-
matrix.append(range(0, 10))
108-
# 全ての組み合わせを生成
109-
combinations = product(*matrix)
110-
# 各組み合わせを文字列として結合
111-
return ["".join(map(str, combo)) for combo in combinations]
99+
# start_pos = str(start_mesh)
100+
# end_pos = str(end_mesh)
101+
# print(start_pos, end_pos)
102+
# matrix = []
103+
# # 開始メッシュコードと終了メッシュコードの各桁の範囲をリストに格納
104+
# for i in range(len(start_pos)):
105+
# if int(start_pos[i]) < int(end_pos[i]):
106+
# matrix.append(range(int(start_pos[i]), int(end_pos[i]) + 1))
107+
# else:
108+
# matrix.append(range(0, 10))
109+
# # 全ての組み合わせを生成
110+
# combinations = product(*matrix)
111+
# # 各組み合わせを文字列として結合
112+
# return ["".join(map(str, combo)) for combo in combinations]
113+
combinations = range(start_mesh, end_mesh + 1)
114+
return [str(combo) for combo in combinations]

Diff for: plateauutils/mesh_geocorder/tests/test_polygon_to_meshcode_list.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
from plateauutils.mesh_geocorder.polygon_to_meshcode_list import (
2-
PolygonToMeshCodeList,
3-
_meshcode_range,
4-
)
1+
from plateauutils.mesh_geocorder.polygon_to_meshcode_list import PolygonToMeshCodeList
52
from shapely import from_wkt
63

74

8-
def test_meshcode_range():
9-
assert _meshcode_range(5136, 5238) == [
10-
"5136",
11-
"5137",
12-
"5138",
13-
"5236",
14-
"5237",
15-
"5238",
16-
]
17-
18-
195
def test_polygon_to_list():
206
polygon = from_wkt(
217
"POLYGON ((136.312866 34.930979, 136.345825 35.670685, 137.416992 35.661759, 136.312866 34.930979))%"
@@ -56,3 +42,8 @@ def test_polygon_to_list():
5642
assert polygon_to_list.output() == sorted(
5743
["5336247314", "5336247323", "5336247332", "5336247341"]
5844
)
45+
polygon = from_wkt(
46+
"POLYGON ((130.41249721501615 33.224722548534864, 130.41249721501615 33.348, 130.59 33.348, 130.59 33.224722548534864, 130.41249721501615 33.224722548534864))"
47+
)
48+
polygon_to_list = PolygonToMeshCodeList(polygon, "3")
49+
assert "49307460" in polygon_to_list.output()

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ classifiers = [
1111
"Development Status :: 2 - Pre-Alpha",
1212
"Programming Language :: Python :: 3",
1313
]
14-
version = "0.0.8"
14+
version = "0.0.9"
1515
dependencies = [
1616
"click",
1717
"numpy",

0 commit comments

Comments
 (0)