keyhole markup language (kml) eric bohn keith krupp

21
Keyhole Markup Language (KML) Eric Bohn Keith Krupp

Upload: iris-pearson

Post on 25-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Keyhole Markup Language(KML)

Eric BohnKeith Krupp

What is KML? How Is KML Used? Where Did KML Come From? Where Is It Heading?KML is a XML-based language schema describing a geographic vocabulary used by geobrowser applications

on two or three dimensional Earth maps.KML was developed by Keyhole, Inc. along with the Earth Viewer application in 2001. Keyhole, Inc. was

acquired by Google in 2004 and KML was converted for use for the Google Earth, Google Maps and Google Mobile applications.

The word Keyhole comes from an American military reconnaissance satellite program developed in the 1970's.The Google Earth program both produces and consumes KML files.KML uses the three-dimensional geographic reference system of longitude, latitude, and altitude to describe a

basic point of view in space over or on the surface of the Earth; then adds more specific control over that view with heading, tilt, and roll factors.

KML also offers the ability to add text information, graphic overlays, 3-D polygons, paths, icons and add embedded files (images or auditory) to enhance the experience of the geobrowser applications.

In April 2008 the 2.2 KML language specification was accepted by the Open Geospatial Consortium as the official standard for geobrowser applications.

KML shares same structural grammar as the Geography Mark Up Language (GML) but provides more 3-dimensional graphical functionality.

Like all XML, KML must begin with the XML header information followed by the KML root element tags. The kml 2.2 namepace specification must be present in all KML files, and the gx namespace for Touring elements.

<?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"> . . .</kml>

Basic Placemark

<<?xml version="1.0" encoding="UTF-8"?>

<kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark> <name>Gonda Building Rochester MN</name> <description>An example of a simple placemark on known terrain.</description> <Point> <coordinates>-92.46651823514594,44.02303521347328,0</coordinates> </Point> </Placemark></kml>

A Placemark object contains the following elements:

· Name - the label for the Placemark · Description - appears in the "balloon" attached to the Placemark · Point- the position of the Placemark on the Earth's surface (longitude, latitude, and optional altitude) · Auto-markup automatically converts text such as www.test.com into active hyperlinks in the description.· A CDATA tag or and HTML characters can be used to enhance the description (&lt;&gt)

Import Features

A coordinate element consists of three floating point values (longitude, latitude, and altitude). Latitude is degrees north or south of the Equator (0 degrees). Values range from - 90 degrees to 90

degrees.

Longitude is the angular distance in degrees, relative to the Prime Meridian. Values west range from -180 to 0 degrees and east o range from 0 to 180 degrees.

Altitude is the distance of the camera from the earth's surface in meters interpreted according to the altitudeMode element.

altitudeMode values include:relativeToGround – (default) meters above the ground or level of water body.clampToGround - exactly terrain or sea level height.absolute - meters above sea level

Heading is the direction (azimuth) in degrees from due North 0 to 360 degrees.

Tilt is the rotation in degrees around the X axis. A value of 0 indicates that the view is aimed straight down toward the earth (default), a value for 90 indicates that the view is aimed toward the horizon, values greater than 90 indicate that the view is pointed up into the sky. Values for are clamped at +180 degrees.

Roll is the rotation, in degrees around the Z axis. Values range from - 180 to +180 degrees

LookAt Element

<?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"> <Placemark>

<name>Machu Picchu, Peru</name>

<LookAt>

<longitude>-72.503364</longitude>

<latitude>-13.209676</latitude>

<altitude>0</altitude>

<range>14794.882995</range>

<tilt>66.768762</tilt>

<heading>71.131493</heading>

</LookAt>

<styleUrl>#msn_icon12</styleUrl>

<Point>

<coordinates>-72.516244,-13.162806,0</coordinates>

</Point>

</Placemark>

</kml>

LookAt specifies the view of a virtual camera in terms of the point of interest that is being viewed. Heading is the direction from due North in degrees.

Camera Element<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>Golden Gate tour</name> <open>1</open> <Camera> <longitude>-122.4790</longitude> <latitude>37.8110</latitude> <altitude>127</altitude> <heading>18.0</heading> <tilt>85</tilt> <altitudeMode>absolute</altitudeMode> </Camera> </Document></kml>

Camera specifies the view in terms of the viewer's position and orientation.

Overlays

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Folder> <name>Ground Overlays</name> <description>Example of a ground overlay</description> <GroundOverlay> <name>Picture over Previous Location</name> <description>Overlay a picture of Rochester MN.</description> <Icon> <href>http://www.soldiersfield.com/images/hotelmayo07website_001.jpg</href> </Icon> <LatLonBox> <north>44.02378751187333</north> <south>44.0222828739314</south> <east>-92.46506916608553</east> <west>-92.46796737309303</west> </LatLonBox> </GroundOverlay> </Folder></kml>

