
Geometry : 
Subject: [geometry] Strange values using boost geometry gis extension with tmerc projection
From: Andrew Hundt (athundt_at_[hidden])
Date: 20150426 17:08:44
I'm getting what I believe to be strange behavior with lat/lon to x/y for
tmerc. If I understand correctly, I can pass a lat/lon in degrees in and
get an x/y in meters out. However, when I pass in 0,0 m and then 1,1 m into
inv() it appears to jump by 1.57 degrees latitude, which I believe is
thousands of meters rather than just 1. Am I using it incorrectly or is
this an issue?
Details are below. Thanks!
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include "boost/geometry/extensions/algorithms/parse.hpp"
#include "boost/geometry/extensions/gis/latlong/latlong.hpp"
#include "boost/geometry/extensions/gis/projections/parameters.hpp"
#include "boost/geometry/extensions/gis/projections/proj/tmerc.hpp"
// Construct a transverse mercator projection, using specified point types
// (This delivers a projection without virtual methods. Note that in p02
example
// the projection is created using a factory, which delivers a projection
with virtual methods)
typedef boost::geometry::model::ll::point<boost::geometry::degree>
point_ll_deg;
typedef boost::geometry::model::d2::point_xy<double> point_xy;
typedef boost::geometry::projections::tmerc_spheroid<point_ll_deg,
point_xy> proj_spheroid;
boost::geometry::projections::parameters par =
boost::geometry::projections::init("+ellps=WGS84 +units=m");
proj_spheroid prj(par);
double x = 1;
double y = 1;
//double x = 0;
//double y = 0;
double lat;
double lon;
prj.inv(x,y,lat,lon);
result: lat: 1.5708 lon: 4.80877e65
If I pass x = 0, y = 0, then I get lat: 0 lon: 0 as the result.
Cheers!
Andrew Hundt
Geometry list run by mateusz at loskot.net