GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-36359e2344
|
GProj library - Functions for re-projecting point data. More...
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/gprojects.h>
#include <grass/glocale.h>
Go to the source code of this file.
Macros | |
#define | MULTIPLY_LOOP(x, y, c, m) |
#define | DIVIDE_LOOP(x, y, c, m) |
Functions | |
int | GPJ_init_transform (const struct pj_info *info_in, const struct pj_info *info_out, struct pj_info *info_trans) |
Create a PROJ transformation object to transform coordinates from an input SRS to an output SRS. More... | |
int | GPJ_transform (const struct pj_info *info_in, const struct pj_info *info_out, const struct pj_info *info_trans, int dir, double *x, double *y, double *z) |
Re-project a point between two co-ordinate systems using a transformation object prepared with GPJ_prepare_pj() More... | |
int | GPJ_transform_array (const struct pj_info *info_in, const struct pj_info *info_out, const struct pj_info *info_trans, int dir, double *x, double *y, double *z, int n) |
Re-project an array of points between two co-ordinate systems using a transformation object prepared with GPJ_prepare_pj() More... | |
int | pj_do_proj (double *x, double *y, const struct pj_info *info_in, const struct pj_info *info_out) |
Re-project a point between two co-ordinate systems. More... | |
int | pj_do_transform (int count, double *x, double *y, double *h, const struct pj_info *info_in, const struct pj_info *info_out) |
Re-project an array of points between two co-ordinate systems with optional ellipsoidal height conversion. More... | |
GProj library - Functions for re-projecting point data.
(C) 2003-2008,2018 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 do_proj.c.
#define DIVIDE_LOOP | ( | x, | |
y, | |||
c, | |||
m | |||
) |
#define MULTIPLY_LOOP | ( | x, | |
y, | |||
c, | |||
m | |||
) |
int GPJ_init_transform | ( | const struct pj_info * | info_in, |
const struct pj_info * | info_out, | ||
struct pj_info * | info_trans | ||
) |
Create a PROJ transformation object to transform coordinates from an input SRS to an output SRS.
After the transformation has been initialized with this function, coordinates can be transformed from input SRS to output SRS with GPJ_transform() and direction = PJ_FWD, and back from output SRS to input SRS with direction = OJ_INV. If coordinates should be transformed between the input SRS and its latlong equivalent, an uninitialized info_out with info_out->pj = NULL can be passed to the function. In this case, coordinates will be transformed between the input SRS and its latlong equivalent, and for PROJ 5+, the transformation object is created accordingly, while for PROJ 4, the output SRS is created as latlong equivalent of the input SRS
PROJ 5+: info_in->pj must not be null if info_out->pj is null, assume info_out to be the ll equivalent of info_in create info_trans as conversion from info_in to its ll equivalent NOTE: this is the inverse of the logic of PROJ 5 which by default converts from ll to a given SRS, not from a given SRS to ll thus PROJ 5+ itself uses an inverse transformation in the first step of the pipeline for proj_create_crs_to_crs() if info_trans->def is not NULL, this pipeline definition will be used to create a transformation object PROJ 4: info_in->pj must not be null if info_out->pj is null, create info_out as ll equivalent else do nothing, info_trans is not used
info_in | pointer to pj_info struct for input co-ordinate system |
info_out | pointer to pj_info struct for output co-ordinate system |
info_trans | pointer to pj_info struct for a transformation object (PROJ 5+) |
Definition at line 434 of file do_proj.c.
References _, pj_info::def, G_asprintf(), G_debug(), G_fatal_error(), G_free(), G_important_message(), G_store(), G_store_upper(), G_warning(), pj_info::meters, NULL, pj_info::pj, pj_info::proj, pj_info::srid, and pj_info::zone.
int GPJ_transform | ( | const struct pj_info * | info_in, |
const struct pj_info * | info_out, | ||
const struct pj_info * | info_trans, | ||
int | dir, | ||
double * | x, | ||
double * | y, | ||
double * | z | ||
) |
Re-project a point between two co-ordinate systems using a transformation object prepared with GPJ_prepare_pj()
This function takes pointers to three pj_info structures as arguments, and projects a point between the input and output co-ordinate system. The pj_info structure info_trans must have been initialized with GPJ_init_transform(). The direction determines if a point is projected from input CRS to output CRS (PJ_FWD) or from output CRS to input CRS (PJ_INV). The easting, northing, and height of the point are contained in the pointers passed to the function; these will be overwritten by the coordinates of the transformed point.
info_in | pointer to pj_info struct for input co-ordinate system |
info_out | pointer to pj_info struct for output co-ordinate system |
info_trans | pointer to pj_info struct for a transformation object (PROJ 5+) |
dir | direction of the transformation (PJ_FWD or PJ_INV) |
x | Pointer to a double containing easting or longitude |
y | Pointer to a double containing northing or latitude |
z | Pointer to a double containing height, or NULL |
int GPJ_transform_array | ( | const struct pj_info * | info_in, |
const struct pj_info * | info_out, | ||
const struct pj_info * | info_trans, | ||
int | dir, | ||
double * | x, | ||
double * | y, | ||
double * | z, | ||
int | n | ||
) |
Re-project an array of points between two co-ordinate systems using a transformation object prepared with GPJ_prepare_pj()
This function takes pointers to three pj_info structures as arguments, and projects an array of pointd between the input and output co-ordinate system. The pj_info structure info_trans must have been initialized with GPJ_init_transform(). The direction determines if a point is projected from input CRS to output CRS (PJ_FWD) or from output CRS to input CRS (PJ_INV). The easting, northing, and height of the point are contained in the pointers passed to the function; these will be overwritten by the coordinates of the transformed point.
info_in | pointer to pj_info struct for input co-ordinate system |
info_out | pointer to pj_info struct for output co-ordinate system |
info_trans | pointer to pj_info struct for a transformation object (PROJ 5+) |
dir | direction of the transformation (PJ_FWD or PJ_INV) |
x | pointer to an array of type double containing easting or longitude |
y | pointer to an array of type double containing northing or latitude |
z | pointer to an array of type double containing height, or NULL |
n | number of points in the arrays to be transformed |
int pj_do_proj | ( | double * | x, |
double * | y, | ||
const struct pj_info * | info_in, | ||
const struct pj_info * | info_out | ||
) |
Re-project a point between two co-ordinate systems.
This function takes pointers to two pj_info structures as arguments, and projects a point between the co-ordinate systems represented by them. The easting and northing of the point are contained in two pointers passed to the function; these will be overwritten by the co-ordinates of the re-projected point.
x | Pointer to a double containing easting or longitude |
y | Pointer to a double containing northing or latitude |
info_in | pointer to pj_info struct for input co-ordinate system |
info_out | pointer to pj_info struct for output co-ordinate system |
int pj_do_transform | ( | int | count, |
double * | x, | ||
double * | y, | ||
double * | h, | ||
const struct pj_info * | info_in, | ||
const struct pj_info * | info_out | ||
) |
Re-project an array of points between two co-ordinate systems with optional ellipsoidal height conversion.
This function takes pointers to two pj_info structures as arguments, and projects an array of points between the co-ordinate systems represented by them. Pointers to the three arrays of easting, northing, and ellipsoidal height of the point (this one may be NULL) are passed to the function; these will be overwritten by the co-ordinates of the re-projected points.
count | Number of points in the arrays to be transformed |
x | Pointer to an array of type double containing easting or longitude |
y | Pointer to an array of type double containing northing or latitude |
h | Pointer to an array of type double containing ellipsoidal height. May be null in which case a two-dimensional re-projection will be done |
info_in | pointer to pj_info struct for input co-ordinate system |
info_out | pointer to pj_info struct for output co-ordinate system |