The The <Icon> element contains the link to the .jpg file with the overlay image. The positioning of a ground overlay is controlled by the <LatLonBox> tag. Bounding values are given for the north and south latitudes, and east and west longitudes. Image formats supported are JPG, BMP, GIF, TIFF, TGA, and PNG.

Paths & Styles<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>Test Path</name><Style id="yellowLineGreenPoly"> <LineStyle> <color>7f00ffff</color> <width>4</width> </LineStyle> <PolyStyle> <color>7f00ff00</color> </PolyStyle> </Style><Placemark> <name>Test Path</name> <styleUrl>"yellowLineGreenPoly"</styleUrl> <LineString> <extrude>1</extrude> <tessellate>1</tessellate> <coordinates>-92.46649892642886,44.021611182648,0 -92.4663867057954,44.02163817950477,0 -92.46604892696915,44.02163820523538,0 -

92.46593632931734,44.02163821434633,0 -92.46571114915615,44.02163823003409,0 -

92.46548596234992,44.02163824608964,0 -92.46533583572284,44.02163825634765,0 -92.46514811302795,44.02161126197234,0

-92.46499818064358,44.02161125789062,0 -92.46481099578385,44.02161124132853,0 -92.46462408744513,44.02161120429276,0 -92.46443715040525,44.02161116735184,0

-92.46428760269356,44.02163815324332,0 -92.46410061298926,44.02163811674728,0 -92.46395102184133,44.02166510948038,0 -92.4637639797633,44.02166507438202,0

-92.46353921861345,44.02166505125623,0 -92.46346424194114,44.0216650455531,0

</coordinates> </LineString> </Placemark> </Document></kml>

A path is created by a <LineString> element.

The <tessellate> tag breaks the line up into smaller chunks, and the <extrude> tag extends the line down to the ground.

When a Style and an ID is defined it can be used by Geometry, Placemarks, and Overlays, referred to as shared styles. The Style can be referenced multiple times, using the <styleUrl> element preceding the Style ID with a # sign. If the Style definition is in an external file, include the complete URL in the <styleUrl> element. A Document is a container for features and styles. This element is required if your KML file uses shared styles.

Highlighted Icons<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <name>Highlighted Icon</name> <description>Place your mouse over the icon to see it display the new

icon</description> <Style id="highlightPlacemark"> <IconStyle> <Icon> <href>http://maps.google.com/mapfiles/kml/paddle/red-stars.png</href> </Icon> </IconStyle> </Style> <Style id="normalPlacemark"> <IconStyle> <Icon> <href>http://maps.google.com/mapfiles/kml/paddle/wht-blank.png</href> </Icon> </IconStyle> </Style> <StyleMap id="exampleStyleMap"> <Pair> <key>normal</key> <styleUrl>#normalPlacemark</styleUrl> </Pair> <Pair> <key>highlight</key> <styleUrl>#highlightPlacemark</styleUrl> </Pair> </StyleMap> <Placemark> <name>Roll over this icon</name> <styleUrl>#exampleStyleMap</styleUrl> <Point> <coordinates>-122.0856545755255,37.42243077405461,0</coordinates> </Point> </Placemark> </Document></kml>

Define a <Style> for the Placemark's normal icon including an <Icon> with an <href> to the actual image to use. Define a <Style> for the Placemark's highlight icon and assign an ID to it. Create the <StyleMap> element and assign an ID to it. The Placemark will refer to this ID. In the <StyleMap> element, specify "#normalicon" for the normal state. In the <StyleMap> element, specify "#highlightincon" for the highlight state. In the Placemark, add a <styleUrl> element that refers to the stylmap.

Polygons

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark> <name>The Pentagon</name> <Polygon> <extrude>1</extrude> <altitudeMode>relativeToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <coordinates> -77.05788457660967,38.87253259892824,100 -77.05465973756702,38.87291016281703,100 -77.05315536854791,38.87053267794386,100 -77.05552622493516,38.868757801256,100 -77.05844056290393,38.86996206506943,100 -77.05788457660967,38.87253259892824,100 </coordinates> </LinearRing> </outerBoundaryIs> <innerBoundaryIs> <LinearRing> <coordinates> -77.05668055019126,38.87154239798456,100 -77.05542625960818,38.87167890344077,100 -77.05485125901024,38.87076535397792,100 -77.05577677433152,38.87008686581446,100 -77.05691162017543,38.87054446963351,100 -77.05668055019126,38.87154239798456,100 </coordinates> </LinearRing> </innerBoundaryIs> </Polygon> </Placemark></kml>

The polygon is made of simple inner and outer rings extruded down to the ground, then adding fill.

Screen Overlays

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"> <ScreenOverlay> <name>Absolute Positioning: Top left</name> <Icon> <href>http://code.google.com/apis/kml/documentation/top_left.jpg</href> </Icon> <overlayXY x="0" y="1" xunits="fraction" yunits="fraction"/> <screenXY x="0" y="1" xunits="fraction" yunits="fraction"/> <rotationXY x="0" y="0" xunits="fraction" yunits="fraction"/> <size x="0" y="0" xunits="fraction" yunits="fraction"/> </ScreenOverlay></kml>

Screen overlays cannot be authored directly within Google Earth. Positioning is controlled by mapping a point in the image specified by <overlayXY> to a point on the screen specified by <screenXY>. In this case, the top-left corner of the image (0,1) has been made coincident with the same point on the screen.

KMZ File

A KMZ file consists of a main KML file and zero or more supporting files that are compressed and packaged with a zip application into an archive file with a .kmz suffix. The KMZ file can be stored, emailed and loaded from a web server. When the KMZ file is unzipped, the main .kml file and its supporting files are separated into their original formats and directory structure, with their original filenames and extensions. The kml file can then be run with Google Earth.

XML Schema For KML

To validate a KML XML document download the KML XML Schema document at: http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd

Change the following code in the ogckml22.xsd from a hard coded file location to a web link URL:

<!-- import atom:author and atom:link --> <import namespace="http://www.w3.org/2005/Atom" schemaLocation="http://schemas.opengis.net/kml/2.2.0/atom-author-link.xsd"/>

Add the xsi namespace and schemaLocation to the KML XML document you want to validate: <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 ogckml22.xsd">

Google Earth:- KML was originally developed for Google Earth

- Originally called Keyhole Earth Viewer- Originally created by Keyhole, Inc

- Acquired by Google in 2004- First program to view and graphically edit KML files.- Maps the Earth by superimposing images obtained from satellite imagery, aerial photography, and GIS 3D globe.- Easy navigation using mouse and control button.- Most of Earth is available in 2D imagery only, but some places have 3D available.

- 3D images of buildings and terrain are made available through digital elevation model imagery collected by NASA’s Shuttle Radar Topography Mission.

- Able to overlay images for comparing different types of information- Scale must be accurate, but image conforms to topography.

- Capability to build 3D models of cities- Irish town of Westport first to do so.- Helpful in promoting cities, and using for navigating city.

- Flight simulator (ctrl + alt + a)

Google Earth 5.0, Touring

- Allows controlled flights through geospatial data- Specific flight druations between locations- Smooth flight past locations without stopping- Play sound files at predetermined times during the tour

-KML elements that define tours are containted within a set of extensions, using the gx prefix.

- <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">- Tours are constructed by placing specific elements, in order, into a KML file.

- The KML file can contain any other legal KML elements together with the tour.

- Tours are made up of a series of tour primitives - FlyTos, Waits, TourControls, AnimatedUpdates, and SoundCues.- Tours move from location to location, each of which specified with a <gx:flyTo>- Updates to KML can take place during the tour

Google Earth 5.0, Touring:

- Some of these primitives are played one after the other, waiting for one primitive to complete before beginning the next. Others run parallel to other primitives, so that multiple actions can occur simultaneously.

Comparable Products:

-Marble-NASA World Wind-Xplanet-Earth 3D-ESRI ArcGIS Explorer

Marble

-Virtual globe and world atlas you can use to learn more about Earth-Mouse click on a place will bring up a wikipedia article-Can measure distances between locations, and/or view weather-Different “thematic” maps

- Topographic view- Satellite view- Night view- Street map

-Free Open source software that promotes the use of free maps-Can be used in C++/Qt 4.x applications-Compatible with KML

NASA World Wind

- Developed by NASA staff and open source community members- Uses satellite imagery and elevation data to create a 3D view of Earth- Can be used with other planets- Compatible with KML/KMZ with KML/KMZ plug in

- Differences between Google Earth and NASA World Wind- Google Earth commercially produced, World Wind is not entirely.- Google Earth uses commercial satellite imagery which allows it to

have more data than world wind.- Google Earth can’t be extended with user with user-authored add-

ins or plug-ins like world wind can- Add-ons and plug-ins for Google Earth created in KML can now be

used in world wind- World Wind covers more planets- World wind comes with more views out of the box

Conclusion

-With KML recognized as the standard for geographic visualization it will continue to evolve and grow as more and more geographic browsers continue to be developed,And as the current geographic browsers grow it will be used more.

- KML is the international standard.-The OGC and Google have agreed to harmonize KML and GML further

- GML is Geography Markup Language  an XML based encoding standard for geographic information. The language allows Internet browsers the ability to view web-based mapping without additional components or viewers- This will allow for smoother interoperability between geographic browsers.

References

http://code.google.com/apis/kml/documentation/kml_tut.htmlhttp://code.google.com/apis/kml/documentation/kmlreference.htmlhttp://code.google.com/apis/kml/documentation/touring.htmlhttp://code.google.com/apis/kml/documentation/whatiskml.htmlhttp://en.wikipedia.org/wiki/Keyhole_Markup_Languagehttp://en.wikipedia.org/wiki/CityGMLhttp://www.earth3d.org/http://create.landprint.com/index.htmlhttp://worldwind.arc.nasa.gov/java/index.htmlhttp://edu.kde.org/marble/http://www.opengeospatial.org/standards/kml