PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ parse_gml_data()

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 974 of file lwgeom_in_gml.c.

975 {
976  POINTARRAY *pa = 0, *tmp_pa = 0;
977  xmlNodePtr xa, xb;
978  gmlSrs srs;
979  bool found;
980 
981  pa = NULL;
982 
983  for (xa = xnode ; xa != NULL ; xa = xa->next)
984  {
985  if (xa->type != XML_ELEMENT_NODE) continue;
986  if (!is_gml_namespace(xa, false)) continue;
987  if (xa->name == NULL) continue;
988 
989  if (is_gml_element(xa, "pos"))
990  {
991  tmp_pa = parse_gml_pos(xa, hasz);
992  if (pa == NULL) pa = tmp_pa;
993  else pa = ptarray_merge(pa, tmp_pa);
994 
995  }
996  else if (is_gml_element(xa, "posList"))
997  {
998  tmp_pa = parse_gml_poslist(xa, hasz);
999  if (pa == NULL) pa = tmp_pa;
1000  else pa = ptarray_merge(pa, tmp_pa);
1001 
1002  }
1003  else if (is_gml_element(xa, "coordinates"))
1004  {
1005  tmp_pa = parse_gml_coordinates(xa, hasz);
1006  if (pa == NULL) pa = tmp_pa;
1007  else pa = ptarray_merge(pa, tmp_pa);
1008 
1009  }
1010  else if (is_gml_element(xa, "coord"))
1011  {
1012  tmp_pa = parse_gml_coord(xa, hasz);
1013  if (pa == NULL) pa = tmp_pa;
1014  else pa = ptarray_merge(pa, tmp_pa);
1015 
1016  }
1017  else if (is_gml_element(xa, "pointRep") ||
1018  is_gml_element(xa, "pointProperty"))
1019  {
1020  found = false;
1021  for (xb = xa->children ; xb != NULL ; xb = xb->next)
1022  {
1023  if (xb->type != XML_ELEMENT_NODE) continue;
1024  if (!is_gml_namespace(xb, false)) continue;
1025  if (is_gml_element(xb, "Point"))
1026  {
1027  found = true;
1028  break;
1029  }
1030  }
1031  if (!found || xb == NULL)
1032  gml_lwpgerror("invalid GML representation", 29);
1033 
1034  if (is_xlink(xb)) xb = get_xlink_node(xb);
1035  if (xb == NULL || xb->children == NULL)
1036  gml_lwpgerror("invalid GML representation", 30);
1037 
1038  tmp_pa = parse_gml_data(xb->children, hasz, root_srid);
1039  if (tmp_pa->npoints != 1)
1040  gml_lwpgerror("invalid GML representation", 31);
1041 
1042  parse_gml_srs(xb, &srs);
1043  if (srs.reverse_axis) tmp_pa = ptarray_flip_coordinates(tmp_pa);
1044  if (*root_srid == SRID_UNKNOWN) *root_srid = srs.srid;
1045  else if (srs.srid != *root_srid)
1046  gml_reproject_pa(tmp_pa, srs.srid, *root_srid);
1047  if (pa == NULL) pa = tmp_pa;
1048  else pa = ptarray_merge(pa, tmp_pa);
1049  }
1050  }
1051 
1052  if (pa == NULL) gml_lwpgerror("invalid GML representation", 32);
1053 
1054  return pa;
1055 }
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:229
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
Definition: ptarray.c:603
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.
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 * gml_reproject_pa(POINTARRAY *pa, int32_t epsg_in, int32_t epsg_out)
Use Proj to reproject a given POINTARRAY.
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 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_data(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse data coordinates.
static POINTARRAY * parse_gml_coord(xmlNodePtr xnode, bool *hasz)
Parse gml:coord.
static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code)
Definition: lwgeom_in_gml.c:81
static POINTARRAY * parse_gml_poslist(xmlNodePtr xnode, bool *hasz)
Parse gml:posList.
static bool is_gml_element(xmlNodePtr xn, const char *gml_name)

References get_xlink_node(), gml_lwpgerror(), gml_reproject_pa(), is_gml_element(), 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().

Here is the call graph for this function:
Here is the caller graph for this function: