PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ parse_gml_coord()

static POINTARRAY* parse_gml_coord ( xmlNodePtr  xnode,
bool *  hasz 
)
static

Parse gml:coord.

Definition at line 623 of file lwgeom_in_gml.c.

References gml_lwpgerror(), is_gml_namespace(), LW_FALSE, parse_gml_double(), ptarray_append_point(), ptarray_clone_deep(), ptarray_construct_empty(), pixval::x, POINT4D::x, pixval::y, POINT4D::y, and POINT4D::z.

Referenced by parse_gml_data().

624 {
625  xmlNodePtr xyz;
626  POINTARRAY *dpa;
627  bool x,y,z;
628  xmlChar *c;
629  POINT4D p;
630 
631  /* HasZ?, !HasM, 1 Point */
632  dpa = ptarray_construct_empty(1, 0, 1);
633 
634  x = y = z = false;
635  for (xyz = xnode->children ; xyz != NULL ; xyz = xyz->next)
636  {
637  if (xyz->type != XML_ELEMENT_NODE) continue;
638  if (!is_gml_namespace(xyz, false)) continue;
639 
640  if (!strcmp((char *) xyz->name, "X"))
641  {
642  if (x) gml_lwpgerror("invalid GML representation", 21);
643  c = xmlNodeGetContent(xyz);
644  p.x = parse_gml_double((char *) c, true, true);
645  x = true;
646  xmlFree(c);
647  }
648  else if (!strcmp((char *) xyz->name, "Y"))
649  {
650  if (y) gml_lwpgerror("invalid GML representation", 22);
651  c = xmlNodeGetContent(xyz);
652  p.y = parse_gml_double((char *) c, true, true);
653  y = true;
654  xmlFree(c);
655  }
656  else if (!strcmp((char *) xyz->name, "Z"))
657  {
658  if (z) gml_lwpgerror("invalid GML representation", 23);
659  c = xmlNodeGetContent(xyz);
660  p.z = parse_gml_double((char *) c, true, true);
661  z = true;
662  xmlFree(c);
663  }
664  }
665  /* Check dimension consistancy */
666  if (!x || !y) gml_lwpgerror("invalid GML representation", 24);
667  if (!z) *hasz = false;
668 
669  ptarray_append_point(dpa, &p, LW_FALSE);
670  x = y = z = false;
671 
672  return ptarray_clone_deep(dpa);
673 }
double x
Definition: liblwgeom.h:336
static void gml_lwpgerror(char *msg, int error_code)
Definition: lwgeom_in_gml.c:67
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
static double parse_gml_double(char *d, bool space_before, bool space_after)
Parse a string supposed to be a double.
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_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:62
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
double z
Definition: liblwgeom.h:336
static bool is_gml_namespace(xmlNodePtr xnode, bool is_strict)
Return false if current element namespace is not a GML one Return true otherwise. ...
double y
Definition: liblwgeom.h:336
Here is the call graph for this function:
Here is the caller graph for this function: