Table of Contents

Class KmlImport

Namespace
LansMap.Core.Import

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
object
KmlImport

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

document KmlDocument

Parsed KML from Parse(string).

markers MarkerStore

Receives one marker per Point.

polylines PolylineStore

Receives one polyline per LineString.

polygons PolygonStore

Receives one polygon per Polygon outer ring.

markerSizePx float

Marker size in screen px (markers import in SceneSize, the map-pin behaviour).

markerColorRgba uint

Marker fill, packed 0xRRGGBBAA.

lineWidthPx float

Polyline width in screen px.

lineColorRgba uint

Polyline color, packed 0xRRGGBBAA.

polygonFillRgba uint

Polygon fill, packed 0xRRGGBBAA.

markerInfo MarkerInfoStore

Optional. 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.

useAltitudes bool

True 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

KmlImport.Result

Exceptions

ArgumentNullException

document or any store is null.