GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
make_loc.c File Reference

GIS Library - Functions to create a new location. More...

#include <grass/gis.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <math.h>
#include <grass/glocale.h>
Include dependency graph for make_loc.c:

Go to the source code of this file.

Functions

int G_make_location (const char *location_name, struct Cell_head *wind, const struct Key_Value *proj_info, const struct Key_Value *proj_units)
 Create a new location. More...
 
int G_make_location_epsg (const char *location_name, struct Cell_head *wind, const struct Key_Value *proj_info, const struct Key_Value *proj_units, const struct Key_Value *proj_epsg)
 Create a new location. More...
 
int G_make_location_crs (const char *location_name, struct Cell_head *wind, const struct Key_Value *proj_info, const struct Key_Value *proj_units, const char *proj_srid, const char *proj_wkt)
 Create a new location. More...
 
int G_compare_projections (const struct Key_Value *proj_info1, const struct Key_Value *proj_units1, const struct Key_Value *proj_info2, const struct Key_Value *proj_units2)
 Compare projections including units. More...
 
int G_write_projwkt (const char *location_name, const char *wktstring)
 Write WKT definition to file. More...
 
int G_write_projsrid (const char *location_name, const char *sridstring)
 Write srid (spatial reference id) to file. More...
 

Detailed Description

GIS Library - Functions to create a new location.

Creates a new location automatically given a "Cell_head", PROJ_INFO and PROJ_UNITS information.

(C) 2000-2013 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.

Author
Frank Warmerdam

Definition in file make_loc.c.

Function Documentation

◆ G_compare_projections()

int G_compare_projections ( const struct Key_Value proj_info1,
const struct Key_Value proj_units1,
const struct Key_Value proj_info2,
const struct Key_Value proj_units2 
)

Compare projections including units.

Parameters
proj_info1projection info to compare
proj_units1projection units to compare
proj_info2projection info to compare
proj_units2projection units to compare
Returns
-1 if not the same projection
-2 if linear unit translation to meters fails
-3 if not the same datum,
-4 if not the same ellipsoid,
-5 if UTM zone differs
-6 if UTM hemisphere differs,
-7 if false easting differs
-8 if false northing differs,
-9 if center longitude differs,
-10 if center latitude differs,
-11 if standard parallels differ,
1 if projections match.

Definition at line 231 of file make_loc.c.

References G_find_key_value(), NULL, and TRUE.

◆ G_make_location()

int G_make_location ( const char *  location_name,
struct Cell_head wind,
const struct Key_Value proj_info,
const struct Key_Value proj_units 
)

Create a new location.

This function creates a new location in the current database, initializes the projection, default window and current window.

Parameters
location_nameName of the new location. Should not include the full path, the location will be created within the current database.
winddefault window setting for the new location. All fields should be set in this structure, and care should be taken to ensure that the proj/zone fields match the definition in the proj_info parameter(see G_set_cellhd_from_projinfo()).
proj_infoprojection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
proj_unitsprojection units suitable to write to the PROJ_UNITS file, or NULL.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 failed to create projection file (currently not used)
-3 illegal name

Definition at line 53 of file make_loc.c.

◆ G_make_location_crs()

int G_make_location_crs ( const char *  location_name,
struct Cell_head wind,
const struct Key_Value proj_info,
const struct Key_Value proj_units,
const char *  proj_srid,
const char *  proj_wkt 
)

Create a new location.

This function creates a new location in the current database, initializes the projection, default window and current window, and sets WKT, srid, and EPSG code if present

Parameters
location_nameName of the new location. Should not include the full path, the location will be created within the current database.
winddefault window setting for the new location. All fields should be set in this structure, and care should be taken to ensure that the proj/zone fields match the definition in the proj_info parameter(see G_set_cellhd_from_projinfo()).
proj_infoprojection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
proj_unitsprojection units suitable to write to the PROJ_UNITS file, or NULL.
proj_epsgEPSG code suitable to write to the PROJ_EPSG file, or NULL.
proj_wktWKT definition suitable to write to the PROJ_WKT file, or NULL.
proj_sridSpatial reference ID suitable to write to the PROJ_SRID file, or NULL.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 failed to create projection file (currently not used)
-3 illegal name

Definition at line 185 of file make_loc.c.

◆ G_make_location_epsg()

int G_make_location_epsg ( const char *  location_name,
struct Cell_head wind,
const struct Key_Value proj_info,
const struct Key_Value proj_units,
const struct Key_Value proj_epsg 
)

Create a new location.

This function creates a new location in the current database, initializes the projection, default window and current window, and sets the EPSG code if present

Parameters
location_nameName of the new location. Should not include the full path, the location will be created within the current database.
winddefault window setting for the new location. All fields should be set in this structure, and care should be taken to ensure that the proj/zone fields match the definition in the proj_info parameter(see G_set_cellhd_from_projinfo()).
proj_infoprojection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
proj_unitsprojection units suitable to write to the PROJ_UNITS file, or NULL.
proj_epsgEPSG code suitable to write to the PROJ_EPSG file, or NULL.
Returns
0 on success
-1 to indicate a system error (check errno).
-2 failed to create projection file (currently not used)
-3 illegal name

Definition at line 126 of file make_loc.c.

◆ G_write_projsrid()

int G_write_projsrid ( const char *  location_name,
const char *  sridstring 
)

Write srid (spatial reference id) to file.

A srid consists of an authority name and code and must be known to PROJ.

Parameters
location_namename of the location to write the srid
sridstringpointer to srid string
Returns
0 success
-1 error writing

Definition at line 563 of file make_loc.c.

References _, err(), G_fatal_error(), G_file_name(), G_gisdbase(), GPATH_MAX, and SRID_FILE.

◆ G_write_projwkt()

int G_write_projwkt ( const char *  location_name,
const char *  wktstring 
)

Write WKT definition to file.

Any WKT string and version recognized by PROJ is supported.

Parameters
location_namename of the location to write the WKT definition
wktstringpointer to WKT string
Returns
0 success
-1 error writing

Definition at line 511 of file make_loc.c.

References _, err(), G_fatal_error(), G_file_name(), G_gisdbase(), GPATH_MAX, and WKT_FILE.