Add a parser for reading and writing KML.
This adds ol.parser.ogc.KML which can be used to read and write KML documents. NetworkLinks are retrieved asynchronously. Current caveats of the implementation are: * LabelStyle not yet implemented. Missing support in renderers. * When using shared structures the parser needs to be configured with dimension 2. * We need a better way to disable fill, currently we use opacity as a workaround. * We cannot really roundtrip documents, since some of the info is not preserved in the ol structures. But we can write out most of the important info.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<NetworkLink><Link><href>spec/ol/parser/ogc/xml/kml_polygon.kml</href></Link></NetworkLink>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Placemark>
|
||||
<name>Extended data placemark</name>
|
||||
<description>Attached to the ground. Intelligently places itself
|
||||
at the height of the underlying terrain.</description>
|
||||
<ExtendedData>
|
||||
<Data name="foo">
|
||||
<value>bar</value>
|
||||
</Data>
|
||||
</ExtendedData>
|
||||
<Point>
|
||||
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
</kml>
|
||||
@@ -0,0 +1,30 @@
|
||||
<kml xmlns="http://earth.google.com/kml/2.2">
|
||||
<Document>
|
||||
<Placemark>
|
||||
<name>Easy trail</name>
|
||||
<ExtendedData>
|
||||
<SchemaData schemaUrl="#TrailHeadTypeId">
|
||||
<SimpleData name="TrailHeadName">Pi in the sky</SimpleData>
|
||||
<SimpleData name="TrailLength">3.14159</SimpleData>
|
||||
<SimpleData name="ElevationGain">10</SimpleData>
|
||||
</SchemaData>
|
||||
</ExtendedData>
|
||||
<Point>
|
||||
<coordinates>-122.000,37.002</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
<Placemark>
|
||||
<name>Difficult trail</name>
|
||||
<ExtendedData>
|
||||
<SchemaData schemaUrl="#TrailHeadTypeId">
|
||||
<SimpleData name="TrailHeadName">Mount Everest</SimpleData>
|
||||
<SimpleData name="TrailLength">347.45</SimpleData>
|
||||
<SimpleData name="ElevationGain">10000</SimpleData>
|
||||
</SchemaData>
|
||||
</ExtendedData>
|
||||
<Point>
|
||||
<coordinates>-122.000,37.002</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,23 @@
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
|
||||
<Document>
|
||||
<Style id="pushpin">
|
||||
<IconStyle id="mystyle">
|
||||
<color>ffffffff</color>
|
||||
<colorMode>normal</colorMode>
|
||||
<scale>1</scale>
|
||||
<heading>0</heading>
|
||||
<Icon>
|
||||
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
|
||||
</Icon>
|
||||
<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
|
||||
</IconStyle>
|
||||
</Style>
|
||||
<Placemark id="mountainpin1">
|
||||
<name>Pin on a mountaintop</name>
|
||||
<styleUrl>#pushpin</styleUrl>
|
||||
<Point>
|
||||
<coordinates>170.1435558771009,-43.60505741890396,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<name>LineString.kml</name>
|
||||
<open>1</open>
|
||||
<LookAt>
|
||||
<longitude>-122.36415</longitude>
|
||||
<latitude>37.824553</latitude>
|
||||
<altitude>0</altitude>
|
||||
<range>150</range>
|
||||
<tilt>50</tilt>
|
||||
<heading>0</heading>
|
||||
</LookAt>
|
||||
<Placemark>
|
||||
<name>unextruded</name>
|
||||
<LineString>
|
||||
<extrude>1</extrude>
|
||||
<tessellate>1</tessellate>
|
||||
<coordinates>
|
||||
-122.364383,37.824664,0 -122.364152,37.824322,0
|
||||
</coordinates>
|
||||
</LineString>
|
||||
</Placemark>
|
||||
<Placemark>
|
||||
<name>extruded</name>
|
||||
<LineString>
|
||||
<extrude>1</extrude>
|
||||
<tessellate>1</tessellate>
|
||||
<altitudeMode>relativeToGround</altitudeMode>
|
||||
<coordinates>
|
||||
-122.364167,37.824787,50 -122.363917,37.824423,50
|
||||
</coordinates>
|
||||
</LineString>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<name>Polygon.kml</name>
|
||||
<open>0</open>
|
||||
<Placemark>
|
||||
<name>SF Marina Harbor Master</name>
|
||||
<visibility>0</visibility>
|
||||
<MultiGeometry>
|
||||
<LineString>
|
||||
<!-- north wall -->
|
||||
<coordinates>
|
||||
-122.4425587930444,37.80666418607323,0
|
||||
-122.4428379594768,37.80663578323093,0
|
||||
</coordinates>
|
||||
</LineString>
|
||||
<LineString>
|
||||
<!-- south wall -->
|
||||
<coordinates>
|
||||
-122.4425509770566,37.80662588061205,0
|
||||
-122.4428340530617,37.8065999493009,0
|
||||
</coordinates>
|
||||
</LineString>
|
||||
</MultiGeometry>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<name>Polygon.kml</name>
|
||||
<open>0</open>
|
||||
<Placemark>
|
||||
<name>SF Marina Harbor Master</name>
|
||||
<visibility>0</visibility>
|
||||
<MultiGeometry>
|
||||
<LineString>
|
||||
<!-- north wall -->
|
||||
<coordinates>
|
||||
-122.4425587930444,37.80666418607323,0
|
||||
-122.4428379594768,37.80663578323093,0
|
||||
</coordinates>
|
||||
</LineString>
|
||||
<Point>
|
||||
<coordinates>
|
||||
-122.4428340530617,37.8065999493009,0
|
||||
</coordinates>
|
||||
</Point>
|
||||
</MultiGeometry>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<Placemark>
|
||||
<name>Simple placemark</name>
|
||||
<description>Attached to the ground. Intelligently places itself
|
||||
at the height of the underlying terrain.</description>
|
||||
<Point>
|
||||
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
<NetworkLink><Link><href>spec/ol/parser/ogc/xml/kml_polygon.kml</href></Link></NetworkLink>
|
||||
<NetworkLink><Link><href>spec/ol/parser/ogc/xml/kml_point.kml</href></Link></NetworkLink>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<Placemark>
|
||||
<name>Simple placemark</name>
|
||||
<description>Attached to the ground. Intelligently places itself
|
||||
at the height of the underlying terrain.</description>
|
||||
<Point>
|
||||
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
<NetworkLink><Link><href>spec/ol/parser/ogc/xml/kml_depth.kml</href></Link></NetworkLink>
|
||||
</Document>
|
||||
</kml>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Placemark>
|
||||
<name>Simple placemark</name>
|
||||
<description>Attached to the ground. Intelligently places itself
|
||||
at the height of the underlying terrain.</description>
|
||||
<Point>
|
||||
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
</kml>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<name>Polygon.kml</name>
|
||||
<open>0</open>
|
||||
<Placemark>
|
||||
<name>hollow box</name>
|
||||
<Polygon>
|
||||
<extrude>1</extrude>
|
||||
<altitudeMode>relativeToGround</altitudeMode>
|
||||
<outerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>
|
||||
-122.366278,37.818844,30
|
||||
-122.365248,37.819267,30
|
||||
-122.365640,37.819861,30
|
||||
-122.366669,37.819429,30
|
||||
-122.366278,37.818844,30
|
||||
</coordinates>
|
||||
</LinearRing>
|
||||
</outerBoundaryIs>
|
||||
<innerBoundaryIs>
|
||||
<LinearRing>
|
||||
<coordinates>
|
||||
-122.366212,37.818977,30
|
||||
-122.365424,37.819294,30
|
||||
-122.365704,37.819731,30
|
||||
-122.366488,37.819402,30
|
||||
-122.366212,37.818977,30
|
||||
</coordinates>
|
||||
</LinearRing>
|
||||
</innerBoundaryIs>
|
||||
</Polygon>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
Reference in New Issue
Block a user