Parse kml:coordinates.
302 int seen_kml_dims = 0;
308 if (xnode == NULL) lwpgerror(
"invalid KML representation");
310 for (found =
false ; xnode != NULL ; xnode = xnode->next)
312 if (xnode->type != XML_ELEMENT_NODE)
continue;
319 if (!found) lwpgerror(
"invalid KML representation");
322 kml_coord = xmlNodeGetContent(xnode);
323 p = (
char *) kml_coord;
333 while (*p && isspace(*p)) ++p;
334 for (kml_dims=0; *p ; p++)
337 if ( isdigit(*p) || *p ==
'+' || *p ==
'-' || *p ==
'.' ) {
339 errno = 0; d = strtod(p, &q);
342 lwpgerror(
"invalid KML representation");
344 if (kml_dims == 1) pt.
x = d;
345 else if (kml_dims == 2) pt.
y = d;
346 else if (kml_dims == 3) pt.
z = d;
348 lwpgerror(
"invalid KML representation");
354 if ( *q && ! isspace(*q) && *q !=
',' ) {
355 lwpgerror(
"invalid KML representation");
359 while (*q && isspace(*q)) ++q;
360 if ( isdigit(*q) || *q ==
'+' || *q ==
'-' || *q ==
'.' || ! *q ) {
361 if ( kml_dims < 2 ) lwpgerror(
"invalid KML representation");
362 else if ( kml_dims < 3 ) *hasz =
false;
363 if ( ! seen_kml_dims ) seen_kml_dims = kml_dims;
364 else if ( seen_kml_dims != kml_dims ) {
365 lwpgerror(
"invalid KML representation: mixed coordinates dimension");
372 }
else if ( *p !=
',' && ! isspace(*p) ) {
373 lwpgerror(
"invalid KML representation");
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
#define LW_TRUE
Return types for functions with status returns.
static bool is_kml_namespace(xmlNodePtr xnode, bool is_strict)
Return false if current element namespace is not a KML one Return true otherwise.
static bool is_kml_element(xmlNodePtr xn, const char *kml_name)