-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code to use the new
find_all
utility function
- Loading branch information
Showing
7 changed files
with
109 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../tests/ogc_conformance/data/kml/Document-clean.kml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Working with KML Files | ||
====================== | ||
|
||
Import the necessary modules: | ||
|
||
.. code-block:: pycon | ||
>>> from fastkml.utils import find_all | ||
>>> from fastkml import KML | ||
>>> from fastkml import Placemark, Point | ||
Open a KML file: | ||
|
||
.. code-block:: pycon | ||
>>> k = KML.parse("docs/Document-clean.kml") | ||
Extract all placemarks and print their geometries: | ||
|
||
.. code-block:: pycon | ||
>>> placemarks = list(find_all(k, of_type=Placemark)) | ||
>>> for p in placemarks: | ||
... print(p.geometry) # doctest: +ELLIPSIS | ||
... | ||
POINT Z (-123.93563168 49.16716103 5.0) | ||
POLYGON Z ((-123.940449937288 49.16927524669021 17.0, ... | ||
>>> pts = list(find_all(k, of_type=Point)) | ||
>>> for point in pts: | ||
... print(point.geometry) | ||
... | ||
POINT Z (-123.93563168 49.16716103 5.0) | ||
POINT Z (-123.1097 49.2774 0.0) | ||
POINT Z (-123.028369 49.26107900000001 0.0) | ||
POINT Z (-123.3215766 49.2760338 0.0) | ||
POINT Z (-123.2643704 49.3301853 0.0) | ||
POINT Z (-123.2477084 49.2890857 0.0) | ||
You can also define what you are looking for by specifying additional parameters: | ||
|
||
|
||
.. code-block:: pycon | ||
>>> al = list(find_all(k, name="Vancouver Film Studios")) | ||
>>> al[0].name | ||
'Vancouver Film Studios' | ||
>>> al[0].get_tag_name() | ||
'Placemark' | ||
>>> list(find_all(k, href="http://www.vancouverfilmstudios.com/")) # doctest: +ELLIPSIS | ||
[fastkml.atom.Link(ns=... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters