PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ parse_gml_srs()

static void parse_gml_srs ( xmlNodePtr  xnode,
gmlSrs srs 
)
static

Parse gml srsName attribute.

Definition at line 493 of file lwgeom_in_gml.c.

494 {
495  char *p;
496  int is_axis_order_gis_friendly;
497  xmlNodePtr node;
498  xmlChar *srsname;
499  bool honours_authority_axis_order = false;
500  char sep = ':';
501 
502  node = xnode;
503  srsname = gmlGetProp(node, "srsName");
504  /*printf("srsname %s\n",srsname);*/
505  if (!srsname)
506  {
507  if (node->parent == NULL)
508  {
509  srs->srid = SRID_UNKNOWN;
510  srs->reverse_axis = false;
511  return;
512  }
513  parse_gml_srs(node->parent, srs);
514  }
515  else
516  {
517  /* Severals srsName formats are available...
518  * cf WFS 1.1.0 -> 9.2 (p36)
519  * cf ISO 19142:2009 -> 7.9.2.4.4 (p34)
520  * cf RFC 5165 <http://tools.ietf.org/html/rfc5165>
521  * cf CITE WFS-1.1 (GetFeature-tc17.2)
522  */
523 
524  /* SRS pattern like: EPSG:4326
525  urn:EPSG:geographicCRS:4326
526  urn:ogc:def:crs:EPSG:4326
527  urn:ogc:def:crs:EPSG::4326
528  urn:ogc:def:crs:EPSG:6.6:4326
529  urn:x-ogc:def:crs:EPSG:6.6:4326
530  http://www.opengis.net/gml/srs/epsg.xml#4326
531  http://www.epsg.org/6.11.2/4326
532  */
533 
534  if (!strncmp((char *) srsname, "EPSG:", 5))
535  {
536  sep = ':';
537  honours_authority_axis_order = false;
538  }
539  else if (!strncmp((char *) srsname, "urn:ogc:def:crs:EPSG:", 21)
540  || !strncmp((char *) srsname, "urn:x-ogc:def:crs:EPSG:", 23)
541  || !strncmp((char *) srsname, "urn:EPSG:geographicCRS:", 23))
542  {
543  sep = ':';
544  honours_authority_axis_order = true;
545  }
546  else if (!strncmp((char *) srsname,
547  "http://www.opengis.net/gml/srs/epsg.xml#", 40))
548  {
549  sep = '#';
550  honours_authority_axis_order = false;
551  }
552  else gml_lwpgerror("unknown spatial reference system", 4);
553 
554  /* retrieve the last ':' or '#' char */
555  for (p = (char *) srsname ; *p ; p++);
556  for (--p ; *p != sep ; p--)
557  if (!isdigit(*p)) gml_lwpgerror("unknown spatial reference system", 5);
558 
559  srs->srid = atoi(++p);
560 
561  /* Check into spatial_ref_sys that this SRID really exist */
562  is_axis_order_gis_friendly = gml_is_srs_axis_order_gis_friendly(srs->srid);
563  if (srs->srid == SRID_UNKNOWN || is_axis_order_gis_friendly == -1)
564  gml_lwpgerror("unknown spatial reference system", 6);
565 
566  /* Reverse axis order if the srsName is meant to honour the axis
567  order defined by the authority and if that axis order is not
568  the GIS friendly one. */
569  srs->reverse_axis = !is_axis_order_gis_friendly && honours_authority_axis_order;
570 
571  xmlFree(srsname);
572  return;
573  }
574 }
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:230
static int gml_is_srs_axis_order_gis_friendly(int32_t srid)
Return 1 if the SRS definition from the authority has a GIS friendly order, that is easting,...
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:81

References gml_is_srs_axis_order_gis_friendly(), 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: