PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ parse_gml_coord()

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

Parse gml:coord.

Definition at line 638 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().

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