diff --git a/extensions/test/gis/projections/interface.cpp b/extensions/test/gis/projections/interface.cpp new file mode 100644 index 000000000..3cd84b600 --- /dev/null +++ b/extensions/test/gis/projections/interface.cpp @@ -0,0 +1,108 @@ +// Boost.Geometry +// Unit Test + +// Copyright (c) 2017, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#include + +#include +#include +#include + + +int test_main(int, char*[]) +{ + using namespace boost::geometry; + using namespace boost::geometry::model; + using namespace boost::geometry::projections; + + typedef point > point_ll; + typedef point point_xy; + + std::cout << std::setprecision(12); + + { + point_ll pt_ll(1, 1); + point_xy pt_xy(0, 0); + + projection prj(proj4("+proj=tmerc +ellps=WGS84 +units=m")); + + std::cout << wkt(pt_ll) << std::endl; + prj.forward(pt_ll, pt_xy); + std::cout << wkt(pt_xy) << std::endl; + prj.inverse(pt_xy, pt_ll); + std::cout << wkt(pt_ll) << std::endl; + } + + { + point_ll pt_ll(1, 1); + point_xy pt_xy(0, 0); + + projection prj(epsg(2000)); + + std::cout << wkt(pt_ll) << std::endl; + prj.forward(pt_ll, pt_xy); + std::cout << wkt(pt_xy) << std::endl; + prj.inverse(pt_xy, pt_ll); + std::cout << wkt(pt_ll) << std::endl; + } + + { + point_ll pt_ll(1, 1); + point_xy pt_xy(0, 0); + + // default WGS84 spheroid and additional parameters + projection > prj; + + std::cout << wkt(pt_ll) << std::endl; + prj.forward(pt_ll, pt_xy); + std::cout << wkt(pt_xy) << std::endl; + prj.inverse(pt_xy, pt_ll); + std::cout << wkt(pt_ll) << std::endl; + } + + { + point_ll pt_ll(1, 1); + point_xy pt_xy(0, 0); + + projection > prj; + + std::cout << wkt(pt_ll) << std::endl; + prj.forward(pt_ll, pt_xy); + std::cout << wkt(pt_xy) << std::endl; + prj.inverse(pt_xy, pt_ll); + std::cout << wkt(pt_ll) << std::endl; + } + + { + // default spheroid and additional parameters + projection > > + prj2; + + // default spheroid and additional parameters + projection > > + prj3((static_proj4 >())); + + // passed spheroid and default additional parameters + projection > > + prj4((static_proj4 >(srs::spheroid()))); + + // default spheroid and passed additional parameters + projection > > + prj5((static_proj4 >(""))); + + // passed spheroid and additional parameters + projection > > + prj6((static_proj4 >(srs::spheroid(), ""))); + } + + return 0; +}