Loading...
Searching...
No Matches
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.
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.
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.
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.
int | G_write_projwkt (const char *location_name, const char *wktstring)
| Write WKT definition to file.
int | G_write_projsrid (const char *location_name, const char *sridstring)
| Write srid (spatial reference id) to file.

## 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_info1 | projection info to compare
  proj_units1 | projection units to compare
  proj_info2 | projection info to compare
  proj_units2 | projection 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 229 of file make_loc.c.

References G_debug(), G_find_key_value(), G_get_ellipsoid_by_name(), G_strcasecmp(), 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_name | Name of the new location. Should not include the full path, the location will be created within the current database.
  wind | default 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_info | projection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
  proj_units | projection 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.

References G_file_name(), G_gisdbase(), G_legal_filename(), G_mkdir(), G_put_element_window(), G_setenv_nogisrc(), G_write_key_value_file(), and NULL.

Referenced by G_make_location_crs(), and G_make_location_epsg().

## 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_name | Name of the new location. Should not include the full path, the location will be created within the current database.
  wind | default 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_info | projection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
  proj_units | projection units suitable to write to the PROJ_UNITS file, or NULL.
  proj_srid | Spatial reference ID suitable to write to the PROJ_SRID file, or NULL.
  proj_wkt | WKT definition suitable to write to the PROJ_WKT 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 183 of file make_loc.c.

References G_make_location(), G_write_projsrid(), G_write_projwkt(), and NULL.

## 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_name | Name of the new location. Should not include the full path, the location will be created within the current database.
  wind | default 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_info | projection definition suitable to write to the PROJ_INFO file, or NULL for PROJECTION_XY.
  proj_units | projection units suitable to write to the PROJ_UNITS file, or NULL.
  proj_epsg | EPSG 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 127 of file make_loc.c.

References G_file_name(), G_make_location(), G_write_key_value_file(), and NULL.

## 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_name | name of the location to write the srid
  sridstring | pointer to srid string

Returns
  0 success
  -1 error writing

Definition at line 559 of file make_loc.c.

References err(), G_fatal_error(), G_file_name(), and G_gisdbase().

Referenced by G_make_location_crs().

## 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_name | name of the location to write the WKT definition
  wktstring | pointer to WKT string

Returns
  0 success
  -1 error writing

Definition at line 508 of file make_loc.c.

References err(), G_fatal_error(), G_file_name(), and G_gisdbase().

Referenced by G_make_location_crs().