sharpkml
sharpkml copied to clipboard
Wrong parsing result for KML file with leading commas in the coordinates
Hi! We are getting an odd behavior while parsing files with leading commas and without altitude values.
current behavior: What the parser is doing is returning a geometry with a single vector taking (firstPoint.Latitude, firstPoint.longitude, secondPointLatitude) and throwing away the rest of the coordinates. We use the files on google earth and seems to be working fine as we can see in the attached image
expected behavior: we would expect to receive a parser error or maybe just ignore the "," characters as google earth does.
File example:
<?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" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Untitled Project</name>
<gx:CascadingStyle kml:id="__managed_style_2A6D6AD34423575D18C9">
<Style>
<IconStyle>
<scale>1.2</scale>
<Icon>
<href>https://earth.google.com/earth/rpc/cc/icon?color=1976d2&id=2000&scale=4</href>
</Icon>
<hotSpot x="64" y="128" xunits="pixels" yunits="insetPixels"/>
</IconStyle>
<LabelStyle>
</LabelStyle>
<LineStyle>
<color>ff2dc0fb</color>
<width>6</width>
</LineStyle>
<PolyStyle>
<color>40ffffff</color>
</PolyStyle>
<BalloonStyle>
<displayMode>hide</displayMode>
</BalloonStyle>
</Style>
</gx:CascadingStyle>
<gx:CascadingStyle kml:id="__managed_style_1A556FFF7423575D18C9">
<Style>
<IconStyle>
<Icon>
<href>https://earth.google.com/earth/rpc/cc/icon?color=1976d2&id=2000&scale=4</href>
</Icon>
<hotSpot x="64" y="128" xunits="pixels" yunits="insetPixels"/>
</IconStyle>
<LabelStyle>
</LabelStyle>
<LineStyle>
<color>ff2dc0fb</color>
<width>4</width>
</LineStyle>
<PolyStyle>
<color>40ffffff</color>
</PolyStyle>
<BalloonStyle>
<displayMode>hide</displayMode>
</BalloonStyle>
</Style>
</gx:CascadingStyle>
<StyleMap id="__managed_style_0B0498AB9323575D18C9">
<Pair>
<key>normal</key>
<styleUrl>#__managed_style_1A556FFF7423575D18C9</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#__managed_style_2A6D6AD34423575D18C9</styleUrl>
</Pair>
</StyleMap>
<Placemark id="0465ADB7B023575D18B1">
<name>SamplePolygon</name>
<LookAt>
<longitude>-96.37549845507505</longitude>
<latitude>33.69573399847625</latitude>
<altitude>161.6919297143338</altitude>
<heading>0</heading>
<tilt>0</tilt>
<gx:fovy>35</gx:fovy>
<range>1493.557827594923</range>
<altitudeMode>absolute</altitudeMode>
</LookAt>
<styleUrl>#__managed_style_0B0498AB9323575D18C9</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-96.3771267813479,33.69746891969778, -96.37757927526032,33.69532740118915, -96.37468917139492,33.69530114437216, -96.37444803536881,33.69749495506764, -96.3771267813479,33.69746891969778,</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
result of loading the file on google earth:

Please let me know if you need any extra details from my side. Thanks!!