PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ parse_gml_srs()

static void parse_gml_srs ( xmlNodePtr  xnode,
gmlSrs srs 
)
static

Parse gml srsName attribute.

Definition at line 448 of file lwgeom_in_gml.c.

449 {
450  char *p;
451  int is_planar;
452  xmlNodePtr node;
453  xmlChar *srsname;
454  bool latlon = false;
455  char sep = ':';
456 
457  node = xnode;
458  srsname = gmlGetProp(node, "srsName");
459  /*printf("srsname %s\n",srsname);*/
460  if (!srsname)
461  {
462  if (node->parent == NULL)
463  {
464  srs->srid = SRID_UNKNOWN;
465  srs->reverse_axis = false;
466  return;
467  }
468  parse_gml_srs(node->parent, srs);
469  }
470  else
471  {
472  /* Severals srsName formats are available...
473  * cf WFS 1.1.0 -> 9.2 (p36)
474  * cf ISO 19142:2009 -> 7.9.2.4.4 (p34)
475  * cf RFC 5165 <http://tools.ietf.org/html/rfc5165>
476  * cf CITE WFS-1.1 (GetFeature-tc17.2)
477  */
478 
479  /* SRS pattern like: EPSG:4326
480  urn:EPSG:geographicCRS:4326
481  urn:ogc:def:crs:EPSG:4326
482  urn:ogc:def:crs:EPSG::4326
483  urn:ogc:def:crs:EPSG:6.6:4326
484  urn:x-ogc:def:crs:EPSG:6.6:4326
485  http://www.opengis.net/gml/srs/epsg.xml#4326
486  http://www.epsg.org/6.11.2/4326
487  */
488 
489  if (!strncmp((char *) srsname, "EPSG:", 5))
490  {
491  sep = ':';
492  latlon = false;
493  }
494  else if (!strncmp((char *) srsname, "urn:ogc:def:crs:EPSG:", 21)
495  || !strncmp((char *) srsname, "urn:x-ogc:def:crs:EPSG:", 23)
496  || !strncmp((char *) srsname, "urn:EPSG:geographicCRS:", 23))
497  {
498  sep = ':';
499  latlon = true;
500  }
501  else if (!strncmp((char *) srsname,
502  "http://www.opengis.net/gml/srs/epsg.xml#", 40))
503  {
504  sep = '#';
505  latlon = false;
506  }
507  else gml_lwpgerror("unknown spatial reference system", 4);
508 
509  /* retrieve the last ':' or '#' char */
510  for (p = (char *) srsname ; *p ; p++);
511  for (--p ; *p != sep ; p--)
512  if (!isdigit(*p)) gml_lwpgerror("unknown spatial reference system", 5);
513 
514  srs->srid = atoi(++p);
515 
516  /* Check into spatial_ref_sys that this SRID really exist */
517  is_planar = gml_is_srid_planar(srs->srid);
518  if (srs->srid == SRID_UNKNOWN || is_planar == -1)
519  gml_lwpgerror("unknown spatial reference system", 6);
520 
521  /* About lat/lon issue, Cf: http://tinyurl.com/yjpr55z */
522  srs->reverse_axis = !is_planar && latlon;
523 
524  xmlFree(srsname);
525  return;
526  }
527 }
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:229
static xmlChar * gmlGetProp(xmlNodePtr xnode, const char *charProp)
Retrieve a GML property from a node or NULL otherwise Respect namespaces if presents in the node elem...
static void parse_gml_srs(xmlNodePtr xnode, gmlSrs *srs)
Parse gml srsName attribute.
static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code)
Definition: lwgeom_in_gml.c:82
static int gml_is_srid_planar(int32_t srid)
Return 1 if given srid is planar (0 otherwise, i.e geocentric srid) Return -1 if srid is not in spati...

References gml_is_srid_planar(), gml_lwpgerror(), gmlGetProp(), struct_gmlSrs::reverse_axis, struct_gmlSrs::srid, and SRID_UNKNOWN.

Referenced by parse_gml(), parse_gml_coll(), parse_gml_curve(), parse_gml_data(), parse_gml_line(), parse_gml_linearring(), parse_gml_mcurve(), parse_gml_mline(), parse_gml_mpoint(), parse_gml_mpoly(), parse_gml_msurface(), parse_gml_patch(), parse_gml_point(), parse_gml_polygon(), parse_gml_psurface(), parse_gml_tin(), and parse_gml_triangle().

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