26#include "local_proto.h"
29#define CSVDIR "/etc/proj/ogr_csv"
31static void DatumNameMassage(
char **);
42 {
"km",
"1000.",
"Kilometer", 1000.0},
43 {
"m",
"1.",
"Meter", 1.0},
44 {
"dm",
"1/10",
"Decimeter", 0.1},
45 {
"cm",
"1/100",
"Centimeter", 0.01},
46 {
"mm",
"1/1000",
"Millimeter", 0.001},
47 {
"kmi",
"1852.0",
"International Nautical Mile", 1852.0},
48 {
"in",
"0.0254",
"International Inch", 0.0254},
49 {
"ft",
"0.3048",
"International Foot", 0.3048},
50 {
"yd",
"0.9144",
"International Yard", 0.9144},
51 {
"mi",
"1609.344",
"International Statute Mile", 1609.344},
52 {
"fath",
"1.8288",
"International Fathom", 1.8288},
53 {
"ch",
"20.1168",
"International Chain", 20.1168},
54 {
"link",
"0.201168",
"International Link", 0.201168},
55 {
"us-in",
"1./39.37",
"U.S. Surveyor's Inch", 0.0254},
56 {
"us-ft",
"0.304800609601219",
"U.S. Surveyor's Foot", 0.304800609601219},
57 {
"us-yd",
"0.914401828803658",
"U.S. Surveyor's Yard", 0.914401828803658},
58 {
"us-ch",
"20.11684023368047",
"U.S. Surveyor's Chain", 20.11684023368047},
59 {
"us-mi",
"1609.347218694437",
"U.S. Surveyor's Statute Mile",
61 {
"ind-yd",
"0.91439523",
"Indian Yard", 0.91439523},
62 {
"ind-ft",
"0.30479841",
"Indian Foot", 0.30479841},
63 {
"ind-ch",
"20.11669506",
"Indian Chain", 20.11669506},
66static char *grass_to_wkt(
const struct Key_Value *proj_info,
177 if ((proj_info ==
NULL) || (proj_units ==
NULL))
184 G_warning(
_(
"Unable parse GRASS PROJ_INFO file"));
191 G_warning(
_(
"Unable get PROJ.4-style parameter string"));
205 G_warning(
_(
"OGR can't parse PROJ.4-style parameter string: "
206 "%s (OGR Error code was %d)"),
219 G_warning(
_(
"OGR can't get WKT-style parameter string "
220 "(OGR Error code was %d)"),
245 G_debug(3,
"GPJ_grass_to_osr: datum: <%s>", datum);
312 "%sGEOGCS[\"%s\",DATUM[\"%s\",SPHEROID[\"%s\",%.16g,%.16g]%s],%s%s",
373 double df[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
450 G_debug(3,
"proj4 extension:");
462 G_warning(
_(
"Updating spatial reference with embedded proj4 "
463 "definition failed. "
464 "Proj4 definition: <%s>"),
473 G_warning(
_(
"Updating spatial reference with embedded proj4 "
611 G_warning(
_(
"No projection name! Projection parameters likely to be "
663 G_debug(3,
"GPJ_osr_to_grass: pszDatumNameConst: <%s>",
681 "Datum <%s> not recognised by GRASS and no "
700 "Datum <%s> apparently recognised by GRASS but "
701 "no parameters found. "
702 "You may want to look into this.",
708 "Invalid transformation number %d; valid range is "
710 "Leaving datum transform parameters unspecified.",
727 }
while (tlist !=
NULL);
788 fabs(1 - a /
list->a) < 0.0000001) &&
789 ((es == 0 &&
list->es == 0) ||
936 if (cellhd !=
NULL) {
972 struct Key_Value **projunits,
const char *wkt,
1034static const char *papszDatumEquiv[] = {
1035 "Militar_Geographische_Institute",
1036 "Militar_Geographische_Institut",
1037 "World_Geodetic_System_1984",
1039 "World_Geodetic_System_1972",
1041 "European_Terrestrial_Reference_System_89",
1042 "European_Terrestrial_Reference_System_1989",
1043 "European_Reference_System_1989",
1044 "European_Terrestrial_Reference_System_1989",
1046 "European_Terrestrial_Reference_System_1989",
1048 "European_Terrestrial_Reference_System_1989",
1050 "European_Terrestrial_Reference_System_1989",
1052 "New_Zealand_Geodetic_Datum_2000",
1057 "Campo_Inchauspe_1969",
1060 "System_Jednotne_Trigonometricke_Site_Katastralni",
1062 "Militar_Geographische_Institut",
1064 "Deutsches_Hauptdreiecksnetz",
1065 "Rauenberg_Datum_83",
1066 "Deutsches_Hauptdreiecksnetz",
1067 "South_American_1969",
1068 "South_American_Datum_1969",
1069 "International_Terrestrial_Reference_Frame_1992",
1083static void DatumNameMassage(
char **
ppszDatum)
1088 G_debug(3,
"DatumNameMassage: Raw string found <%s>", (
char *)
pszDatum);
1092 for (i = 0;
pszDatum[i] !=
'\0'; i++) {
1103 for (i = 1,
j = 0;
pszDatum[i] !=
'\0'; i++) {
1118 G_debug(3,
"DatumNameMassage: Search for datum equivalences of <%s>",
1120 for (i = 0; papszDatumEquiv[i] !=
NULL; i += 2) {
char * GPJ_grass_to_wkt(const struct Key_Value *proj_info, const struct Key_Value *proj_units, int esri_style, int prettify)
Converts a GRASS co-ordinate system representation to WKT style.
struct gpj_units gpj_units[]
OGRSpatialReferenceH GPJ_grass_to_osr2(const struct Key_Value *proj_info, const struct Key_Value *proj_units, const struct Key_Value *proj_epsg)
Converts a GRASS co-ordinate system to an OGRSpatialReferenceH object. EPSG code is preferred if avai...
int GPJ_osr_to_grass(struct Cell_head *cellhd, struct Key_Value **projinfo, struct Key_Value **projunits, OGRSpatialReferenceH hSRS1, int datumtrans)
Converts an OGRSpatialReferenceH object to a GRASS co-ordinate system.
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.
char * GPJ_grass_to_wkt2(const struct Key_Value *proj_info, const struct Key_Value *proj_units, const struct Key_Value *proj_epsg, int esri_style, int prettify)
Converts a GRASS co-ordinate system representation to WKT style. EPSG code is preferred if available.
OGRSpatialReferenceH GPJ_grass_to_osr(const struct Key_Value *proj_info, const struct Key_Value *proj_units)
Converts a GRASS co-ordinate system to an OGRSpatialReferenceH object.
const char * GPJ_set_csv_loc(const char *name)
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
const char * G_gisbase(void)
Get full path name of the top level module directory.
void G_free_key_value(struct Key_Value *)
Free allocated Key_Value structure.
void G_set_key_value(const char *, const char *, struct Key_Value *)
Set value for given key.
char ** G_tokenize(const char *, const char *)
Tokenize string.
int G_lookup_key_value_from_file(const char *, const char *, char[], int)
Look up for key in file.
void G_free_tokens(char **)
Free memory allocated to tokens.
int G_asprintf(char **, const char *,...) __attribute__((format(printf
struct Key_Value * G_create_key_value(void)
Allocate and initialize Key_Value structure.
int G_number_of_tokens(char **)
Return number of tokens.
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
char * G_store(const char *)
Copy string to allocated memory.
int G_debug(int, const char *,...) __attribute__((format(printf
void GPJ_free_datum(struct gpj_datum *)
Free the memory used for the strings in a gpj_datum struct.
int GPJ_get_ellipsoid_by_name(const char *, struct gpj_ellps *)
Looks up ellipsoid in ellipsoid table and returns the a, e2 parameters for the ellipsoid.
int GPJ_get_datum_by_name(const char *, struct gpj_datum *)
Look up a string in datum.table file to see if it is a valid datum name and if so place its informati...
void GPJ_free_ellps(struct gpj_ellps *)
Free ellipsoid data structure.
int GPJ_get_default_datum_params_by_name(const char *, char **)
"Last resort" function to retrieve a "default" set of datum parameters for a datum (N....
int GPJ__get_datum_params(const struct Key_Value *, char **, char **)
Extract the datum transformation-related parameters from a set of general PROJ_INFO parameters.
int pj_get_kv(struct pj_info *, const struct Key_Value *, const struct Key_Value *)
Create a pj_info struct Co-ordinate System definition from a set of PROJ_INFO / PROJ_UNITS-style key-...
int GPJ__get_ellipsoid_params(const struct Key_Value *, double *, double *, double *)
Get the ellipsoid parameters from proj keys structure.
void GPJ_free_datum_transform(struct gpj_datum_transform_list *)
Free the memory used by a gpj_datum_transform_list struct.
struct gpj_datum_transform_list * GPJ_get_datum_transform_by_name(const char *)
Internal function to find all possible sets of transformation parameters for a particular datum.
struct ellps_list * read_ellipsoid_table(int fatal)
void free_ellps_list(struct ellps_list *elist)
#define PROJECTION_OTHER
Projection code - other projection (other then noted above)
#define PROJECTION_XY
Projection code - XY coordinate system (unreferenced data)
#define PROJECTION_UTM
Projection code - UTM.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
void free_datum_list(struct datum_list *dstruct)
Free the memory used by a datum_list linked list structure.
struct datum_list * read_datum_table(void)
Read the current GRASS datum.table from disk and store in memory.
2D/3D raster map header (used also for region)
int zone
Projection zone (UTM)