Parse KML Polygon.
422{
423 int ring;
424 xmlNodePtr xa, xb;
426 int outer_rings = 0;
427
428 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
429 {
430
431
432 if (xa->type != XML_ELEMENT_NODE) continue;
435
436 for (xb = xa->children ; xb != NULL ; xb = xb->next)
437 {
438
439 if (xb->type != XML_ELEMENT_NODE) continue;
442
445
446 if (ppa[0]->npoints < 4)
447 lwpgerror("invalid KML representation");
448
451 {
455 lwpgnotice("forced closure on an un-closed KML polygon");
456 }
457 outer_rings++;
458 }
459 }
460
461 if (outer_rings != 1)
462 lwpgerror("invalid KML representation");
463
464 for (ring=1, xa = xnode->children ; xa != NULL ; xa = xa->next)
465 {
466
467
468 if (xa->type != XML_ELEMENT_NODE) continue;
471
472 for (xb = xa->children ; xb != NULL ; xb = xb->next)
473 {
474
475 if (xb->type != XML_ELEMENT_NODE) continue;
478
481
482 if (ppa[ring]->npoints < 4)
483 lwpgerror("invalid KML representation");
484
487 {
491 lwpgnotice("forced closure on an un-closed KML polygon");
492 }
493
494 ring++;
495 }
496 }
497
498
499 if (ppa == NULL || ppa[0] == NULL) lwpgerror("invalid KML representation");
500
502}
void * lwrealloc(void *mem, size_t size)
int ptarray_is_closed_3d(const POINTARRAY *pa)
void * lwalloc(size_t size)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **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,...
int ptarray_is_closed_2d(const POINTARRAY *pa)
#define LW_TRUE
Return types for functions with status returns.
static POINTARRAY * parse_kml_coordinates(xmlNodePtr xnode, bool *hasz)
Parse kml:coordinates.
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)