Skip to content
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

etree_element dump fails if MultiGeometry is empty #221

Closed
TimSC opened this issue Feb 10, 2023 · 2 comments
Closed

etree_element dump fails if MultiGeometry is empty #221

TimSC opened this issue Feb 10, 2023 · 2 comments
Labels

Comments

@TimSC
Copy link

TimSC commented Feb 10, 2023

Traceback (most recent call last):
  File "/home/tim/Desktop/testkml.py", line 33, in <module>
    print (k.etree_element())
  File "/home/tim/.local/lib/python3.10/site-packages/fastkml/kml.py", line 127, in etree_element
    root.append(feature.etree_element())
  File "/home/tim/.local/lib/python3.10/site-packages/fastkml/kml.py", line 990, in etree_element
    element = super(Document, self).etree_element()
  File "/home/tim/.local/lib/python3.10/site-packages/fastkml/kml.py", line 616, in etree_element
    element.append(feature.etree_element())
  File "/home/tim/.local/lib/python3.10/site-packages/fastkml/kml.py", line 616, in etree_element
    element.append(feature.etree_element())
  File "/home/tim/.local/lib/python3.10/site-packages/fastkml/kml.py", line 1104, in etree_element
    element.append(self._geometry.etree_element())
  File "/home/tim/.local/lib/python3.10/site-packages/fastkml/geometry.py", line 287, in etree_element
    raise ValueError("Illegal geometry type.")
ValueError: Illegal geometry type.

Input kml:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
	<name>zred.kml</name>
	<Folder>
		<name>Red</name>
		<open>1</open>
		<Placemark>
			<name>Untitled Path</name>
            <MultiGeometry>
            </MultiGeometry>
		</Placemark>

	</Folder>
</Document>
</kml>

The spec seems to allow for empty MultiGeometry https://developers.google.com/kml/documentation/kmlreference#multigeometry

<MultiGeometry id="ID">
  <!-- specific to MultiGeometry -->
  <!-- 0 or more Geometry elements -->
</MultiGeometry>
@cleder
Copy link
Owner

cleder commented Feb 10, 2023

Geometries are currently refactored in https://github.com/cleder/fastkml/tree/refactor-geometry I hope to address this in that branch

@cleder cleder added the bug label Feb 10, 2023
@cleder
Copy link
Owner

cleder commented Feb 10, 2023

#84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants