[test][projections] Update tests WRT recent changes in static_proj4 interface and parameters.

This commit is contained in:
Adam Wulkiewicz 2017-10-25 00:53:10 +02:00
parent 375e39a0db
commit 51e67a38bb
4 changed files with 57 additions and 45 deletions

View File

@ -38,6 +38,7 @@
namespace srs = bg::srs;
namespace par = bg::srs::par4;
template <typename Prj, typename Model, typename P1, typename P2>
void test_one(double lon, double lat,
@ -45,7 +46,8 @@ void test_one(double lon, double lat,
typename bg::coordinate_type<P2>::type y,
std::string const& parameters)
{
srs::projection<srs::static_proj4<Prj, Model> > prj = srs::static_proj4<Prj, Model>(parameters);
srs::projection<srs::static_proj4<par::proj<Prj>, par::ellps<Model> > >
prj = srs::static_proj4<par::proj<Prj>, par::ellps<Model> >(parameters);
P1 ll;
bg::set<0>(ll, lon);
@ -65,7 +67,7 @@ void test_all()
typedef bg::model::point<coord_type, 2, bg::cs::geographic<bg::degree> > point_type;
// aea
test_one<srs::proj::aea, srs::ellps::WGS84, point_type, P>
test_one<par::aea, par::WGS84, point_type, P>
(4.897000, 52.371000, 334609.583974, 5218502.503686,
"+proj=aea +ellps=WGS84 +units=m +lat_1=55 +lat_2=65");
}

View File

@ -14,6 +14,7 @@
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/srs/epsg.hpp>
#include <boost/geometry/srs/esri.hpp>
#include <boost/geometry/srs/projection.hpp>
#include "check_geometry.hpp"
@ -23,6 +24,7 @@ int test_main(int, char*[])
using namespace boost::geometry;
using namespace boost::geometry::model;
using namespace boost::geometry::srs;
using namespace boost::geometry::srs::par4;
typedef point<double, 2, cs::geographic<degree> > point_ll;
typedef point<double, 2, cs::cartesian> point_xy;
@ -61,8 +63,9 @@ int test_main(int, char*[])
point_ll pt_ll2(0, 0);
point_xy pt_xy(0, 0);
// default WGS84 spheroid and additional parameters
projection<static_proj4<proj::tmerc> > prj;
// default WGS84 spheroid
projection<static_proj4<proj<tmerc> > > prj;
//projection<static_proj4<proj<tmerc>, ellps<WGS84> > > prj;
prj.forward(pt_ll, pt_xy);
test::check_geometry(pt_xy, "POINT(111308.33561309829 110591.34223734379)", 0.001);
@ -87,25 +90,28 @@ int test_main(int, char*[])
}
{
// default spheroid and additional parameters
projection<static_proj4<proj::tmerc, ellps::WGS84> >
// static_proj4 constructors
projection<static_proj4<proj<tmerc>, ellps<WGS84> > >
prj2;
projection<static_proj4<proj<tmerc>, ellps<WGS84> > >
prj3 = static_proj4<proj<tmerc>, ellps<WGS84> >();
projection<static_proj4<proj<tmerc>, ellps<WGS84> > >
prj4 = static_proj4<proj<tmerc>, ellps<WGS84> >("");
// default spheroid and additional parameters
projection<static_proj4<proj::tmerc, ellps::WGS84> >
prj3 = static_proj4<proj::tmerc, ellps::WGS84>();
projection<static_proj4<proj<tmerc>, datum<WGS84> > >
prj5;
projection<static_proj4<proj<tmerc>, ellps<WGS84>, datum<WGS84> > >
prj6;
}
// passed spheroid and default additional parameters
projection<static_proj4<proj::tmerc, ellps::WGS84> >
prj4 = static_proj4<proj::tmerc, ellps::WGS84>(ellps::WGS84());
// default spheroid and passed additional parameters
projection<static_proj4<proj::tmerc, ellps::WGS84> >
prj5 = static_proj4<proj::tmerc, ellps::WGS84>("");
// passed spheroid and additional parameters
projection<static_proj4<proj::tmerc, ellps::WGS84> >
prj6 = static_proj4<proj::tmerc, ellps::WGS84>(ellps::WGS84(), "");
{
typedef spheroid<double> sph;
typedef ellps<sph> ell;
typedef proj<tmerc> prj;
projection<static_proj4<ell, prj> >
prj1 = static_proj4<ell, prj>(ell(sph(1000, 999)));
projection<static_proj4<ell, prj> >
prj2 = static_proj4<ell, prj>(ell(sph(1000, 999)), "");
}
// compile-time errors
@ -116,7 +122,8 @@ int test_main(int, char*[])
//projection<static_proj4<int> > prj1;
//projection<int> prj2;
projection<static_proj4<proj::bacon> > prj3;
projection<static_proj4<proj<bacon> > > prj3;
//projection<static_proj4<proj<bacon>, ellps<WGS84> > > prj3;
//prj3.inverse(pt_xy, pt_ll);
}

View File

