PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ parse_gml_srs()

static void parse_gml_srs ( xmlNodePtr  xnode,
gmlSrs srs 
)
static

Parse gml srsName attribute.

Definition at line 370 of file lwgeom_in_gml.c.

371 {
372  char *p;
373  int is_planar;
374  xmlNodePtr node;
375  xmlChar *srsname;
376  bool latlon = false;
377  char sep = ':';
378 
379  node = xnode;
380  srsname = gmlGetProp(node, (xmlChar *) "srsName");
381  /*printf("srsname %s\n",srsname);*/
382  if (!srsname)
383  {
384  if (node->parent == NULL)
385  {
386  srs->srid = SRID_UNKNOWN;
387  srs->reverse_axis = false;
388  return;
389  }
390  parse_gml_srs(node->parent, srs);
391  }
392  else
393  {
394  /* Severals srsName formats are available...
395  * cf WFS 1.1.0 -> 9.2 (p36)
396  * cf ISO 19142:2009 -> 7.9.2.4.4 (p34)
397  * cf RFC 5165 <http://tools.ietf.org/html/rfc5165>
398  * cf CITE WFS-1.1 (GetFeature-tc17.2)
399  */
400 
401  /* SRS pattern like: EPSG:4326
402  urn:EPSG:geographicCRS:4326
403  urn:ogc:def:crs:EPSG:4326
404  urn:ogc:def:crs:EPSG::4326
405  urn:ogc:def:crs:EPSG:6.6:4326
406  urn:x-ogc:def:crs:EPSG:6.6:4326
407  http://www.opengis.net/gml/srs/epsg.xml#4326
408  http://www.epsg.org/6.11.2/4326
409  */
410 
411  if (!strncmp((char *) srsname, "EPSG:", 5))
412  {
413  sep = ':';
414  latlon = false;
415  }
416  else if (!strncmp((char *) srsname, "urn:ogc:def:crs:EPSG:", 21)
417  || !strncmp((char *) srsname, "urn:x-ogc:def:crs:EPSG:", 23)
418  || !strncmp((char *) srsname, "urn:EPSG:geographicCRS:", 23))
419  {
420  sep = ':';
421  latlon = true;
422  }
423  else if (!strncmp((char *) srsname,
424  "http://www.opengis.net/gml/srs/epsg.xml#", 40))
425  {
426  sep = '#';
427  latlon = false;
428  }
429  else gml_lwpgerror("unknown spatial reference system", 4);
430 
431  /* retrieve the last ':' or '#' char */
432  for (p = (char *) srsname ; *p ; p++);
433  for (--p ; *p != sep ; p--)
434  if (!isdigit(*p)) gml_lwpgerror("unknown spatial reference system", 5);
435 
436  srs->srid = atoi(++p);
437 
438  /* Check into spatial_ref_sys that this SRID really exist */
439  is_planar = gml_is_srid_planar(srs->srid);
440  if (srs->srid == SRID_UNKNOWN || is_planar == -1)
441  gml_lwpgerror("unknown spatial reference system", 6);
442 
443  /* About lat/lon issue, Cf: http://tinyurl.com/yjpr55z */
444  srs->reverse_axis = !is_planar && latlon;
445 
446  xmlFree(srsname);
447  return;
448  }
449 }
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
static xmlChar * gmlGetProp(xmlNodePtr xnode, xmlChar *prop)
Retrieve a GML property from a node or NULL otherwise Respect namespaces if presents in the node elem...
static int gml_is_srid_planar(int srid)
Return 1 if given srid is planar (0 otherwise, i.e geocentric srid) Return -1 if srid is not in spati...
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

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: