Parse gml:coordinates.
611{
612 xmlChar *gml_coord, *gml_ts, *gml_cs, *gml_dec;
613 char cs, ts, dec;
615 int gml_dims;
616 char *p, *q;
617 bool digit;
619
620
621 gml_coord = xmlNodeGetContent(xnode);
622 p = (char *) gml_coord;
623
624
625
626
627
628
629
630
632 if (gml_ts == NULL) ts = ' ';
633 else
634 {
635 if (xmlStrlen(gml_ts) > 1 || isdigit(gml_ts[0]))
637 ts = gml_ts[0];
638 xmlFree(gml_ts);
639 }
640
641
643 if (gml_cs == NULL) cs = ',';
644 else
645 {
646 if (xmlStrlen(gml_cs) > 1 || isdigit(gml_cs[0]))
648 cs = gml_cs[0];
649 xmlFree(gml_cs);
650 }
651
652
654 if (gml_dec == NULL) dec = '.';
655 else
656 {
657 if (xmlStrlen(gml_dec) > 1 || isdigit(gml_dec[0]))
659 dec = gml_dec[0];
660 xmlFree(gml_dec);
661 }
662
663 if (cs == ts || cs == dec || ts == dec)
665
666
668
669 while (isspace(*p)) p++;
670 for (q = p, gml_dims=0, digit = false ; *p ; p++)
671 {
672
673 if (isdigit(*p)) digit = true;
674
675
676 if (*p == cs)
677 {
678 *p = '\0';
679 gml_dims++;
680
681 if (*(p+1) ==
'\0')
gml_lwpgerror(
"invalid GML representation", 19);
682
685
686 q = p+1;
687
688
689 }
690 else if (digit && (*p == ts || *(p+1) == '\0'))
691 {
692 if (*p == ts) *p = '\0';
693 gml_dims++;
694
695 if (gml_dims < 2 || gml_dims > 3)
697
698 if (gml_dims == 3)
700 else
701 {
703 *hasz = false;
704 }
705
707 digit = false;
708
709 q = p+1;
710 gml_dims = 0;
711
712
713 }
714 else if (*p == dec && dec != '.') *p = '.';
715 }
716
717 xmlFree(gml_coord);
718
719 return dpa;
720}
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)