Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion digital_land/datatype/wkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def make_multipolygon(geometry):
raise ValueError(f"unexpected geometry {geometry.geom_type}")


def normalise_geometry(geometry, simplification=0.000005):
def normalise_geometry(geometry, simplification=0.000001):
if geometry.geom_type in ["Point", "Line", "MultiLineString"]:
return geometry, None

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"dataclasses-json",
"pydantic",
"json-stream",
"duckdb",
"duckdb>=0.10.0,<1.5.0",
"dask",
"dask[dataframe]",
"pyarrow",
Expand Down
22 changes: 12 additions & 10 deletions tests/unit/datatype/test_multipolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ def test_normalise_geometrycollection_provided():
expected = (
"MULTIPOLYGON (((-0.173644 51.549807,-0.173551 51.549811,"
"-0.173545 51.549902,-0.173545 51.549912,-0.173554 51.549913,-0.173550 51.549971,"
"-0.173689 51.549976,-0.173724 51.549935,-0.174041 51.549928,-0.174039 51.549828,"
"-0.174024 51.549799,-0.173644 51.549807)),((-0.176790 51.555154,"
"-0.176884 51.555212,-0.176896 51.555199,-0.176994 51.555231,-0.177025 51.555233,"
"-0.177041 51.555212,-0.177085 51.555194,-0.176995 51.555106,-0.176900 51.555147,"
"-0.176851 51.555112,-0.176790 51.555154)),((-0.176757 51.552538,"
"-0.176804 51.552519,-0.176793 51.552502,-0.176758 51.552515,-0.176707 51.552463,"
"-0.176595 51.552506,-0.176651 51.552562,-0.176746 51.552526,-0.176757 51.552538)))"
"-0.173689 51.549976,-0.173724 51.549935,-0.173930 51.549928,-0.174041 51.549928,"
"-0.174039 51.549828,-0.174031 51.549807,-0.174024 51.549799,-0.174000 51.549795,"
"-0.173779 51.549803,-0.173712 51.549804,-0.173711 51.549808,-0.173644 51.549807)),"
"((-0.176790 51.555154,-0.176884 51.555212,-0.176896 51.555199,-0.176994 51.555231,"
"-0.177006 51.555227,-0.177025 51.555233,-0.177041 51.555212,-0.177085 51.555194,"
"-0.176995 51.555106,-0.176900 51.555147,-0.176851 51.555112,-0.176790 51.555154)),"
"((-0.176757 51.552538,-0.176804 51.552519,-0.176793 51.552502,-0.176758 51.552515,"
"-0.176707 51.552463,-0.176595 51.552506,-0.176651 51.552562,-0.176746 51.552526,"
"-0.176757 51.552538)))"
)

actual = wkt.normalise(value, issues=issues)
Expand Down Expand Up @@ -172,7 +174,7 @@ def test_wkt_multipolygon_wgs84():
issues = IssueLog()

value = "MULTIPOLYGON (((-0.1434494279 51.46626361,-0.1434646353 51.46627914,-0.143515539 51.4663375,-0.1435648475 51.4663926,-0.1435988703 51.46643054,-0.1436227923 51.46646195,-0.1436840978 51.46644134,-0.1436913831 51.4664392,-0.1437519691 51.46641858,-0.1437548832 51.46641773,-0.1436953554 51.46634835,-0.1435837312 51.46621808,-0.1435209507 51.46623957,-0.1434494279 51.46626361)))" # noqa: E501
expected = "MULTIPOLYGON (((-0.143449 51.466264,-0.143623 51.466462,-0.143755 51.466418,-0.143584 51.466218,-0.143449 51.466264)))"
expected = "MULTIPOLYGON (((-0.143449 51.466264,-0.143465 51.466279,-0.143599 51.466431,-0.143623 51.466462,-0.143755 51.466418,-0.143584 51.466218,-0.143449 51.466264)))"
assert wkt.normalise(value, issues=issues) == expected
assert issue_type(issues) is None