@ -30,6 +30,7 @@
namespace srs = bg::srs;
namespace par = bg::srs::par4;
template <typename Proj, typename Model, typename GeoPoint>
void test_forward(std::string const& id, GeoPoint const& geo_point1, GeoPoint const& geo_point2,
@ -37,11 +38,12 @@ void test_forward(std::string const& id, GeoPoint const& geo_point1, GeoPoint co
{
typedef typename bg::coordinate_type<GeoPoint>::type coordinate_type;
typedef bg::model::d2::point_xy<coordinate_type> cartesian_point_type;
typedef srs::projection<srs::static_proj4<Proj, Model> > projection_type;
typedef srs::static_proj4<par::proj<Proj>, par::ellps<Model> > static_proj4;
typedef srs::projection<static_proj4> projection_type;
try
{
projection_type prj = srs::static_proj4<Proj, Model>(parameters);
projection_type prj = static_proj4(parameters);
cartesian_point_type xy1, xy2;
prj.forward(geo_point1, xy1);
@ -92,26 +94,26 @@ void test_all()
geo_point_type denver = bg::make<geo_point_type>(-104.88, 39.76);
// IGH (internally using moll/sinu)
test_forward<srs::proj::igh, srs::ellps::sphere>("igh-au", amsterdam, utrecht, "+ellps=sphere +units=m", 5);
test_forward<srs::proj::igh, srs::ellps::sphere>("igh-ad", aspen, denver, "+ellps=sphere +units=m", 3);
test_forward<srs::proj::igh, srs::ellps::sphere>("igh-aw", auckland, wellington, "+ellps=sphere +units=m", 152);
test_forward<srs::proj::igh, srs::ellps::sphere>("igh-aj", anchorage, juneau, "+ellps=sphere +units=m", 28);
test_forward<par::igh, par::sphere>("igh-au", amsterdam, utrecht, "+ellps=sphere +units=m", 5);
test_forward<par::igh, par::sphere>("igh-ad", aspen, denver, "+ellps=sphere +units=m", 3);
test_forward<par::igh, par::sphere>("igh-aw", auckland, wellington, "+ellps=sphere +units=m", 152);
test_forward<par::igh, par::sphere>("igh-aj", anchorage, juneau, "+ellps=sphere +units=m", 28);
// Using moll
//test_forward<srs::proj::ob_tran_oblique, srs::ellps::WGS84>("obto-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 4);
//test_forward<srs::proj::ob_tran_transverse, srs::ellps::WGS84>("obtt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 5);
test_forward<srs::proj::ob_tran, srs::ellps::WGS84>("obt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 4);
//test_forward<srs::proj::ob_tran_oblique, srs::ellps::WGS84>("obto-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 19);
//test_forward<srs::proj::ob_tran_transverse, srs::ellps::WGS84>("obtt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 19);
test_forward<srs::proj::ob_tran, srs::ellps::WGS84>("obt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 19);
//test_forward<par::ob_tran_oblique, par::WGS84>("obto-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 4);
//test_forward<par::ob_tran_transverse, par::WGS84>("obtt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 5);
test_forward<par::ob_tran, par::WGS84>("obt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 4);
//test_forward<par::ob_tran_oblique, par::WGS84>("obto-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 19);
//test_forward<par::ob_tran_transverse, par::WGS84>("obtt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 19);
test_forward<par::ob_tran, par::WGS84>("obt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=moll +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 19);
// Using sinu
//test_forward<srs::proj::ob_tran_oblique, srs::ellps::WGS84>("obto-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 5);
//test_forward<srs::proj::ob_tran_transverse, srs::ellps::WGS84>("obtt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 4);
test_forward<srs::proj::ob_tran, srs::ellps::WGS84>("obt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 5);
//test_forward<srs::proj::ob_tran_oblique, srs::ellps::WGS84>("obto-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 14);
//test_forward<srs::proj::ob_tran_transverse, srs::ellps::WGS84>("obtt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 6);
test_forward<srs::proj::ob_tran, srs::ellps::WGS84>("obt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 14);
//test_forward<par::ob_tran_oblique, par::WGS84>("obto-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 5);
//test_forward<par::ob_tran_transverse, par::WGS84>("obtt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 4);
test_forward<par::ob_tran, par::WGS84>("obt-au", amsterdam, utrecht, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 5);
//test_forward<par::ob_tran_oblique, par::WGS84>("obto-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 14);
//test_forward<par::ob_tran_transverse, par::WGS84>("obtt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 6);
test_forward<par::ob_tran, par::WGS84>("obt-ad", aspen, denver, "+ellps=WGS84 +units=m +o_proj=sinu +o_lat_p=10 +o_lon_p=90 +o_lon_o=11.50", 14);
}

View File

@ -27,6 +27,7 @@ int test_main(int, char*[])
using namespace boost::geometry;
using namespace boost::geometry::model;
using namespace boost::geometry::srs;
using namespace boost::geometry::srs::par4;
using namespace bg::strategy::transform;
typedef point<double, 2, cs::geographic<degree> > point_ll;
@ -70,26 +71,26 @@ int test_main(int, char*[])
{
srs_forward_transformer
<
projection<static_proj4<proj::tmerc, ellps::WGS84> >
projection<static_proj4<proj<tmerc>, ellps<WGS84> > >
> strategy_pf;
srs_forward_transformer
<
projection<static_proj4<proj::tmerc, ellps::WGS84> >
projection<static_proj4<proj<tmerc>, ellps<WGS84> > >
> strategy_pi;
srs_forward_transformer
<
transformation
<
static_proj4<proj::tmerc, ellps::WGS84>,
static_proj4<proj::tmerc, ellps::clrk66>
static_proj4<proj<tmerc>, ellps<WGS84> >,
static_proj4<proj<tmerc>, ellps<clrk66> >
>
> strategy_tf;
srs_forward_transformer
<
transformation
<
static_proj4<proj::tmerc, ellps::WGS84>,
static_proj4<proj::tmerc, ellps::clrk66>
static_proj4<proj<tmerc>, ellps<WGS84> >,
static_proj4<proj<tmerc>, ellps<clrk66> >
>
> strategy_ti;
}