PostGIS  3.4.0dev-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 343 of file lwgeom_in_gml.c.

344 {
345  char *srtext;
346  char query[256];
347  int is_axis_order_gis_friendly, err;
348 
349  if (SPI_OK_CONNECT != SPI_connect ())
350  lwpgerror("gml_is_srs_axis_order_gis_friendly: could not connect to SPI manager");
351 
352  sprintf(query, "SELECT srtext \
353  FROM spatial_ref_sys WHERE srid='%d'", srid);
354 
355  err = SPI_exec(query, 1);
356  if (err < 0) lwpgerror("gml_is_srs_axis_order_gis_friendly: error executing query %d", err);
357 
358  /* No entry in spatial_ref_sys */
359  if (SPI_processed <= 0)
360  {
361  SPI_finish();
362  return -1;
363  }
364 
365  srtext = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
366 
367  is_axis_order_gis_friendly = 1;
368  if (srtext && srtext[0] != '\0')
369  {
370  char* ptr;
371  char* srtext_horizontal = (char*) malloc(strlen(srtext) + 1);
372  strcpy(srtext_horizontal, srtext);
373 
374  /* Remove the VERT_CS part if we are in a COMPD_CS */
375  ptr = strstr(srtext_horizontal, ",VERT_CS[");
376  if (ptr)
377  *ptr = '\0';
378 
379  if( strstr(srtext_horizontal, "AXIS[") == NULL &&
380  strstr(srtext_horizontal, "GEOCCS[") == NULL )
381  {
382  /* If there is no axis definition, then due to how GDAL < 3
383  * generated the WKT, this means that the axis order is not
384  * GIS friendly */
385  is_axis_order_gis_friendly = 0;
386  }
387  else if( strstr(srtext_horizontal,
388  "AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST]") != NULL )
389  {
390  is_axis_order_gis_friendly = 0;
391  }
392  else if( strstr(srtext_horizontal,
393  "AXIS[\"Northing\",NORTH],AXIS[\"Easting\",EAST]") != NULL )
394  {
395  is_axis_order_gis_friendly = 0;
396  }
397  else if( strstr(srtext_horizontal,
398  "AXIS[\"geodetic latitude (Lat)\",north,ORDER[1]") != NULL )
399  {
400  is_axis_order_gis_friendly = 0;
401  }
402 
403  free(srtext_horizontal);
404  }
405  SPI_finish();
406 
407  return is_axis_order_gis_friendly;
408 }
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: