- Notifications
You must be signed in to change notification settings - Fork1
Google Earth Writer in Pure Julia
License
NotificationsYou must be signed in to change notification settings
JuliaComputing/KML.jl
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Working with Google Earth's KML format in Julia.
This package takes inspiration from Python'ssimplekmlpackage.
file=KMLFile(Document( Features= [Placemark( Geometry=Point(coordinates=(77.0369,38.9072)), name="Washington, D.C." ) ] ))
<?xml version="1.0" encoding="UTF-8"?><kmlxmlns="http://earth.google.com/kml/2.2"> <Document> <Placemark> <name>Washington, D.C.</name> <Point> <coordinates>77.0369,38.9072</coordinates> </Point> </Placemark> </Document></kml>
path=download("https://developers.google.com/kml/documentation/KML_Samples.kml")file=read(path, KMLFile)
KML.write(filename::String, kml_file)# Write to fileKML.write(io::IO, kml_file)# Write to IO streamKML.write(kml_file)# String
This package is designed to be used intuitively alongsideGoogle's KML Reference Page. Thus, there are rules that guide the mapping between KML (XML) Objects and Julia structs.
- In Julia, each
Objectis constructed with keyword arguments only. - Keywords are the associated attributes as well as child elements of the
Object- E.g.
pt = Point(id="mypoint", coordinates=(0,1))sets theidattribute andcoordinateschild element.
- E.g.
- Every keyword has a default value (most often
nothing). They can be set after construction.- E.g.
pt.coordinates = (2, 3)
- E.g.
- If a child element is itself an
Object, the keyword matches the type name.- E.g.
pl = Placemark(); pl.Geometry = Point(). Here, aPlacemarkcan hold anyGeometry, which is an abstract type. APointis a subtype ofGeometry.
- E.g.
- Some
Objects can hold several children of the same type. Fields with plural names expect aVector.- E.g.
mg = MultiGeometry(); mg.Geometries = [Point(), Polygon()]
- E.g.
- Enum types are in the
KML.Enumsmodule. However, you shouldn't need to create them directly as conversion is handled for you/helpful error messages are provided.
julia> pt.altitudeMode="clamptoground"ERROR: altitudeMode∉ clampToGround, relativeToGround, absolute
- Google extensions (things with
gx:in the name) replace:with_.- E.g.
gx:altitudeMode→gx_altitudeMode
- E.g.
Fields≡≡≡≡≡≡≡≡id :: Union{Nothing, String}targetId :: Union{Nothing, String}name :: Union{Nothing, String}visibility :: Union{Nothing, Bool}open :: Union{Nothing, Bool}atom_author :: Union{Nothing, String}atom_link :: Union{Nothing, String}address :: Union{Nothing, String}xal_AddressDetails :: Union{Nothing, String}phoneNumber :: Union{Nothing, String}Snippet :: Union{Nothing, KML.Snippet}description :: Union{Nothing, String}AbstractView :: Union{Nothing, KML.AbstractView} # Camera or LookAtTimePrimitive :: Union{Nothing, KML.TimePrimitive} # TimeSpan or TimeMapstyleURL :: Union{Nothing, String}StyleSelector :: Union{Nothing, KML.StyleSelector} # Style or StyleMapregion :: Union{Nothing, KML.Region}ExtendedData :: Union{Nothing, KML.ExtendedData}Schemas :: Union{Nothing, Vector{KML.Schema}} # Multiple Schemas allowedFeatures :: Union{Nothing, Vector{KML.Feature}} # Multiple Features (abstract type) allowedAbout
Google Earth Writer in Pure Julia
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.