PostGIS  2.1.10dev-r@@SVN_REVISION@@
static POINTARRAY* parse_gml_coord ( xmlNodePtr  xnode,
bool *  hasz 
)
static

Parse gml:coord.

Definition at line 628 of file lwgeom_in_gml.c.

References gml_lwerror(), 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().

629 {
630  xmlNodePtr xyz;
631  POINTARRAY *dpa;
632  bool x,y,z;
633  xmlChar *c;
634  POINT4D p;
635 
636  /* HasZ?, !HasM, 1 Point */
637  dpa = ptarray_construct_empty(1, 0, 1);
638 
639  x = y = z = false;
640  for (xyz = xnode->children ; xyz != NULL ; xyz = xyz->next)
641  {
642  if (xyz->type != XML_ELEMENT_NODE) continue;
643  if (!is_gml_namespace(xyz, false)) continue;
644 
645  if (!strcmp((char *) xyz->name, "X"))
646  {
647  if (x) gml_lwerror("invalid GML representation", 21);
648  c = xmlNodeGetContent(xyz);
649  p.x = parse_gml_double((char *) c, true, true);
650  x = true;
651  xmlFree(c);
652  }
653  else if (!strcmp((char *) xyz->name, "Y"))
654  {
655  if (y) gml_lwerror("invalid GML representation", 22);
656  c = xmlNodeGetContent(xyz);
657  p.y = parse_gml_double((char *) c, true, true);
658  y = true;
659  xmlFree(c);
660  }
661  else if (!strcmp((char *) xyz->name, "Z"))
662  {
663  if (z) gml_lwerror("invalid GML representation", 23);
664  c = xmlNodeGetContent(xyz);
665  p.z = parse_gml_double((char *) c, true, true);
666  z = true;
667  xmlFree(c);
668  }
669  }
670  /* Check dimension consistancy */
671  if (!x || !y) gml_lwerror("invalid GML representation", 24);
672  if (!z) *hasz = false;
673 
674  ptarray_append_point(dpa, &p, LW_FALSE);
675  x = y = z = false;
676 
677  return ptarray_clone_deep(dpa);
678 }
double x
Definition: liblwgeom.h:308
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:57
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:141
#define LW_FALSE
Definition: liblwgeom.h:52
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:619
double z
Definition: liblwgeom.h:308
tuple x
Definition: pixval.py:53
static bool is_gml_namespace(xmlNodePtr xnode, bool is_strict)
Return false if current element namespace is not a GML one Return true otherwise. ...
static void gml_lwerror(char *msg, int error_code)
Definition: lwgeom_in_gml.c:68
double y
Definition: liblwgeom.h:308
tuple y
Definition: pixval.py:54

Here is the call graph for this function:

Here is the caller graph for this function: