You are on page 1of 50

Advanced KML

Bent Hagemark
May 29, 2008
Overview

OGC Standard
KML Architecture
Advanced features
Future enhancement
OGC Standard
OGC KML 2.2

April 14, 2008


Standard: 07-147r2
Abstract Test Suite: 07-134r2
100% "Google" KML 2.2 compatible
xmlns="http://www.opengis.net/kml/2.2"
OGC KML 2.2

www.opengeospatial.org/standards/kml
schemas.opengis.net/kml/2.2.0/ogckml22.xsd
code.google.com/apis/kml
code.google.com/apis/kml/documentation/kmlreference.html
KML Architecture
KML Architecture

Object
Feature
Geometry
Style
Link
Extension mechanism
Object

most complex elements


id="ID"
targetId="ID" for Update
AbstractXxxObjectExtensionGroup
kml:AbstractObjectGroup (8.1)
Feature

left panel entry: name, snippet, visibility


balloon
style
viewpoint, flyTo
custom data
kml:AbstractFeatureGroup (9.1)
Feature: concrete elements

Placemark
NetworkLink
Container: Document, Folder
Overlay: GroundOverlay, PhotoOverlay, ScreenOverlay
Geometry

2d or 3d
extrude
tessellate
kml:AbstractGeometryGroup (10.1)
Geometry: concrete elements

Point (icon)
LineString, LinearRing
Polygon
Model (textured 3d)
MultiGeometry
Style

shared style (6.4)


inline style
style resolution
kml:AbstractStyleSelectorGroup (12.1)
Style: concrete elements

Style
StyleMap
styleUrl
SubStyle: BalloonStyle, ListStyle, ColorStyle
ColorStyle: IconStyle, LabelStyle, LineStyle, PolyStyle
Link

href
network-shared style
network-shared schema
images, 3d models, more KML
balloon
ascription
Link: concrete elements

NetworkLink/Link/href
Overlay/Icon/href
Model/Link/href
styleUrl
schemaUrl
html:img src="..."
html:a href="..."
atom:link
Extension mechanism

ExtendedData/Data
Document/Schema, ExtendedData/SchemaData
ExtendedData/XML
XSD extension mechanism
XML and JavaScript

same model (same system!)


code.google.com/apis/kml/documentation
code.google.com/apis/earth
Advanced features
Review: Basic features

Placemark
Overlay
Folder
Style
NetworkLink
Advanced features

Region
Time
Update
ExtendedData
Region

Feature LOD
visibility transitions
millions of points
SuperOverlay
Region: any Feature

Placemark: visibility
NetworkLink: fetch
Overlay: fetch of image and visibility
Document/Folder: cascade
Region: simple effects

simple Lod
pop in and out
fade
clean swap with fade
Region: Example 1: simple Lod

<Placemark>

<Region>
<Lod>
<minLodPixels>128</minLodPixels>
</Lod>
<LatLonAltBox>...</LatLonAltBox>
</Region>

<Point>...</Point>

</Placemark>
Region: Example 2: pop in and out

<Placemark>

<Region>
<Lod>
<minLodPixels>128</minLodPixels>
<maxLodPixels>512</maxLodPixels>
</Lod>
<LatLonAltBox>...</LatLonAltBox>
</Region>

<Point>...</Point>

</Placemark>
Region: Example 3: clean swap

<Placemark id="coarse">

<Region>
<Lod> <!-- minLodPixels defaults to 0 -->
<maxLodPixels>256</maxLodPixels>
</Lod>
<LatLonAltBox>...</LatLonAltBox>
</Region>

<Point>...</Point> <!-- "come look here" -->

</Placemark>
Region: Example 3: clean swap

<Placemark id="fine">

<Region>
<Lod>
<minLodPixels>256</minLodPixels>
</Lod> <!-- maxLodPixels defaults to -1 "infinite" -->
<LatLonAltBox>...</LatLonAltBox>
</Region>

<Polygon>...</Polygon> <!-- more detail -->

</Placemark>
Region: NetworkLink

<NetworkLink>

<Region>
<Lod>
<minLodPixels>256</minLodPixels>
</Lod>
<LatLonAltBox>...</LatLonAltBox>
</Region>
<Link>
<href>load-when-viewer-close-enough.kml</href>
<viewRefreshMode>onRegion</viewRefreshMode>
</Link>
</NetworkLink>
Region: "RbNL" and tools

cascade of Region-based NetworkLinks


KML Layers
code.google.com/p/regionator
csvregionator.py - CSV -> RbNL
placemarks.py - KML -> RbNL
checklinks.py - walks RbNL
checkregions.py - checks RbNL Regions
code.google.com/p/libkml
Region: "RbNL" Google Earth layers

Rumsey Historical Maps


Gigapan/Gigapxl Photos
YouTube
Books
News
Weather
Region: SuperOverlay

"RbNL" of GroundOverlays
Examples:
Google Earth Weather
disaster imagery
Region: tips and tricks

focus on Lod, especially minLodPixels


minLodPixels most likely > 128
Region with any Feature including ScreenOverlay
minLodPixels = 1/2 wid/ht of image tile
256x256 image -> minLodPixels 128
512 is 1/4 a typical screen
Time

Feature
TimeStamp
TimeSpan
Example: Google Earth Weather
Time: tips and tricks

TimeStamp for Points


TimeStamp: geographically non-coincident
TimeSpan for Overlays
TimeSpan: geographically coincident
Containers cascade
checkHideChildren
Update

Change
Create
Delete
Example: Santa
Update: Change

<!-- original fetched with NetworkLink -->


<kml xmlns="www.opengis.net/kml/2.2">
<Folder>
<Placemark id="p1">
<name>Point @ 3,-4.2</name>
<description>My movable Point</description>
<styleUrl>#some-style</styleUrl>
<Point>
<extrude>true</extrude>
<coordinates>3,4.2</coordinates>
</Point>
</Placemark>
</Folder>
</kml>
Update: Change

<kml><NetworkLinkControl>
<Update>
<Change>
<Placemark targetId="p1">
<name>Point @ 3,-4.2</name>
<Point>
<coordinates>3,4.2</coordinates>
</Point>
</Placemark>
</Change>
</Update>
</NetworkLinkControl>
</kml>
Update: NetworkLinkControl and cookie

<kml><NetworkLinkControl>
<!-- name=value compat with cgi parsing -->
<cookie>count=123</cookie>
<Update>
<Change>
<Placemark targetId="p1">
<Point>
<coordinates>[coords for 123]</coordinates>
</Point>
</Placemark>
</Change>
</Update>
</NetworkLinkControl></kml>
ExtendedData

Feature
Data: untyped data
Schema and SchemaData: typed data
"<xs:any>": any XML
balloon templating with shared style
Example: Google Earth Weather
(Metadata deprecated)
ExtendedData: Example: Weather

<Placemark>
<name>...</name>
<styleUrl>http://.../style.kml#sunny</styleUrl>
<ExtendedData>...</ExtendedData>
<Point>...</Point>
</Placemark>
ExtendedData: Example: Weather

<!-- style.kml -->


<Style id="sunny">
<IconStyle>
<Icon><href>sunny.jpg</href></Icon>
</IconStyle>
<LabelStyle>...</LabelStyle>
<BalloonStyle>
<text> <!-- 50 entities replaced in one template -->
...<td>$[01_Temperature]</td>...
</text>
</BalloonStyle>
</Style>
ExtendedData: Example: Weather

<ExtendedData>
<Data name="location">
<value>Shillong, IN as of 2008-05-28 17:00</value>
</Data>
<Data name="00_Temperature">
<value>80°F / 27°C</value>
</Data>
<Data name="00_Phrase">
<value>Haze</value>
</Data>
</ExtendedData>
ExtendedData: Example: weather

Feature
Data: untyped data
Schema and SchemaData: typed data
"<xs:any>": any XML
balloon templating with shared style
Example: Google Earth Weather
(Metadata deprecated)
ExtendedData: tips and tricks

ExtendedData/Data
the comment trick
Future enhancement
Future enhancement

ExtendedData
XSD extension mechanism
OGC SWG
Demo
code.google.com/apis/kml

You might also like