PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ gml_is_srs_axis_order_gis_friendly()

static int gml_is_srs_axis_order_gis_friendly ( int32_t  srid)
static

Return 1 if the SRS definition from the authority has a GIS friendly order, that is easting,northing.

This is typically true for most projected CRS (but not all!), and this is false for EPSG geographic CRS.

Definition at line 427 of file lwgeom_in_gml.c.

428 {
429  char *srtext;
430  char query[256];
431  int is_axis_order_gis_friendly, err;
432 
433  if (SPI_OK_CONNECT != SPI_connect ())
434  lwpgerror("gml_is_srs_axis_order_gis_friendly: could not connect to SPI manager");
435 
436  sprintf(query, "SELECT srtext \
437  FROM spatial_ref_sys WHERE srid='%d'", srid);
438 
439  err = SPI_exec(query, 1);
440  if (err < 0) lwpgerror("gml_is_srs_axis_order_gis_friendly: error executing query %d", err);
441 
442  /* No entry in spatial_ref_sys */
443  if (SPI_processed <= 0)
444  {
445  SPI_finish();
446  return -1;
447  }
448 
449  srtext = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
450 
451  is_axis_order_gis_friendly = 1;
452  if (srtext && srtext[0] != '\0')
453  {
454  char* ptr;
455  char* srtext_horizontal = (char*) malloc(strlen(srtext) + 1);
456  strcpy(srtext_horizontal, srtext);
457 
458  /* Remove the VERT_CS part if we are in a COMPD_CS */
459  ptr = strstr(srtext_horizontal, ",VERT_CS[");
460  if (ptr)
461  *ptr = '\0';
462 
463  if( strstr(srtext_horizontal, "AXIS[") == NULL &&
464  strstr(srtext_horizontal, "GEOCCS[") == NULL )
465  {
466  /* If there is no axis definition, then due to how GDAL < 3
467  * generated the WKT, this means that the axis order is not
468  * GIS friendly */
469  is_axis_order_gis_friendly = 0;
470  }
471  else if( strstr(srtext_horizontal,
472  "AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST]") != NULL )
473  {
474  is_axis_order_gis_friendly = 0;
475  }
476  else if( strstr(srtext_horizontal,
477  "AXIS[\"Northing\",NORTH],AXIS[\"Easting\",EAST]") != NULL )
478  {
479  is_axis_order_gis_friendly = 0;
480  }
481  else if( strstr(srtext_horizontal,
482  "AXIS[\"geodetic latitude (Lat)\",north,ORDER[1]") != NULL )
483  {
484  is_axis_order_gis_friendly = 0;
485  }
486 
487  free(srtext_horizontal);
488  }
489  SPI_finish();
490 
491  return is_axis_order_gis_friendly;
492 }
void * malloc(YYSIZE_T)
void free(void *)

References free(), and malloc().

Referenced by parse_gml_srs().

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