aboutsummaryrefslogtreecommitdiff
path: root/test/postinstall/c_app/c_app.c
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2021-12-09 00:45:03 +1300
committerGitHub <noreply@github.com>2021-12-09 00:45:03 +1300
commit7a9b6566ac02d8c408f4f3758bfa5fcc3e90b552 (patch)
treed71d0771cc9f95d5a8ea96bd975bbd4164188813 /test/postinstall/c_app/c_app.c
parent1b18defb63c7d2420d18e4375348663874247838 (diff)
downloadPROJ-7a9b6566ac02d8c408f4f3758bfa5fcc3e90b552.tar.gz
PROJ-7a9b6566ac02d8c408f4f3758bfa5fcc3e90b552.zip
Refactor post-install suite to test shared and static projlib (#2972)
Diffstat (limited to 'test/postinstall/c_app/c_app.c')
-rw-r--r--test/postinstall/c_app/c_app.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/postinstall/c_app/c_app.c b/test/postinstall/c_app/c_app.c
new file mode 100644
index 00000000..58d7e135
--- /dev/null
+++ b/test/postinstall/c_app/c_app.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <proj.h>
+
+int test_transform() {
+ PJ *P;
+ PJ_COORD a, b;
+ P = proj_create_crs_to_crs(
+ PJ_DEFAULT_CTX,
+ "EPSG:4326",
+ "+proj=utm +zone=32 +datum=WGS84", /* or EPSG:32632 */
+ NULL);
+ if (0 == P) {
+ fprintf(stderr, "Oops\n");
+ return 1;
+ }
+ /* Copenhagen: 55d N, 12d E */
+ a = proj_coord(55, 12, 0, 0);
+ b = proj_trans(P, PJ_FWD, a);
+ printf("easting: %.2f, northing: %.2f, ", b.enu.e, b.enu.n);
+ b = proj_trans(P, PJ_INV, b);
+ printf("latitude: %.2f, longitude: %.2f\n", b.lp.lam, b.lp.phi);
+ proj_destroy(P);
+ return 0;
+}
+
+int main(int argc, char *argv[]) {
+ PJ_INFO info;
+ info = proj_info();
+ if(argc == 2 && argv[1][0] == '-') {
+ switch(argv[1][1]) {
+ case 't':
+ return(test_transform());
+ case 's':
+ printf("%s\n", info.searchpath);
+ return(0);
+ case 'v':
+ printf("%d.%d.%d\n", info.major, info.minor, info.patch);
+ return(0);
+ }
+ }
+ fprintf(stderr, "Use option -t, -s or -v\n");
+ return(1);
+}