Skip to content

Commit

Permalink
consider northing-easing in verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jjimenezshaw committed Jul 20, 2023
1 parent 5301fdc commit 807ae5a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/apps/proj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <stdlib.h>
#include <string.h>

#include <proj/crs.hpp>

#include <vector>

#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__WIN32__)
Expand All @@ -25,6 +27,7 @@

static PJ *Proj = nullptr;
static PJ *ProjForFactors = nullptr;
static bool swapAxisCrs = false;
static union {
PJ_XY (*fwd)(PJ_LP, PJ *);
PJ_LP (*inv)(PJ_XY, PJ *);
Expand Down Expand Up @@ -300,10 +303,12 @@ static void vprocess(FILE *fid) {
(void)fputs(proj_rtodms2(pline, sizeof(pline), dat_ll.phi, 'N', 'S'),
stdout);
(void)printf(" [ %.11g ]\n", dat_ll.phi * RAD_TO_DEG);
(void)fputs("Easting (x): ", stdout);
(void)fputs(swapAxisCrs ? "Northing (y): " : "Easting (x): ",
stdout);
(void)printf(oform, dat_xy.x);
putchar('\n');
(void)fputs("Northing (y): ", stdout);
(void)fputs(swapAxisCrs ? "Easting (x): " : "Northing (y): ",
stdout);
(void)printf(oform, dat_xy.y);
putchar('\n');
(void)printf("Meridian scale (h) : %.8f ( %.4g %% error )\n",
Expand Down Expand Up @@ -534,6 +539,16 @@ int main(int argc, char **argv) {
if (PJ *P = proj_create(nullptr, ocrs.c_str())) {
const auto type = proj_get_type(P);
if (type == PJ_TYPE_PROJECTED_CRS) {
try {
using namespace osgeo::proj;
auto crs = dynamic_cast<const crs::ProjectedCRS *>(
P->iso_obj.get());
auto dir =
crs->coordinateSystem()->axisList()[0]->direction();
swapAxisCrs = dir == cs::AxisDirection::NORTH ||
dir == cs::AxisDirection::SOUTH;
} catch (...) {
}
auto ctx = P->ctx;
auto geodetic_crs = proj_get_source_crs(ctx, P);
assert(geodetic_crs);
Expand Down

0 comments on commit 807ae5a

Please sign in to comment.