Spaces between numbers create a problem in KML path coordinates?

206 views
Skip to first unread message

Roland Longbow

unread,
Mar 27, 2013, 6:37:14 PM3/27/13
to kml-support-g...@googlegroups.com
Hello, Everyone:

I use Fortran to create circle paths, and leave some spaces after each comma (,) as shown in the following snippet of my output results. These spaces create a problem. As a consequence, the path shows up in all the wrong places. I have to go the extra length to remove these spaces to make it work correctly.

   <coordinates>179.209671,  41.560760,  2375
              179.848038,  41.991741,  2375
             -179.509399,  42.425385,  2375
             -178.868225,  42.861984,  2375
             -178.225571,  43.301155,  2375
               ........
      </coordinates>

However, in my placemark KML files, the spaces after each comma do not seem to matter.

Could anyone tell if these spaces after commas are strictly prohibited or not? Is there a way to get around the problem without removing the spaces?

Thank you!

--R.

Message has been deleted

Jason M

unread,
Mar 28, 2013, 12:50:50 PM3/28/13
to kml-support-g...@googlegroups.com
Hi.

Yes, space after commas is strictly prohibited.

If you have them then Google Earth interprets each whitespace as a new tuple so your first line "179.209671,  41.560760,  2375"
is interpreted as 3 longitude values with no latitude/altitude so it is converted to: 179.209671,0,0 41.560760,0,0  2375.0.0

You'll find some further details on the issue of whitespace here.

Roland Longbow

unread,
Mar 28, 2013, 3:48:59 PM3/28/13
to kml-support-g...@googlegroups.com
On Thursday, March 28, 2013 12:50:50 PM UTC-4, Jason M wrote:
Hi.

Yes, space after commas is strictly prohibited.

If you have them then Google Earth interprets each whitespace as a new tuple so your first line "179.209671,  41.560760,  2375"
is interpreted as 3 longitude values with no latitude/altitude so it is converted to: 179.209671,0,0 41.560760,0,0  2375.0.0

You'll find some further details on the issue of whitespace here.

Jason: Thank you very much for the information which helps a lot!  Does this rule *not* apply to placemarks?  Each placemark has only one tuple of data, though. I have created a KML file that includes hundreds of placemarks, and I have left spaces after commas, and I have not found a problem with the spaces.      ---R.

Jason M

unread,
Mar 28, 2013, 6:01:10 PM3/28/13
to kml-support-g...@googlegroups.com
With respect to the OGC KML spec whitespace before/after commas within coordinate tuples violates the spec.

However, current version of Google Earth v7.0.3 when parsing Placemarks with Point geometry has implemented some relaxed rules allowing whitespace in coordinates for points but there is no guanantee it will work like this in future versions of GE. Likewise it may or may not work in Google Earth API, Google Maps or other KML readers so best to avoid whitespace and keep to the spec.

--jason

Jason M

unread,
Mar 29, 2013, 1:00:35 PM3/29/13
to kml-support-g...@googlegroups.com
If you're using GE 7.0 or higher then all whitespace in Placemarks with lines, rings, and polygons need to be fixed otherwise won't show up in the right location as you described.
If the KML is just for you then you don't actually need to fix whitespace within tuples for Point-only geometries.

Hope that helps.

--jason
Reply all
Reply to author
Forward
0 new messages