Strange values using boost geometry gis extension with tmerc projection

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange values using boost geometry gis extension with tmerc projection

Andrew Hundt

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.80877e-65

If I pass x = 0, y = 0, then I get lat: 0 lon: 0 as the result.


Cheers!
Andrew Hundt

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|

Re: Strange values using boost geometry gis extension with tmerc projection

Barend
Hi Andrew,


Andrew Hundt schreef op 26-4-2015 om 23:08:
>
> 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!

I'm by chance currently busy with the projections so will look tomorrow.

Regards, Barend

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|

Re: Strange values using boost geometry gis extension with tmerc projection

Barend
In reply to this post by Andrew Hundt
Hi Andrew,


Andrew Hundt schreef op 26-4-2015 om 23:08:
>
> typedef boost::geometry::projections::tmerc_spheroid<point_ll_deg,
> point_xy> proj_spheroid;

Better use tmerc_ellipsoid.

Spheroid exist but I don't get good results with that. I don't know the
details of all projections, so can't yet explain, but ellipsoid is the
tested one and works OK.


>
> prj.inv(x,y,lat,lon);

Please never use inv directly. It is not meant to be called. Just looked
it up - none of the examples or tests are using inv...

Please call prj.inverse(xy, ll) where xy and ll are point types (as you
specified before)

inv (and also fwd) is meant to be called internally. I will check if I
can make it private.

If you use inverse and ellipsoid, it should work fine.

Regards, Barend

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry