Parse kml:coordinates.
284 int seen_kml_dims = 0;
290 if (xnode == NULL) lwpgerror(
"invalid KML representation");
292 for (found =
false ; xnode != NULL ; xnode = xnode->next)
294 if (xnode->type != XML_ELEMENT_NODE)
continue;
296 if (strcmp((
char *) xnode->name,
"coordinates"))
continue;
301 if (!found) lwpgerror(
"invalid KML representation");
304 kml_coord = xmlNodeGetContent(xnode);
305 p = (
char *) kml_coord;
315 while (*p && isspace(*p)) ++p;
316 for (kml_dims=0; *p ; p++)
319 if ( isdigit(*p) || *p ==
'+' || *p ==
'-' || *p ==
'.' ) {
321 errno = 0; d = strtod(p, &q);
324 lwpgerror(
"invalid KML representation");
326 if (kml_dims == 1) pt.
x = d;
327 else if (kml_dims == 2) pt.
y = d;
328 else if (kml_dims == 3) pt.
z = d;
330 lwpgerror(
"invalid KML representation");
336 if ( *q && ! isspace(*q) && *q !=
',' ) {
337 lwpgerror(
"invalid KML representation");
341 while (*q && isspace(*q)) ++q;
342 if ( isdigit(*q) || *q ==
'+' || *q ==
'-' || *q ==
'.' || ! *q ) {
343 if ( kml_dims < 2 ) lwpgerror(
"invalid KML representation");
344 else if ( kml_dims < 3 ) *hasz =
false;
345 if ( ! seen_kml_dims ) seen_kml_dims = kml_dims;
346 else if ( seen_kml_dims != kml_dims ) {
347 lwpgerror(
"invalid KML representation: mixed coordinates dimension");
354 }
else if ( *p !=
',' && ! isspace(*p) ) {
355 lwpgerror(
"invalid KML representation");
static bool is_kml_namespace(xmlNodePtr xnode, bool is_strict)
Return false if current element namespace is not a KML one Return true otherwise. ...
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, then a duplicate point will not be added.
#define LW_TRUE
Return types for functions with status returns.
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)