Parse gml:coordinates.
607{
608 xmlChar *gml_coord, *gml_ts, *gml_cs, *gml_dec;
609 char cs, ts, dec;
611 int gml_dims;
612 char *p, *q;
613 bool digit;
615
616
617 gml_coord = xmlNodeGetContent(xnode);
618 p = (char *) gml_coord;
619
620
621
622
623
624
625
626
628 if (gml_ts == NULL) ts = ' ';
629 else
630 {
631 if (xmlStrlen(gml_ts) > 1 || isdigit(gml_ts[0]))
633 ts = gml_ts[0];
634 xmlFree(gml_ts);
635 }
636
637
639 if (gml_cs == NULL) cs = ',';
640 else
641 {
642 if (xmlStrlen(gml_cs) > 1 || isdigit(gml_cs[0]))
644 cs = gml_cs[0];
645 xmlFree(gml_cs);
646 }
647
648
650 if (gml_dec == NULL) dec = '.';
651 else
652 {
653 if (xmlStrlen(gml_dec) > 1 || isdigit(gml_dec[0]))
655 dec = gml_dec[0];
656 xmlFree(gml_dec);
657 }
658
659 if (cs == ts || cs == dec || ts == dec)
661
662
664
665 while (isspace(*p)) p++;
666 for (q = p, gml_dims=0, digit = false ; *p ; p++)
667 {
668
669 if (isdigit(*p)) digit = true;
670
671
672 if (*p == cs)
673 {
674 *p = '\0';
675 gml_dims++;
676
677 if (*(p+1) ==
'\0')
gml_lwpgerror(
"invalid GML representation", 19);
678
681
682 q = p+1;
683
684
685 }
686 else if (digit && (*p == ts || *(p+1) == '\0'))
687 {
688 if (*p == ts) *p = '\0';
689 gml_dims++;
690
691 if (gml_dims < 2 || gml_dims > 3)
693
694 if (gml_dims == 3)
696 else
697 {
699 *hasz = false;
700 }
701
703 digit = false;
704
705 q = p+1;
706 gml_dims = 0;
707
708
709 }
710 else if (*p == dec && dec != '.') *p = '.';
711 }
712
713 xmlFree(gml_coord);
714
715 return dpa;
716}
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 xmlChar * gmlGetProp(xmlNodePtr xnode, const char *charProp)
Retrieve a GML property from a node or NULL otherwise Respect namespaces if presents in the node elem...
static double parse_gml_double(char *d, bool space_before, bool space_after)
Parse a string supposed to be a double.
static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code)