GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
get_projinfo.c File Reference

GIS Library - Get projection info. More...

#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Include dependency graph for get_projinfo.c:

Go to the source code of this file.

Macros

#define PERMANENT   "PERMANENT"
 

Functions

struct Key_ValueG_get_projunits (void)
 Gets units information for location. More...
 
struct Key_ValueG_get_projinfo (void)
 Gets projection information for location. More...
 
struct Key_ValueG_get_projepsg (void)
 Gets EPSG information for the current location. More...
 
char * G_get_projwkt (void)
 Get WKT information for the current location. More...
 
char * G_get_projsrid (void)
 Get srid (spatial reference id) for the current location. More...
 

Detailed Description

GIS Library - Get projection info.

(C) 1999-2014 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Definition in file get_projinfo.c.

Macro Definition Documentation

◆ PERMANENT

#define PERMANENT   "PERMANENT"

Definition at line 19 of file get_projinfo.c.

Referenced by G_get_projepsg(), G_get_projinfo(), and G_get_projunits().

Function Documentation

◆ G_get_projepsg()

struct Key_Value* G_get_projepsg ( void  )

Gets EPSG information for the current location.

DEPRECATED: Use G_get_projsrid() instead.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Returns
pointer to Key_Value structure with key/value pairs
NULL when EPSG code is not defined for location

Definition at line 102 of file get_projinfo.c.

References EPSG_FILE, G_debug(), G_file_name(), G_location(), G_projection(), G_read_key_value_file(), GPATH_MAX, NULL, PERMANENT, and PROJECTION_XY.

Referenced by G_get_projinfo().

◆ G_get_projinfo()

struct Key_Value* G_get_projinfo ( void  )

Gets projection information for location.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Prints a warning if no projection information available.

Returns
pointer to Key_Value structure with key/value pairs
NULL on failure

Definition at line 61 of file get_projinfo.c.

References _, G_file_name(), G_find_key_value(), G_free_key_value(), G_get_projepsg(), G_location(), G_projection(), G_read_key_value_file(), G_set_key_value(), G_warning(), GPATH_MAX, NULL, PERMANENT, PROJECTION_FILE, and PROJECTION_XY.

Referenced by GPJ_get_datum_params().

◆ G_get_projsrid()

char* G_get_projsrid ( void  )

Get srid (spatial reference id) for the current location.

Typically an srid will be of the form authority NAME:CODE, e.g. EPSG:4326

This srid is passed to proj_create() using PROJ or OSRSetFromUserInput() using GDAL. Therefore various other forms of srid are possible, e.g. in OSRSetFromUserInput():

  1. Well Known Text definition - passed on to importFromWkt().
  2. "EPSG:n" - number passed on to importFromEPSG().
  3. "EPSGA:n" - number passed on to importFromEPSGA().
  4. "AUTO:proj_id,unit_id,lon0,lat0" - WMS auto projections.
  5. "urn:ogc:def:crs:EPSG::n" - ogc urns
  6. PROJ.4 definitions - passed on to importFromProj4().
  7. filename - file read for WKT, XML or PROJ.4 definition.
  8. well known name accepted by SetWellKnownGeogCS(), such as NAD27, NAD83, WGS84 or WGS72.
  9. "IGNF:xxxx", "ESRI:xxxx", etc. from definitions from the PROJ database;

PROJJSON (PROJ >= 6.2)

Returns
pointer to srid string
NULL when srid is not available for the current location

Definition at line 233 of file get_projinfo.c.

References GPATH_MAX, and NULL.

◆ G_get_projunits()

struct Key_Value* G_get_projunits ( void  )

Gets units information for location.

Note: Allocated Key_Value structure should be freed by G_free_key_value().

Prints a warning if no units information available.

Returns
pointer to Key_Value structure with key/value pairs
NULL on failure

Definition at line 32 of file get_projinfo.c.

References _, G_file_name(), G_location(), G_projection(), G_read_key_value_file(), G_warning(), GPATH_MAX, NULL, PERMANENT, PROJECTION_XY, and UNIT_FILE.

◆ G_get_projwkt()

char* G_get_projwkt ( void  )

Get WKT information for the current location.

Returns
pointer to WKT string
NULL when WKT is not available for the current location

Definition at line 127 of file get_projinfo.c.

References GPATH_MAX, and NULL.