PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void parse_gml_srs ( xmlNodePtr  xnode,
gmlSrs srs 
)
static

Parse gml srsName attribute.

Definition at line 354 of file lwgeom_in_gml.c.

References gml_is_srid_planar(), gml_lwerror(), 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().

355 {
356  char *p;
357  int is_planar;
358  xmlNodePtr node;
359  xmlChar *srsname;
360  bool latlon = false;
361  char sep = ':';
362 
363  node = xnode;
364  srsname = gmlGetProp(node, (xmlChar *) "srsName");
365  /*printf("srsname %s\n",srsname);*/
366  if (!srsname)
367  {
368  if (node->parent == NULL)
369  {
370  srs->srid = SRID_UNKNOWN;
371  srs->reverse_axis = false;
372  return;
373  }
374  parse_gml_srs(node->parent, srs);
375  }
376  else
377  {
378  /* Severals srsName formats are available...
379  * cf WFS 1.1.0 -> 9.2 (p36)
380  * cf ISO 19142:2009 -> 7.9.2.4.4 (p34)
381  * cf RFC 5165 <http://tools.ietf.org/html/rfc5165>
382  * cf CITE WFS-1.1 (GetFeature-tc17.2)
383  */
384 
385  /* SRS pattern like: EPSG:4326
386  urn:EPSG:geographicCRS:4326
387  urn:ogc:def:crs:EPSG:4326
388  urn:ogc:def:crs:EPSG::4326
389  urn:ogc:def:crs:EPSG:6.6:4326
390  urn:x-ogc:def:crs:EPSG:6.6:4326
391  http://www.opengis.net/gml/srs/epsg.xml#4326
392  http://www.epsg.org/6.11.2/4326
393  */
394 
395  if (!strncmp((char *) srsname, "EPSG:", 5))
396  {
397  sep = ':';
398  latlon = false;
399  }
400  else if (!strncmp((char *) srsname, "urn:ogc:def:crs:EPSG:", 21)
401  || !strncmp((char *) srsname, "urn:x-ogc:def:crs:EPSG:", 23)
402  || !strncmp((char *) srsname, "urn:EPSG:geographicCRS:", 23))
403  {
404  sep = ':';
405  latlon = true;
406  }
407  else if (!strncmp((char *) srsname,
408  "http://www.opengis.net/gml/srs/epsg.xml#", 40))
409  {
410  sep = '#';
411  latlon = false;
412  }
413  else gml_lwerror("unknown spatial reference system", 4);
414 
415  /* retrieve the last ':' or '#' char */
416  for (p = (char *) srsname ; *p ; p++);
417  for (--p ; *p != sep ; p--)
418  if (!isdigit(*p)) gml_lwerror("unknown spatial reference system", 5);
419 
420  srs->srid = atoi(++p);
421 
422  /* Check into spatial_ref_sys that this SRID really exist */
423  is_planar = gml_is_srid_planar(srs->srid);
424  if (srs->srid == SRID_UNKNOWN || is_planar == -1)
425  gml_lwerror("unknown spatial reference system", 6);
426 
427  /* About lat/lon issue, Cf: http://tinyurl.com/yjpr55z */
428  srs->reverse_axis = !is_planar && latlon;
429 
430  xmlFree(srsname);
431  return;
432  }
433 }
static void parse_gml_srs(xmlNodePtr xnode, gmlSrs *srs)
Parse gml srsName attribute.
static xmlChar * gmlGetProp(xmlNodePtr xnode, xmlChar *prop)
Retrieve a GML propertie from a node or NULL otherwise Respect namespaces if presents in the node ele...
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...
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:154
static void gml_lwerror(char *msg, int error_code)
Definition: lwgeom_in_gml.c:68

Here is the call graph for this function:

Here is the caller graph for this function: