-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inner boundaries for polygon #355 #356
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,19 +60,32 @@ def test_inner_boundary(self) -> None: | |
"""Test the init method.""" | ||
coords = ((1, 2), (2, 0), (0, 0), (1, 2)) | ||
inner_boundary = InnerBoundaryIs( | ||
kml_geometries=[LinearRing(kml_coordinates=Coordinates(coords=coords))], | ||
kml_geometry=LinearRing(kml_coordinates=Coordinates(coords=coords)), | ||
) | ||
|
||
assert inner_boundary.geometries == [geo.LinearRing(coords)] | ||
def test_inner_boundary(self) -> None: | ||
"""Test the init method and __bool__.""" | ||
coords = ((1, 2), (2, 0), (0, 0), (1, 2)) | ||
inner_boundary = InnerBoundaryIs( | ||
kml_geometry=LinearRing(kml_coordinates=Coordinates(coords=coords)), | ||
) | ||
|
||
assert inner_boundary.geometry == geo.LinearRing(coords) | ||
assert bool(inner_boundary) is True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate method definition: The method Apply this diff to remove the duplicate method: -def test_inner_boundary(self) -> None:
- """Test the init method."""
- coords = ((1, 2), (2, 0), (0, 0), (1, 2))
- inner_boundary = InnerBoundaryIs(
- kml_geometry=LinearRing(kml_coordinates=Coordinates(coords=coords)),
- )
-
- assert inner_boundary.geometry == geo.LinearRing(coords)
- assert inner_boundary.to_string(prettyprint=False).strip() == (
- '<kml:innerBoundaryIs xmlns:kml="http://www.opengis.net/kml/2.2">'
- "<kml:LinearRing><kml:coordinates>"
- "1.000000,2.000000 2.000000,0.000000 0.000000,0.000000 1.000000,2.000000"
- "</kml:coordinates></kml:LinearRing></kml:innerBoundaryIs>"
- )
|
||
assert inner_boundary.to_string(prettyprint=False).strip() == ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indentation error at line 75 There is an indentation issue starting at line 75, which leads to a 🧰 Tools🪛 Ruff
|
||
'<kml:innerBoundaryIs xmlns:kml="http://www.opengis.net/kml/2.2">' | ||
"<kml:LinearRing><kml:coordinates>" | ||
"1.000000,2.000000 2.000000,0.000000 0.000000,0.000000 1.000000,2.000000" | ||
"</kml:coordinates></kml:LinearRing></kml:innerBoundaryIs>" | ||
) | ||
|
||
def test_read_inner_boundary(self) -> None: | ||
"""Test the from_string method.""" | ||
def test_read_inner_boundary_multiple_linestrings(self) -> None: | ||
""" | ||
Test the from_string method. | ||
|
||
When there are multiple LinearRings in the innerBoundaryIs element | ||
only the first one is used. | ||
""" | ||
inner_boundary = InnerBoundaryIs.class_from_string( | ||
'<kml:innerBoundaryIs xmlns:kml="http://www.opengis.net/kml/2.2">' | ||
"<kml:LinearRing>" | ||
|
@@ -85,18 +98,9 @@ def test_read_inner_boundary(self) -> None: | |
"</kml:innerBoundaryIs>", | ||
) | ||
|
||
assert inner_boundary.geometries == [ | ||
geo.LinearRing(((1, 4), (2, 0), (0, 0), (1, 4))), | ||
geo.LinearRing( | ||
( | ||
(-122.366212, 37.818977, 30), | ||
(-122.365424, 37.819294, 30), | ||
(-122.365704, 37.819731, 30), | ||
(-122.366488, 37.819402, 30), | ||
(-122.366212, 37.818977, 30), | ||
), | ||
), | ||
] | ||
assert inner_boundary.geometry == geo.LinearRing( | ||
((1, 4), (2, 0), (0, 0), (1, 4)), | ||
) | ||
|
||
|
||
class TestBoundariesLxml(Lxml, TestBoundaries): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Test case for handling multiple LinearRings in innerBoundaryIs
This test now correctly checks that only the first LinearRing is used when multiple are present in the XML. Consider adding a warning or log message in the implementation to inform users when additional LinearRings are ignored.