Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Google Earth Writer in Pure Julia

License

NotificationsYou must be signed in to change notification settings

JuliaComputing/KML.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Working with Google Earth's KML format in Julia.

This package takes inspiration from Python'ssimplekmlpackage.



Quickstart

Writing

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>

Reading

path=download("https://developers.google.com/kml/documentation/KML_Samples.kml")file=read(path, KMLFile)

Writing

KML.write(filename::String, kml_file)# Write to fileKML.write(io::IO, kml_file)# Write to IO streamKML.write(kml_file)# String


KML Objects ←→ Julia structs

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.

  1. In Julia, eachObject is constructed with keyword arguments only.
  2. Keywords are the associated attributes as well as child elements of theObject
    • E.g.pt = Point(id="mypoint", coordinates=(0,1)) sets theid attribute andcoordinates child element.
  3. Every keyword has a default value (most oftennothing). They can be set after construction.
    • E.g.pt.coordinates = (2, 3)
  4. If a child element is itself anObject, the keyword matches the type name.
    • E.g.pl = Placemark(); pl.Geometry = Point(). Here, aPlacemark can hold anyGeometry, which is an abstract type. APoint is a subtype ofGeometry.
  5. SomeObjects can hold several children of the same type. Fields with plural names expect aVector.
    • E.g.mg = MultiGeometry(); mg.Geometries = [Point(), Polygon()]
  6. Enum types are in theKML.Enums module. 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
  1. Google extensions (things withgx: in the name) replace: with_.
    • E.g.gx:altitudeModegx_altitudeMode




For a concrete example, examine the fields of aKML.Document:

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) allowed


About

Google Earth Writer in Pure Julia

Topics

Resources

License

Stars

Watchers

Forks

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp