aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBrendan Jurd <direvus@gmail.com>2021-09-27 17:17:58 +1000
committerGitHub <noreply@github.com>2021-09-27 09:17:58 +0200
commite27c4424ea84160ddc957032cb65e444f7d7944a (patch)
tree6cc74731199d03fa465aaa01dae4f7ce2964fa3b /examples
parent3a827d2e041bf49e0e19800a5f666a0b1af153c3 (diff)
downloadPROJ-e27c4424ea84160ddc957032cb65e444f7d7944a.tar.gz
PROJ-e27c4424ea84160ddc957032cb65e444f7d7944a.zip
DOC: Refresh Development/Quickstart and remove Development/Threads (#2863)
* DOC: Refresh Development/Quickstart and remove Development/Threads The document Development/Threads was severely out of date, and was focussed on contrasting the current API with an old API that was deprecated several years ago, and removed from the current PROJ earlier this year. Update Development/Quickstart to give more information about the use of threading context, as a replacement for the content that was previously in Threads. Also give the example code examples/pj_obs_api_mini_demo.c a cleanup pass to make it at least internally consistent with its own code style. The header comments of the example code are still, much like the Threads document, fixated on comparing proj.h against proj_api.h, which is an interesting historical curio to be sure, but probably doesn't need to persist here. It might be worth cleaning this up further as a separate exercise. Fixes #2451
Diffstat (limited to 'examples')
-rw-r--r--examples/pj_obs_api_mini_demo.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/examples/pj_obs_api_mini_demo.c b/examples/pj_obs_api_mini_demo.c
index 3df94e2d..5cd5efe4 100644
--- a/examples/pj_obs_api_mini_demo.c
+++ b/examples/pj_obs_api_mini_demo.c
@@ -1,6 +1,6 @@
/*******************************************************************************
- Tiny test of an evolving new API, demonstrating simple examples of
- 2D and 3D transformations.
+ Simple example code demonstrating use of the proj.h API for 2D coordinate
+ transformations.
The main transformation setup object is PJ, well known from the two
former proj APIs (projects.h and proj_api.h)
@@ -42,7 +42,7 @@
int main (void) {
PJ_CONTEXT *C;
PJ *P;
- PJ* P_for_GIS;
+ PJ *norm;
PJ_COORD a, b;
/* or you may set C=PJ_DEFAULT_CTX if you are sure you will */
@@ -54,35 +54,36 @@ int main (void) {
"+proj=utm +zone=32 +datum=WGS84", /* or EPSG:32632 */
NULL);
- if (0==P) {
- fprintf(stderr, "Oops\n");
+ if (0 == P) {
+ fprintf(stderr, "Failed to create transformation object.\n");
return 1;
}
/* This will ensure that the order of coordinates for the input CRS */
/* will be longitude, latitude, whereas EPSG:4326 mandates latitude, */
/* longitude */
- P_for_GIS = proj_normalize_for_visualization(C, P);
- if( 0 == P_for_GIS ) {
- fprintf(stderr, "Oops\n");
+ norm = proj_normalize_for_visualization(C, P);
+ if (0 == norm) {
+ fprintf(stderr, "Failed to normalize transformation object.\n");
return 1;
}
proj_destroy(P);
- P = P_for_GIS;
+ P = norm;
/* a coordinate union representing Copenhagen: 55d N, 12d E */
/* Given that we have used proj_normalize_for_visualization(), the order of
/* coordinates is longitude, latitude, and values are expressed in degrees. */
- a = proj_coord (12, 55, 0, 0);
+ a = proj_coord(12, 55, 0, 0);
/* transform to UTM zone 32, then back to geographical */
- b = proj_trans (P, PJ_FWD, a);
- printf ("easting: %.3f, northing: %.3f\n", b.enu.e, b.enu.n);
- b = proj_trans (P, PJ_INV, b);
- printf ("longitude: %g, latitude: %g\n", b.lp.lam, b.lp.phi);
+ b = proj_trans(P, PJ_FWD, a);
+ printf("easting: %.3f, northing: %.3f\n", b.enu.e, b.enu.n);
+
+ b = proj_trans(P, PJ_INV, b);
+ printf("longitude: %g, latitude: %g\n", b.lp.lam, b.lp.phi);
/* Clean up */
- proj_destroy (P);
- proj_context_destroy (C); /* may be omitted in the single threaded case */
+ proj_destroy(P);
+ proj_context_destroy(C); /* may be omitted in the single threaded case */
return 0;
}