Expand All @@ -181,7 +183,7 @@ def test_wkt_multipolygon_flipped_northings_and_eastings():
wkt = MultiPolygonDataType()
issues = IssueLog()
value = "MULTIPOLYGON (((203500.0 494297.28,203499.8 494297.07,203495.1 494292.05,203491.2 494287.55,203487.2 494284.05,203482.45 494280.05,203478.4 494276.3,203479.85 494274.9,203486.95 494265.96,203500.0 494249.55,203503.6 494244.7,203514.5 494230.45,203532.6 494206.8,203554.0 494178.8,203566.2 494162.9,203601.8 494116.4,203626.0 494136.2,203628.4 494138.7,203628.9 494141.1,203626.04 494151.35,203639.0 494160.6,203645.3 494165.9,203650.7 494170.2,203651.8 494170.9,203659.0 494175.7,203670.3 494183.0,203674.8 494186.0,203677.7 494188.6,203619.4 494261.3,203612.3 494270.3,203607.2 494276.8,203602.7 494282.9,203590.9 494299.4,203578.6 494316.9,203578.36 494317.24,203562.9 494338.9,203550.8 494332.5,203546.6 494330.4,203540.7 494326.7,203533.8 494322.3,203522.1 494315.4,203519.1 494313.4,203516.8 494311.9,203514.3 494309.8,203500.0 494297.28)))" # noqa: E501
expected = "MULTIPOLYGON (((-0.636234 51.722310,-0.635995 51.722479,-0.635742 51.722723,-0.635614 51.722868,-0.636501 51.723277,-0.637759 51.723926,-0.637797 51.723900,-0.638032 51.723686,-0.638174 51.723582,-0.638312 51.723467,-0.638459 51.723495,-0.638494 51.723491,-0.638824 51.723255,-0.636925 51.722318,-0.636543 51.722119,-0.636377 51.722233,-0.636234 51.722310)))" # noqa: E501
expected = "MULTIPOLYGON (((-0.636234 51.722310,-0.636049 51.722436,-0.636018 51.722459,-0.635995 51.722479,-0.635966 51.722506,-0.635862 51.722610,-0.635742 51.722723,-0.635710 51.722761,-0.635614 51.722868,-0.636501 51.723277,-0.636722 51.723389,-0.637759 51.723926,-0.637797 51.723900,-0.638032 51.723686,-0.638174 51.723582,-0.638312 51.723467,-0.638459 51.723495,-0.638494 51.723491,-0.638531 51.723470,-0.638824 51.723255,-0.636925 51.722318,-0.636563 51.722133,-0.636543 51.722119,-0.636488 51.722155,-0.636377 51.722233,-0.636311 51.722267,-0.636234 51.722310)))" # noqa: E501
normalised = wkt.normalise(value, issues=issues)
assert normalised == expected
assert issue_type(issues) == "OSGB flipped"
Expand Down Expand Up @@ -211,7 +213,7 @@ def test_wkt_invalid_multipolygon_too_few_points():
# 465879 "Teesmouth and Cleveland Coast"
# Too few points in geometry component[-1.240621 54.600571]
value = "MULTIPOLYGON(((-1.240621 54.600571,-1.240618 54.600566,-1.24038 54.600608,-1.240094 54.600681,-1.239689 54.6008,-1.239365 54.60088,-1.239192 54.600903,-1.239082 54.600905,-1.23893 54.600894,-1.238186 54.600798,-1.237731 54.600706,-1.237607 54.600704,-1.237373 54.600645,-1.237228 54.600627,-1.237181 54.600612,-1.237163 54.60059,-1.237159 54.6005,-1.237124 54.60044,-1.237062 54.60039,-1.236918 54.600298,-1.236722 54.600197,-1.236307 54.600009,-1.236144 54.599908,-1.23606 54.599837,-1.235639 54.599828,-1.235434 54.599864,-1.235202 54.599854,-1.235063 54.599822,-1.234897 54.599755,-1.234799 54.599734,-1.234647 54.59972,-1.234565 54.59969,-1.234484 54.599638,-1.234447 54.599608,-1.234405 54.599557,-1.234306 54.599471,-1.234267 54.599451,-1.234022 54.599388,-1.233858 54.599361,-1.233446 54.599375,-1.233442 54.599417,-1.233678 54.601451,-1.233948 54.603642,-1.236817 54.603639,-1.246748 54.603569,-1.250048 54.601986,-1.250198 54.601952,-1.249817 54.601682,-1.248889 54.601045,-1.248357 54.600664,-1.247944 54.600349,-1.246529 54.600752,-1.245915 54.599941,-1.245832 54.599909,-1.245807 54.599911,-1.245686 54.599962,-1.245584 54.599994,-1.245013 54.600219,-1.244672 54.600364,-1.244425 54.600494,-1.244167 54.600571,-1.244048 54.600593,-1.244054 54.600605,-1.243709 54.600674,-1.243382 54.60082,-1.242351 54.601124,-1.242329 54.601101,-1.241955 54.600894,-1.241885 54.600845,-1.241862 54.600805,-1.241837 54.600792,-1.241697 54.600757,-1.241631 54.600749,-1.24158 54.600731,-1.241436 54.600726,-1.241406 54.600709,-1.241349 54.600658,-1.241331 54.600653,-1.241279 54.600595,-1.241261 54.600557,-1.241205 54.600525,-1.241081 54.600521,-1.240771 54.600548,-1.240621 54.600571),(-1.240621 54.600571,-1.240621 54.600571,-1.240592 54.600575,-1.240621 54.600571)))" # noqa: E501
expected = "MULTIPOLYGON (((-1.240771 54.600548,-1.240621 54.600571,-1.240618 54.600566,-1.240380 54.600608,-1.240094 54.600681,-1.239689 54.600800,-1.239365 54.600880,-1.239192 54.600903,-1.239082 54.600905,-1.238930 54.600894,-1.238186 54.600798,-1.237731 54.600706,-1.237607 54.600704,-1.237373 54.600645,-1.237228 54.600627,-1.237181 54.600612,-1.237163 54.600590,-1.237159 54.600500,-1.237124 54.600440,-1.237062 54.600390,-1.236918 54.600298,-1.236722 54.600197,-1.236307 54.600009,-1.236144 54.599908,-1.236060 54.599837,-1.235639 54.599828,-1.235434 54.599864,-1.235202 54.599854,-1.235063 54.599822,-1.234897 54.599755,-1.234799 54.599734,-1.234647 54.599720,-1.234565 54.599690,-1.234484 54.599638,-1.234447 54.599608,-1.234405 54.599557,-1.234306 54.599471,-1.234267 54.599451,-1.234022 54.599388,-1.233858 54.599361,-1.233446 54.599375,-1.233442 54.599417,-1.233678 54.601451,-1.233948 54.603642,-1.236817 54.603639,-1.246748 54.603569,-1.250048 54.601986,-1.250198 54.601952,-1.248889 54.601045,-1.248357 54.600664,-1.247944 54.600349,-1.246529 54.600752,-1.245915 54.599941,-1.245832 54.599909,-1.245807 54.599911,-1.245686 54.599962,-1.245584 54.599994,-1.245013 54.600219,-1.244672 54.600364,-1.244425 54.600494,-1.244167 54.600571,-1.244048 54.600593,-1.244054 54.600605,-1.243709 54.600674,-1.243382 54.600820,-1.242351 54.601124,-1.242329 54.601101,-1.241955 54.600894,-1.241885 54.600845,-1.241862 54.600805,-1.241837 54.600792,-1.241697 54.600757,-1.241631 54.600749,-1.241580 54.600731,-1.241436 54.600726,-1.241406 54.600709,-1.241349 54.600658,-1.241331 54.600653,-1.241279 54.600595,-1.241261 54.600557,-1.241205 54.600525,-1.241081 54.600521,-1.240771 54.600548)))" # noqa: E501
expected = "MULTIPOLYGON (((-1.240771 54.600548,-1.240621 54.600571,-1.240618 54.600566,-1.240380 54.600608,-1.240094 54.600681,-1.239689 54.600800,-1.239365 54.600880,-1.239192 54.600903,-1.239082 54.600905,-1.238930 54.600894,-1.238186 54.600798,-1.237731 54.600706,-1.237607 54.600704,-1.237373 54.600645,-1.237228 54.600627,-1.237181 54.600612,-1.237163 54.600590,-1.237159 54.600500,-1.237124 54.600440,-1.237062 54.600390,-1.236918 54.600298,-1.236722 54.600197,-1.236307 54.600009,-1.236144 54.599908,-1.236060 54.599837,-1.235639 54.599828,-1.235434 54.599864,-1.235202 54.599854,-1.235063 54.599822,-1.234897 54.599755,-1.234799 54.599734,-1.234647 54.599720,-1.234565 54.599690,-1.234484 54.599638,-1.234447 54.599608,-1.234405 54.599557,-1.234306 54.599471,-1.234267 54.599451,-1.234022 54.599388,-1.233858 54.599361,-1.233446 54.599375,-1.233442 54.599417,-1.233678 54.601451,-1.233948 54.603642,-1.236817 54.603639,-1.246748 54.603569,-1.250048 54.601986,-1.250198 54.601952,-1.249817 54.601682,-1.248889 54.601045,-1.248357 54.600664,-1.247944 54.600349,-1.246529 54.600752,-1.245915 54.599941,-1.245832 54.599909,-1.245807 54.599911,-1.245686 54.599962,-1.245584 54.599994,-1.245013 54.600219,-1.244672 54.600364,-1.244425 54.600494,-1.244167 54.600571,-1.244048 54.600593,-1.244054 54.600605,-1.243709 54.600674,-1.243382 54.600820,-1.242351 54.601124,-1.242329 54.601101,-1.241955 54.600894,-1.241885 54.600845,-1.241862 54.600805,-1.241837 54.600792,-1.241697 54.600757,-1.241631 54.600749,-1.241580 54.600731,-1.241436 54.600726,-1.241406 54.600709,-1.241349 54.600658,-1.241331 54.600653,-1.241279 54.600595,-1.241261 54.600557,-1.241205 54.600525,-1.241081 54.600521,-1.240771 54.600548)))" # noqa: E501
assert wkt.normalise(value, issues=issues) == expected


Expand Down
Loading