PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ parse_gml_coord()

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

Parse gml:coord.

Definition at line 637 of file lwgeom_in_gml.c.

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

Referenced by parse_gml_data().

638 {
639  xmlNodePtr xyz;
640  POINTARRAY *dpa;
641  bool x,y,z;
642  xmlChar *c;
643  POINT4D p;
644 
645  /* HasZ?, !HasM, 1 Point */
646  dpa = ptarray_construct_empty(1, 0, 1);
647 
648  x = y = z = false;
649  for (xyz = xnode->children ; xyz != NULL ; xyz = xyz->next)
650  {
651  if (xyz->type != XML_ELEMENT_NODE) continue;
652  if (!is_gml_namespace(xyz, false)) continue;
653 
654  if (!strcmp((char *) xyz->name, "X"))
655  {
656  if (x) gml_lwpgerror("invalid GML representation", 21);
657  c = xmlNodeGetContent(xyz);
658  p.x = parse_gml_double((char *) c, true, true);
659  x = true;
660  xmlFree(c);
661  }
662  else if (!strcmp((char *) xyz->name, "Y"))
663  {
664  if (y) gml_lwpgerror("invalid GML representation", 22);
665  c = xmlNodeGetContent(xyz);
666  p.y = parse_gml_double((char *) c, true, true);
667  y = true;
668  xmlFree(c);
669  }
670  else if (!strcmp((char *) xyz->name, "Z"))
671  {
672  if (z) gml_lwpgerror("invalid GML representation", 23);
673  c = xmlNodeGetContent(xyz);
674  p.z = parse_gml_double((char *) c, true, true);
675  z = true;
676  xmlFree(c);
677  }
678  }
679  /* Check dimension consistancy */
680  if (!x || !y) gml_lwpgerror("invalid GML representation", 24);
681  if (!z) *hasz = false;
682 
683  ptarray_append_point(dpa, &p, LW_FALSE);
684  x = y = z = false;
685 
686  return dpa; /* ptarray_clone_deep(dpa); */
687 }
double x
Definition: liblwgeom.h:352
static void gml_lwpgerror(char *msg, int error_code)
Definition: lwgeom_in_gml.c:81
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_FALSE, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:77
double z
Definition: liblwgeom.h:352
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:352
Here is the call graph for this function:
Here is the caller graph for this function: