GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73566
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
get_proj.c File Reference

GProj library - Functions for re-projecting point data. More...

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
Include dependency graph for get_proj.c:

Go to the source code of this file.

Macros

#define FINDERFUNC   set_proj_lib
 
#define PERMANENT   "PERMANENT"
 
#define MAX_PARGS   100
 

Functions

int pj_get_kv (struct pj_info *info, const struct Key_Value *in_proj_keys, const struct Key_Value *in_units_keys)
 Create a pj_info struct Co-ordinate System definition from a set of PROJ_INFO / PROJ_UNITS-style key-value pairs. More...
 
int pj_get_string (struct pj_info *info, char *str)
 Create a pj_info struct Co-ordinate System definition from a string with a sequence of key=value pairs. More...
 
int GPJ_get_equivalent_latlong (struct pj_info *pjnew, struct pj_info *pjold)
 Define a latitude / longitude co-ordinate system with the same ellipsoid and datum parameters as an existing projected system. More...
 
const char * set_proj_lib (const char *name)
 
int pj_print_proj_params (const struct pj_info *iproj, const struct pj_info *oproj)
 Print projection parameters as used by PROJ.4 for input and output co-ordinate systems. More...
 

Detailed Description

GProj library - Functions for re-projecting point data.

Author
Original Author unknown, probably Soil Conservation Service, Eric Miller, Paul Kelly, Markus Metz

(C) 2003-2008, 2018 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_proj.c.

Macro Definition Documentation

#define FINDERFUNC   set_proj_lib

Definition at line 27 of file get_proj.c.

Referenced by pj_get_kv(), and pj_get_string().

#define MAX_PARGS   100

Definition at line 29 of file get_proj.c.

Referenced by pj_get_string().

#define PERMANENT   "PERMANENT"

Definition at line 28 of file get_proj.c.

Function Documentation

int GPJ_get_equivalent_latlong ( struct pj_info pjnew,
struct pj_info pjold 
)

Define a latitude / longitude co-ordinate system with the same ellipsoid and datum parameters as an existing projected system.

This function is useful when projected co-ordinates need to be simply converted to and from latitude / longitude.

Parameters
pjnewPointer to pj_info struct for geographic co-ordinate system that will be created
pjoldPointer to pj_info struct for existing projected co-ordinate system
Returns
1 on success; -1 if there was an error (i.e. if the PROJ.4 pj_latlong_from_proj() function returned NULL)

Definition at line 442 of file get_proj.c.

References pj_info::def, G_store(), pj_info::meters, NULL, pj_info::pj, pj_info::proj, and pj_info::zone.

Referenced by GPJ_init_transform().

int pj_get_kv ( struct pj_info info,
const struct Key_Value in_proj_keys,
const struct Key_Value in_units_keys 
)

Create a pj_info struct Co-ordinate System definition from a set of PROJ_INFO / PROJ_UNITS-style key-value pairs.

This function takes a GRASS-style co-ordinate system definition as stored in the PROJ_INFO and PROJ_UNITS files and processes it to create a pj_info representation for use in re-projecting with pj_do_proj(). In addition to the parameters passed to it it may also make reference to the system ellipse.table and datum.table files if necessary.

Parameters
infoPointer to a pj_info struct (which must already exist) into which the co-ordinate system definition will be placed
in_proj_keysPROJ_INFO-style key-value pairs
in_units_keysPROJ_UNITS-style key-value pairs
Returns
-1 on error (unable to initialise PROJ.4) 2 if "default" 3-parameter datum shift values from datum.table were used 3 if an unrecognised datum name was passed on to PROJ.4 (and initialization was successful) 1 otherwise

Definition at line 61 of file get_proj.c.

References _, pj_info::def, err(), FINDERFUNC, G_fatal_error(), G_find_key_value(), G_free(), G_warning(), GPJ__get_datum_params(), GPJ__get_ellipsoid_params(), GPJ_get_default_datum_params_by_name(), Key_Value::key, pj_info::meters, Key_Value::nitems, NULL, pj_info::pj, pj_info::proj, Key_Value::value, and pj_info::zone.

Referenced by GPJ_grass_to_osr().

int pj_get_string ( struct pj_info info,
char *  str 
)

Create a pj_info struct Co-ordinate System definition from a string with a sequence of key=value pairs.

This function takes a GRASS- or PROJ style co-ordinate system definition and processes it to create a pj_info representation for use in re-projecting with pj_do_proj(). In addition to the parameters passed to it it may also make reference to the system ellipse.table and datum.table files if necessary.

Parameters
infoPointer to a pj_info struct (which must already exist) into which the co-ordinate system definition will be placed
strinput string with projection definition
in_units_keysPROJ_UNITS-style key-value pairs
Returns
-1 on error (unable to initialise PROJ.4) 1 on success

Definition at line 314 of file get_proj.c.

References _, pj_info::def, FINDERFUNC, G_fatal_error(), G_free(), G_warning(), MAX_PARGS, pj_info::meters, NULL, pj_info::pj, pj_info::proj, and pj_info::zone.

int pj_print_proj_params ( const struct pj_info iproj,
const struct pj_info oproj 
)

Print projection parameters as used by PROJ.4 for input and output co-ordinate systems.

Parameters
iproj'Input' co-ordinate system
oproj'Output' co-ordinate system
Returns
1 on success, -1 on error (i.e. if the PROJ-style definition is NULL for either co-ordinate system)

Definition at line 494 of file get_proj.c.

References _, pj_info::def, pj_info::meters, and NULL.

const char* set_proj_lib ( const char *  name)

Definition at line 464 of file get_proj.c.

References G_free(), G_gisbase(), GRIDDIR, and NULL.