天天看點

OGC标準介紹 9

I. KML-我從Google來

· 概述

KML(OpenGIS® KML Encoding Standard)從2.2.0版本開始由Google送出到OGC并被接受為标準,目前OGC KML的版本也就是2.2.0。

KML和GML在名稱上類似,但是功能有很大不同。GML主要用于地理資料的交換;而KML主要用于地理資料的可視化,它不僅包括地理資料的描述,還包括資料的符号化方式、使用者視角的控制等資訊。

· KML Schema

KML的Schema可以從http://schemas.opengis.net/kml/ 通路到。所有KML中耳熟能詳的Placemark、LookAt等名稱都可以在這裡找到定義,相對OGC給出的文檔,更好的關于KML Schema的參考在Google Code上http://code.google.com/intl/zh-CN/apis/kml/documentation/kml_tut.html ,這裡還有關于Schema對象的關系,如圖 11。

圖 11 KML Schema對象關系圖

注意,在圖 11中的方框中的對象是邏輯上的對象,并不真實存在于Schema定義中。還有,紅色标注的對象是Google對KML 2.2.0的擴充,在Google Earth 5.0以上版本中被支援,是以,對于需要了解KML标準的人來說,這些紅色的内容都可以被忽略。

· KML示例

關于地理資料的描述,下面是一個最簡單的描述“地标”的KML,它包含了一個點要素資訊:

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

kml xmlns="http://www.opengis.net/kml/2.2">

Placemark>

name>Simple placemarkname>

description>Attached to the ground. Intelligently places itself

at the height of the underlying terrain.description>

Point>

coordinates>-122.0822035425683,37.42228990140251,0coordinates> Point> Placemark> kml>      

下面是另外一個定義了顯示樣式的多邊形資料:

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

kml xmlns="http://www.opengis.net/kml/2.2">

Document>

Style id="transBluePoly">

LineStyle>

width>1.5width>

LineStyle>

PolyStyle> color>7dff0000color> PolyStyle> Style> Placemark> name>Building 41name> styleUrl>#transBluePolystyleUrl> Polygon> extrude>1extrude> altitudeMode>relativeToGroundaltitudeMode> outerBoundaryIs> LinearRing> coordinates> -122.0857412771483,37.42227033155257,17 -122.0858169768481,37.42231408832346,17 -122.085852582875,37.42230337469744,17 -122.0858799945639,37.42225686138789,17 -122.0858860101409,37.4222311076138,17 -122.0858069157288,37.42220250173855,17 -122.0858379542653,37.42214027058678,17 -122.0856732640519,37.42208690214408,17 -122.0856022926407,37.42214885429042,17 -122.0855902778436,37.422128290487,17 -122.0855841672237,37.42208171967246,17 -122.0854852065741,37.42210455874995,17 -122.0855067264352,37.42214267949824,17 -122.0854430712915,37.42212783846172,17 -122.0850990714904,37.42251282407603,17 -122.0856769818632,37.42281815323651,17 -122.0860162273783,37.42244918858722,17 -122.0857260327004,37.42229239604253,17 -122.0857412771483,37.42227033155257,17 coordinates> LinearRing> outerBoundaryIs> Polygon> Placemark> Document> kml> 這是一個定義了視點屬性的點要素: xml version="1.0" encoding="UTF-8"?> kml xmlns="http://www.opengis.net/kml/2.2"> Placemark> name>Machu Picchu, Peruname> LookAt> longitude>-72.503364longitude> latitude>-13.209676latitude> altitude>0altitude> range>14794.882995range> tilt>66.768762tilt> heading>71.131493heading> LookAt> Point> coordinates>-72.516244,-13.162806,0coordinates> Point> Placemark> kml>