aboutsummaryrefslogtreecommitdiff
path: root/src/apps
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-03-13 11:24:41 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-03-13 11:45:47 +0100
commit2247841879faebe007ccade45d04027361d5d26c (patch)
tree740a420dc2d28ce5ec567bf7983c1ce9ce99145a /src/apps
parent35425763e70b70f7efc9a5c9616695369609553f (diff)
downloadPROJ-2247841879faebe007ccade45d04027361d5d26c.tar.gz
PROJ-2247841879faebe007ccade45d04027361d5d26c.zip
Tag proj_list_units() as deprecated
Diffstat (limited to 'src/apps')
-rw-r--r--src/apps/cs2cs.cpp17
-rw-r--r--src/apps/geod.cpp17
-rw-r--r--src/apps/geod_set.cpp24
-rw-r--r--src/apps/proj.cpp17
4 files changed, 51 insertions, 24 deletions
diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp
index 6c85d4aa..affd2bec 100644
--- a/src/apps/cs2cs.cpp
+++ b/src/apps/cs2cs.cpp
@@ -425,11 +425,18 @@ int main(int argc, char **argv) {
(void)printf("%9s %-16s %-16s %s\n", le->id,
le->major, le->ell, le->name);
} else if (arg[1] == 'u') { /* list units */
- const struct PJ_UNITS *lu;
-
- for (lu = proj_list_units(); lu->id; ++lu)
- (void)printf("%12s %-20s %s\n", lu->id,
- lu->to_meter, lu->name);
+ auto units = proj_get_units_from_database(nullptr, nullptr, "linear", false, nullptr);
+ for( int i = 0; units && units[i]; i++ )
+ {
+ if( units[i]->proj_short_name )
+ {
+ (void)printf("%12s %-20.15g %s\n",
+ units[i]->proj_short_name,
+ units[i]->conv_factor,
+ units[i]->name);
+ }
+ }
+ proj_unit_list_destroy(units);
} else if (arg[1] == 'm') { /* list prime meridians */
const struct PJ_PRIME_MERIDIANS *lpm;
diff --git a/src/apps/geod.cpp b/src/apps/geod.cpp
index b46188d3..919430ca 100644
--- a/src/apps/geod.cpp
+++ b/src/apps/geod.cpp
@@ -185,11 +185,18 @@ noargument: emess(1,"missing argument for -%c",*arg);
(void)printf("%9s %-16s %-16s %s\n",
le->id, le->major, le->ell, le->name);
} else if (arg[1] == 'u') { /* list of units */
- const struct PJ_UNITS *lu;
-
- for (lu = proj_list_units();lu->id ; ++lu)
- (void)printf("%12s %-20s %s\n",
- lu->id, lu->to_meter, lu->name);
+ auto units = proj_get_units_from_database(nullptr, nullptr, "linear", false, nullptr);
+ for( int i = 0; units && units[i]; i++ )
+ {
+ if( units[i]->proj_short_name )
+ {
+ (void)printf("%12s %-20.15g %s\n",
+ units[i]->proj_short_name,
+ units[i]->conv_factor,
+ units[i]->name);
+ }
+ }
+ proj_unit_list_destroy(units);
} else
emess(1,"invalid list option: l%c",arg[1]);
exit( 0 );
diff --git a/src/apps/geod_set.cpp b/src/apps/geod_set.cpp
index ed7edeb9..603f0d95 100644
--- a/src/apps/geod_set.cpp
+++ b/src/apps/geod_set.cpp
@@ -14,7 +14,6 @@ geod_set(int argc, char **argv) {
paralist *start = nullptr, *curr;
double es;
char *name;
- int i;
/* put arguments into internal linked list */
if (argc <= 0)
@@ -22,7 +21,7 @@ geod_set(int argc, char **argv) {
start = curr = pj_mkparam(argv[0]);
if (!curr)
emess(1, "memory allocation failed");
- for (i = 1; curr != nullptr && i < argc; ++i) {
+ for (int i = 1; curr != nullptr && i < argc; ++i) {
curr->next = pj_mkparam(argv[i]);
if (!curr->next)
emess(1, "memory allocation failed");
@@ -32,13 +31,20 @@ geod_set(int argc, char **argv) {
if (pj_ell_set(pj_get_default_ctx(),start, &geod_a, &es)) emess(1,"ellipse setup failure");
/* set units */
if ((name = pj_param(nullptr,start, "sunits").s) != nullptr) {
- const char *s;
- const struct PJ_UNITS *unit_list = proj_list_units();
- for (i = 0; (s = unit_list[i].id) && strcmp(name, s) ; ++i) ;
- if (!s)
- emess(1,"%s unknown unit conversion id", name);
- to_meter = unit_list[i].factor;
- fr_meter = 1 / to_meter;
+ bool unit_found = false;
+ auto units = proj_get_units_from_database(nullptr, nullptr, "linear", false, nullptr);
+ for( int i = 0; units && units[i]; i++ )
+ {
+ if( units[i]->proj_short_name &&
+ strcmp(units[i]->proj_short_name, name) == 0 ) {
+ unit_found = true;
+ to_meter = units[i]->conv_factor;
+ fr_meter = 1 / to_meter;
+ }
+ }
+ proj_unit_list_destroy(units);
+ if( !unit_found )
+ emess(1,"%s unknown unit conversion id", name);
} else
to_meter = fr_meter = 1;
geod_f = es/(1 + sqrt(1 - es));
diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp
index 852cea04..0bf98b3a 100644
--- a/src/apps/proj.cpp
+++ b/src/apps/proj.cpp
@@ -380,11 +380,18 @@ int main(int argc, char **argv) {
(void)printf("%9s %-16s %-16s %s\n",
le->id, le->major, le->ell, le->name);
} else if (arg[1] == 'u') { /* list units */
- const struct PJ_UNITS *lu;
-
- for (lu = proj_list_units(); lu->id ; ++lu)
- (void)printf("%12s %-20s %s\n",
- lu->id, lu->to_meter, lu->name);
+ auto units = proj_get_units_from_database(nullptr, nullptr, "linear", false, nullptr);
+ for( int i = 0; units && units[i]; i++ )
+ {
+ if( units[i]->proj_short_name )
+ {
+ (void)printf("%12s %-20.15g %s\n",
+ units[i]->proj_short_name,
+ units[i]->conv_factor,
+ units[i]->name);
+ }
+ }
+ proj_unit_list_destroy(units);
} else
emess(1,"invalid list option: l%c",arg[1]);
exit(0);