PostGIS  2.5.0dev-r@@SVN_REVISION@@
static POINTARRAY* parse_gml_data ( xmlNodePtr  xnode,
bool *  hasz,
int *  root_srid 
)
static

Parse data coordinates.

There's several ways to encode data coordinates, who could be mixed inside a single geometrie:

  • gml:pos element
  • gml:posList element
  • gml:pointProperty
  • gml:pointRep (deprecated in 3.1.0)
  • gml:coordinate element with tuples string inside (deprecated in 3.1.0)
  • gml:coord elements with X,Y(,Z) nested elements (deprecated in 3.0.0)

Definition at line 835 of file lwgeom_in_gml.c.

References get_xlink_node(), gml_lwpgerror(), gml_reproject_pa(), is_gml_namespace(), is_xlink(), parse_gml_coord(), parse_gml_coordinates(), parse_gml_pos(), parse_gml_poslist(), parse_gml_srs(), ptarray_flip_coordinates(), ptarray_merge(), struct_gmlSrs::reverse_axis, struct_gmlSrs::srid, and SRID_UNKNOWN.

Referenced by parse_gml_curve(), parse_gml_line(), parse_gml_linearring(), parse_gml_patch(), parse_gml_point(), parse_gml_polygon(), and parse_gml_triangle().

836 {
837  POINTARRAY *pa = 0, *tmp_pa = 0;
838  xmlNodePtr xa, xb;
839  gmlSrs srs;
840  bool found;
841 
842  pa = NULL;
843 
844  for (xa = xnode ; xa != NULL ; xa = xa->next)
845  {
846  if (xa->type != XML_ELEMENT_NODE) continue;
847  if (!is_gml_namespace(xa, false)) continue;
848  if (xa->name == NULL) continue;
849 
850  if (!strcmp((char *) xa->name, "pos"))
851  {
852  tmp_pa = parse_gml_pos(xa, hasz);
853  if (pa == NULL) pa = tmp_pa;
854  else pa = ptarray_merge(pa, tmp_pa);
855 
856  }
857  else if (!strcmp((char *) xa->name, "posList"))
858  {
859  tmp_pa = parse_gml_poslist(xa, hasz);
860  if (pa == NULL) pa = tmp_pa;
861  else pa = ptarray_merge(pa, tmp_pa);
862 
863  }
864  else if (!strcmp((char *) xa->name, "coordinates"))
865  {
866  tmp_pa = parse_gml_coordinates(xa, hasz);
867  if (pa == NULL) pa = tmp_pa;
868  else pa = ptarray_merge(pa, tmp_pa);
869 
870  }
871  else if (!strcmp((char *) xa->name, "coord"))
872  {
873  tmp_pa = parse_gml_coord(xa, hasz);
874  if (pa == NULL) pa = tmp_pa;
875  else pa = ptarray_merge(pa, tmp_pa);
876 
877  }
878  else if (!strcmp((char *) xa->name, "pointRep") ||
879  !strcmp((char *) xa->name, "pointProperty"))
880  {
881 
882  found = false;
883  for (xb = xa->children ; xb != NULL ; xb = xb->next)
884  {
885  if (xb->type != XML_ELEMENT_NODE) continue;
886  if (!is_gml_namespace(xb, false)) continue;
887  if (!strcmp((char *) xb->name, "Point"))
888  {
889  found = true;
890  break;
891  }
892  }
893  if (!found || xb == NULL)
894  gml_lwpgerror("invalid GML representation", 29);
895 
896  if (is_xlink(xb)) xb = get_xlink_node(xb);
897  if (xb == NULL || xb->children == NULL)
898  gml_lwpgerror("invalid GML representation", 30);
899 
900  tmp_pa = parse_gml_data(xb->children, hasz, root_srid);
901  if (tmp_pa->npoints != 1)
902  gml_lwpgerror("invalid GML representation", 31);
903 
904  parse_gml_srs(xb, &srs);
905  if (srs.reverse_axis) tmp_pa = ptarray_flip_coordinates(tmp_pa);
906  if (*root_srid == SRID_UNKNOWN) *root_srid = srs.srid;
907  else if (srs.srid != *root_srid)
908  gml_reproject_pa(tmp_pa, srs.srid, *root_srid);
909  if (pa == NULL) pa = tmp_pa;
910  else pa = ptarray_merge(pa, tmp_pa);
911  }
912  }
913 
914  if (pa == NULL) gml_lwpgerror("invalid GML representation", 32);
915 
916  return pa;
917 }
static POINTARRAY * parse_gml_poslist(xmlNodePtr xnode, bool *hasz)
Parse gml:posList.
static void gml_lwpgerror(char *msg, int error_code)
Definition: lwgeom_in_gml.c:81
static void parse_gml_srs(xmlNodePtr xnode, gmlSrs *srs)
Parse gml srsName attribute.
static POINTARRAY * parse_gml_coordinates(xmlNodePtr xnode, bool *hasz)
Parse gml:coordinates.
static POINTARRAY * parse_gml_coord(xmlNodePtr xnode, bool *hasz)
Parse gml:coord.
static POINTARRAY * gml_reproject_pa(POINTARRAY *pa, int srid_in, int srid_out)
Use Proj4 to reproject a given POINTARRAY.
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
Definition: ptarray.c:368
static xmlNodePtr get_xlink_node(xmlNodePtr xnode)
Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:187
static POINTARRAY * parse_gml_pos(xmlNodePtr xnode, bool *hasz)
Parse gml:pos.
static bool is_xlink(xmlNodePtr node)
Return true if current node contains a simple XLink Return false otherwise.
static POINTARRAY * parse_gml_data(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse data coordinates.
static bool is_gml_namespace(xmlNodePtr xnode, bool is_strict)
Return false if current element namespace is not a GML one Return true otherwise. ...
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
Definition: ptarray.c:597

Here is the call graph for this function:

Here is the caller graph for this function: