GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
convert.c File Reference

GProj library - Functions for manipulating co-ordinate system representations. More...

#include <grass/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
#include <cpl_csv.h>
#include "local_proto.h"
Include dependency graph for convert.c:

Go to the source code of this file.

Macros

#define CSVDIR   "/etc/ogr_csv"
 

Functions

char * GPJ_grass_to_wkt (struct Key_Value *proj_info, struct Key_Value *proj_units, int esri_style, int prettify)
 Converts a GRASS co-ordinate system representation to WKT style. More...
 
OGRSpatialReferenceH GPJ_grass_to_osr (struct Key_Value *proj_info, struct Key_Value *proj_units)
 Converts a GRASS co-ordinate system to an OGRSpatialReferenceH object. More...
 
int GPJ_osr_to_grass (struct Cell_head *cellhd, struct Key_Value **projinfo, struct Key_Value **projunits, OGRSpatialReferenceH hSRS, int datumtrans)
 Converts an OGRSpatialReferenceH object to a GRASS co-ordinate system. More...
 
int GPJ_wkt_to_grass (struct Cell_head *cellhd, struct Key_Value **projinfo, struct Key_Value **projunits, const char *wkt, int datumtrans)
 Converts a WKT projection description to a GRASS co-ordinate system. More...
 
const char * GPJ_set_csv_loc (const char *name)
 

Detailed Description

GProj library - Functions for manipulating co-ordinate system representations.

Author
Paul Kelly, Frank Warmerdam

(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 convert.c.

Macro Definition Documentation

#define CSVDIR   "/etc/ogr_csv"

Definition at line 30 of file convert.c.

Referenced by GPJ_set_csv_loc().

Function Documentation

OGRSpatialReferenceH GPJ_grass_to_osr ( struct Key_Value *  proj_info,
struct Key_Value *  proj_units 
)

Converts a GRASS co-ordinate system to an OGRSpatialReferenceH object.

Parameters
proj_infoSet of GRASS PROJ_INFO key/value pairs
proj_unitsSet of GRASS PROJ_UNIT key/value pairs
Returns
OGRSpatialReferenceH object representing the co-ordinate system defined by proj_info and proj_units or NULL if it fails

Definition at line 88 of file convert.c.

References buff, G_asprintf(), G_find_key_value(), G_free(), G_store(), G_strcasecmp(), G_strstr(), G_warning(), GPJ__get_datum_params(), GPJ__get_ellipsoid_params(), GPJ_free_datum(), GPJ_free_ellps(), GPJ_get_datum_by_name(), GPJ_get_ellipsoid_by_name(), NULL, pj_get_kv(), and dialogs::unit.

Referenced by GPJ_grass_to_wkt().

char* GPJ_grass_to_wkt ( struct Key_Value *  proj_info,
struct Key_Value *  proj_units,
int  esri_style,
int  prettify 
)

Converts a GRASS co-ordinate system representation to WKT style.

Takes a GRASS co-ordinate system as specified by two sets of key/value pairs derived from the PROJ_INFO and PROJ_UNITS files, and converts it to the 'Well Known Text' format popularised by proprietary GIS

Parameters
proj_infoSet of GRASS PROJ_INFO key/value pairs
proj_unitsSet of GRASS PROJ_UNIT key/value pairs
esri_styleboolean Output ESRI-style WKT (Use OSRMorphToESRI() function provided by OGR library)
prettifyboolean Use linebreaks and indents to 'prettify' output WKT string (Use OSRExportToPrettyWkt() function in OGR)
Returns
Pointer to a string containing the co-ordinate system in WKT format

Definition at line 52 of file convert.c.

References G_store(), GPJ_grass_to_osr(), and NULL.

int GPJ_osr_to_grass ( struct Cell_head *  cellhd,
struct Key_Value **  projinfo,
struct Key_Value **  projunits,
OGRSpatialReferenceH  hSRS,
int  datumtrans 
)

Converts an OGRSpatialReferenceH object to a GRASS co-ordinate system.

Parameters
cellhdPointer to a GRASS Cell_head structure that will have its projection-related members populated with appropriate values
projinfoPointer to a pointer which will have a GRASS Key_Value structure allocated containing a set of GRASS PROJ_INFO values
projunitsPointer to a pointer which will have a GRASS Key_Value structure allocated containing a set of GRASS PROJ_UNITS values
hSRSOGRSpatialReferenceH object containing the co-ordinate system to be converted
datumtransIndex number of datum parameter set to use, 0 to leave unspecifed
Returns
2 if a projected or lat/long co-ordinate system has been defined; 1 if an unreferenced XY co-ordinate system has been defined

Definition at line 258 of file convert.c.

References ellps_list::a, ellps_list::es, free_datum_list(), free_ellps_list(), G_asprintf(), G_create_key_value(), G_free(), G_free_key_value(), G_gisbase(), G_lookup_key_value_from_file(), G_set_key_value(), G_store(), G_strcasecmp(), G_warning(), GPJ__get_datum_params(), GPJ_free_datum(), GPJ_get_datum_by_name(), GPJ_get_datum_transform_by_name(), GPJ_get_default_datum_params_by_name(), GPJ_set_csv_loc(), datum_list::longname, datum_list::name, render::name, datum_list::next, NULL, old, read_datum_table(), read_ellipsoid_table(), and sprintf().

Referenced by GPJ_wkt_to_grass().

const char* GPJ_set_csv_loc ( const char *  name)

Definition at line 693 of file convert.c.

References buf, CSVDIR, G_asprintf(), G_free(), G_gisbase(), forms::gisbase, and NULL.

Referenced by GPJ_osr_to_grass(), and GPJ_wkt_to_grass().

int GPJ_wkt_to_grass ( struct Cell_head *  cellhd,
struct Key_Value **  projinfo,
struct Key_Value **  projunits,
const char *  wkt,
int  datumtrans 
)

Converts a WKT projection description to a GRASS co-ordinate system.

Parameters
cellhdPointer to a GRASS Cell_head structure that will have its projection-related members populated with appropriate values
projinfoPointer to a pointer which will have a GRASS Key_Value structure allocated containing a set of GRASS PROJ_INFO values
projunitsPointer to a pointer which will have a GRASS Key_Value structure allocated containing a set of GRASS PROJ_UNITS values
wktWell-known Text (WKT) description of the co-ordinate system to be converted
datumtransIndex number of datum parameter set to use, 0 to leave unspecifed
Returns
2 if a projected or lat/long co-ordinate system has been defined; 1 if an unreferenced XY co-ordinate system has been defined

Definition at line 665 of file convert.c.

References GPJ_osr_to_grass(), GPJ_set_csv_loc(), and NULL.