PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 379 of file lwgeom_in_gml.c.

380{
381 char *srtext;
382 char query[256];
383 int is_axis_order_gis_friendly, err;
384
385 if (SPI_OK_CONNECT != SPI_connect ())
386 lwpgerror("gml_is_srs_axis_order_gis_friendly: could not connect to SPI manager");
387
388 sprintf(query, "SELECT srtext \
389 FROM spatial_ref_sys WHERE srid='%d'", srid);
390
391 err = SPI_exec(query, 1);
392 if (err < 0) lwpgerror("gml_is_srs_axis_order_gis_friendly: error executing query %d", err);
393
394 /* No entry in spatial_ref_sys */
395 if (SPI_processed <= 0)
396 {
397 SPI_finish();
398 return -1;
399 }
400
401 srtext = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
402
403 is_axis_order_gis_friendly = 1;
404 if (srtext && srtext[0] != '\0')
405 {
406 char* ptr;
407 char* srtext_horizontal = (char*) malloc(strlen(srtext) + 1);
408 strcpy(srtext_horizontal, srtext);
409
410 /* Remove the VERT_CS part if we are in a COMPD_CS */
411 ptr = strstr(srtext_horizontal, ",VERT_CS[");
412 if (ptr)
413 *ptr = '\0';
414
415 if( strstr(srtext_horizontal, "AXIS[") == NULL &&
416 strstr(srtext_horizontal, "GEOCCS[") == NULL )
417 {
418 /* If there is no axis definition, then due to how GDAL < 3
419 * generated the WKT, this means that the axis order is not
420 * GIS friendly */
421 is_axis_order_gis_friendly = 0;
422 }
423 else if( strstr(srtext_horizontal,
424 "AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST]") != NULL )
425 {
426 is_axis_order_gis_friendly = 0;
427 }
428 else if( strstr(srtext_horizontal,
429 "AXIS[\"Northing\",NORTH],AXIS[\"Easting\",EAST]") != NULL )
430 {
431 is_axis_order_gis_friendly = 0;
432 }
433 else if( strstr(srtext_horizontal,
434 "AXIS[\"geodetic latitude (Lat)\",north,ORDER[1]") != NULL )
435 {
436 is_axis_order_gis_friendly = 0;
437 }
438
439 free(srtext_horizontal);
440 }
441 SPI_finish();
442
443 return is_axis_order_gis_friendly;
444}
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: