Class KmlImport
Turns a parsed KmlDocument into map content: Point placemarks become bulk-tier markers, LineStrings become polylines, Polygons become filled polygons.
public static class KmlImport
- Inheritance
-
objectKmlImport
Remarks
Setup-time glue, not frame-loop code: call it once after Parse(string) and hand the stores to the render layers as usual. Nothing here throws on document content - damaged geometry (a one-point line, a ring that will not triangulate) is counted on the KmlImport.Result instead, because an imported file is user data and a bad shape in it is an expected outcome.
Altitudes are ignored unless useAltitudes is true. KML's
default altitudeMode is clampToGround, and the parser does not read
altitudeMode, so drawing every file's third coordinate as raised
content would float geometry most files mean to sit on the map.
Opting in also permanently raises the stores' max-altitude watermark
(see MaxAltitudeMercator for the re-anchor
cost that carries).
Polygon holes (inner rings) are not drawn: PolygonStore triangulates a single ring. Dropped holes are counted on PolygonHolesDropped so a caller can warn rather than lose them silently.
MultiGeometry needs no handling here: KmlParser already flattens it onto the owning placemark's geometry lists.
Methods
Import(KmlDocument, MarkerStore, PolylineStore, PolygonStore, float, uint, float, uint, uint, MarkerInfoStore, bool)
Imports every placemark in document into the
three stores and reports what was added and what was skipped.
public static KmlImport.Result Import(KmlDocument document, MarkerStore markers, PolylineStore polylines, PolygonStore polygons, float markerSizePx, uint markerColorRgba, float lineWidthPx, uint lineColorRgba, uint polygonFillRgba, MarkerInfoStore markerInfo = null, bool useAltitudes = false)
Parameters
documentKmlDocumentParsed KML from Parse(string).
markersMarkerStoreReceives one marker per Point.
polylinesPolylineStoreReceives one polyline per LineString.
polygonsPolygonStoreReceives one polygon per Polygon outer ring.
markerSizePxfloatMarker size in screen px (markers import in SceneSize, the map-pin behaviour).
markerColorRgbauintMarker fill, packed 0xRRGGBBAA.
lineWidthPxfloatPolyline width in screen px.
lineColorRgbauintPolyline color, packed 0xRRGGBBAA.
polygonFillRgbauintPolygon fill, packed 0xRRGGBBAA.
markerInfoMarkerInfoStoreOptional. When given, a placemark's non-empty name becomes the marker's name and its non-empty description becomes the hover text, for every marker that placemark produced. The marker store itself carries no text, by design; this store is where marker text lives.
useAltitudesboolTrue to place markers and polyline points at their KML altitude instead of on the map plane. See the type remarks for why the default is false.
Returns
Exceptions
- ArgumentNullException
documentor any store is null.