Parse kml:coordinates.
285 int seen_kml_dims = 0;
291 if (xnode == NULL) lwpgerror(
"invalid KML representation");
293 for (found =
false ; xnode != NULL ; xnode = xnode->next)
295 if (xnode->type != XML_ELEMENT_NODE)
continue;
297 if (strcmp((
char *) xnode->name,
"coordinates"))
continue;
302 if (!found) lwpgerror(
"invalid KML representation");
305 kml_coord = xmlNodeGetContent(xnode);
306 p = (
char *) kml_coord;
316 while (*p && isspace(*p)) ++p;
317 for (kml_dims=0; *p ; p++)
320 if ( isdigit(*p) || *p ==
'+' || *p ==
'-' || *p ==
'.' ) {
322 errno = 0; d = strtod(p, &q);
325 lwpgerror(
"invalid KML representation");
327 if (kml_dims == 1) pt.
x = d;
328 else if (kml_dims == 2) pt.
y = d;
329 else if (kml_dims == 3) pt.
z = d;
331 lwpgerror(
"invalid KML representation");
337 if ( *q && ! isspace(*q) && *q !=
',' ) {
338 lwpgerror(
"invalid KML representation");
342 while (*q && isspace(*q)) ++q;
343 if ( isdigit(*q) || *q ==
'+' || *q ==
'-' || *q ==
'.' || ! *q ) {
344 if ( kml_dims < 2 ) lwpgerror(
"invalid KML representation");
345 else if ( kml_dims < 3 ) *hasz =
false;
346 if ( ! seen_kml_dims ) seen_kml_dims = kml_dims;
347 else if ( seen_kml_dims != kml_dims ) {
348 lwpgerror(
"invalid KML representation: mixed coordinates dimension");
355 }
else if ( *p !=
',' && ! isspace(*p) ) {
356 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.