Loading...
Searching...
No Matches
datum.c File Reference

GProj library - Functions for reading datum parameters from the location database. More...

`#include <unistd.h>`
`#include <string.h>`
`#include <ctype.h>`
`#include <stdlib.h>`
`#include <grass/gis.h>`
`#include <grass/glocale.h>`
`#include <grass/gprojects.h>`
`#include "local_proto.h"`
Include dependency graph for proj/datum.c:

Go to the source code of this file.

## Functions

int | GPJ_get_datum_by_name (const char *name, struct gpj_datum *dstruct)
| Look up a string in datum.table file to see if it is a valid datum name and if so place its information into a gpj_datum struct.
int | GPJ_get_default_datum_params_by_name (const char *name, char **params)
| "Last resort" function to retrieve a "default" set of datum parameters for a datum (N.B. there really is no such thing as a catch-all default!)
int | GPJ_get_datum_params (char **name, char **params)
| Extract the datum transformation-related parameters for the current location.
int | GPJ__get_datum_params (const struct Key_Value *projinfo, char **datumname, char **params)
| Extract the datum transformation-related parameters from a set of general PROJ_INFO parameters.
struct gpj_datum_transform_list * | GPJ_get_datum_transform_by_name (const char *inputname)
| Internal function to find all possible sets of transformation parameters for a particular datum.
void | GPJ_free_datum_transform (struct gpj_datum_transform_list *item)
| Free the memory used by a gpj_datum_transform_list struct.
struct datum_list * | read_datum_table (void)
| Read the current GRASS datum.table from disk and store in memory.
void | GPJ_free_datum (struct gpj_datum *dstruct)
| Free the memory used for the strings in a gpj_datum struct.
void | free_datum_list (struct datum_list *dstruct)
| Free the memory used by a datum_list linked list structure.

## Detailed Description

GProj library - Functions for reading datum parameters from the location database.

Author
  Andreas Lange <andreas.lange rhein-main.de>, Paul Kelly <paul-grass stjohnspoint.co.uk>

(C) 2003-2008 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 proj/datum.c.

## Function Documentation

## free_datum_list()

void free_datum_list | ( | struct datum_list * | dstruct | ) |

Free the memory used by a datum_list linked list structure.

Parameters

  dstruct | datum_list struct to be freed

Definition at line 410 of file proj/datum.c.

References G_free(), and NULL.

Referenced by GPJ_get_datum_by_name(), and GPJ_osr_to_grass().

## GPJ__get_datum_params()

int GPJ__get_datum_params | ( | const struct Key_Value * | projinfo,
|  | char ** | datumname,
|  | char ** | params )

Extract the datum transformation-related parameters from a set of general PROJ_INFO parameters.

This function can be used to test if a location's co-ordinate system set-up supports datum transformation.

Parameters

  projinfo | Set of key_value pairs containing projection information in PROJ_INFO file format
  datumname | Pointer to a pointer which will have memory allocated and into which a string containing the datum name (if present) will be placed. Otherwise set to NULL.
  params | Pointer to a pointer which will have memory allocated and into which a string containing the datum parameters (if present) will be placed. Otherwise set to NULL.

Returns
  -1 error or no datum information found, 1 only datum name found, 2 params found

Definition at line 173 of file proj/datum.c.

References G_asprintf(), G_debug(), G_find_key_value(), G_store(), and NULL.

Referenced by GPJ_get_datum_params(), GPJ_grass_to_osr(), GPJ_osr_to_grass(), and pj_get_kv().

## GPJ_free_datum()

void GPJ_free_datum | ( | struct gpj_datum * | dstruct | ) |

Free the memory used for the strings in a gpj_datum struct.

Parameters

  dstruct | gpj_datum struct to be freed

Definition at line 396 of file proj/datum.c.

References G_free().

Referenced by GPJ__get_ellipsoid_params(), GPJ_get_datum_transform_by_name(), GPJ_grass_to_osr(), and GPJ_osr_to_grass().

## GPJ_free_datum_transform()

void GPJ_free_datum_transform | ( | struct gpj_datum_transform_list * | item | ) |

Free the memory used by a gpj_datum_transform_list struct.

Parameters

  item | gpj_datum_transform_list struct to be freed

Definition at line 323 of file proj/datum.c.

References G_free().

Referenced by GPJ_get_default_datum_params_by_name(), and GPJ_osr_to_grass().

## GPJ_get_datum_by_name()

int GPJ_get_datum_by_name | ( | const char * | name,
|  | struct gpj_datum * | dstruct )

Look up a string in datum.table file to see if it is a valid datum name and if so place its information into a gpj_datum struct.

Parameters

  name | String containing datum name to look up
  dstruct | gpj_datum struct into which datum parameters will be placed if found

Returns
  1 if datum found, -1 if not

Definition at line 38 of file proj/datum.c.

References free_datum_list(), G_store(), G_strcasecmp(), list, name, NULL, and read_datum_table().

Referenced by GPJ__get_ellipsoid_params(), GPJ_get_datum_transform_by_name(), GPJ_grass_to_osr(), and GPJ_osr_to_grass().

## GPJ_get_datum_params()

int GPJ_get_datum_params | ( | char ** | name,
|  | char ** | params )

Extract the datum transformation-related parameters for the current location.

This function can be used to test if a location's co-ordinate system set-up supports datum transformation.

Parameters

  name | Pointer to a pointer which will have memory allocated and into which a string containing the datum name (if present) will be placed. Otherwise set to NULL.
  params | Pointer to a pointer which will have memory allocated and into which a string containing the datum parameters (if present) will be placed. Otherwise set to NULL.

Returns
  -1 error or no datum information found, 1 only datum name found, 2 params found

Definition at line 135 of file proj/datum.c.

References G_free_key_value(), G_get_projinfo(), GPJ__get_datum_params(), and name.

## GPJ_get_datum_transform_by_name()

struct gpj_datum_transform_list * GPJ_get_datum_transform_by_name | ( | const char * | inputname | ) |

Internal function to find all possible sets of transformation parameters for a particular datum.

Parameters

  inputname | String containing the datum name we are going to look up parameters for

Returns
  Pointer to struct gpj_datum_transform_list (a linked list containing transformation parameters), or NULL if no suitable parameters were found.

Definition at line 237 of file proj/datum.c.

References count, file, G_asprintf(), G_getl2(), G_gisbase(), G_store(), G_strcasecmp(), G_strip(), G_warning(), GPJ_free_datum(), GPJ_get_datum_by_name(), name, and NULL.

Referenced by GPJ_get_default_datum_params_by_name(), and GPJ_osr_to_grass().

## GPJ_get_default_datum_params_by_name()

int GPJ_get_default_datum_params_by_name | ( | const char * | name,
|  | char ** | params )

"Last resort" function to retrieve a "default" set of datum parameters for a datum (N.B. there really is no such thing as a catch-all default!)

Kind of a "last resort" function as there really is no such thing as a default set of datum transformation parameters. Only should really be used where user interaction to choose a set of parameters is not desirable. Use of this function is not likely to result in selection of the optimum set of datum transformation parameters for the location

Parameters

  name | String containing GRASS datum name for which default parameters are to be retrieved
  params | Pointer to a pointer which will have memory allocated and into which a string containing the datum parameters (if present) will be placed

Returns
  The number of possible parameter sets GRASS knows about for this datum

Definition at line 86 of file proj/datum.c.

References count, G_store(), GPJ_free_datum_transform(), GPJ_get_datum_transform_by_name(), list, name, and NULL.

Referenced by GPJ_osr_to_grass(), and pj_get_kv().

## read_datum_table()

struct datum_list * read_datum_table | ( | void |  | ) |

Read the current GRASS datum.table from disk and store in memory.

The datum information is stored in a datum_list linked list structure.

Returns
  Pointer to first datum_list element in linked list, or NULL if unable to open datum.table file

Definition at line 342 of file proj/datum.c.

References DATUMTABLE, file, G_getl2(), G_gisbase(), G_store(), G_strip(), G_warning(), name, and NULL.

Referenced by GPJ_get_datum_by_name(), and GPJ_osr_to_grass().