PageRenderTime 55ms CodeModel.GetById 48ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/multi/algorithms/multi_transform.cpp

http://hadesmem.googlecode.com/
C++ | 97 lines | 65 code | 19 blank | 13 comment | 0 complexity | 3469674d9b5cc8cca94404f924cd9212 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2// Unit Test
 3
 4// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
 5// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
 6// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
 7
 8// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
 9// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10
11// Use, modification and distribution is subject to the Boost Software License,
12// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13// http://www.boost.org/LICENSE_1_0.txt)
14
15#include <iostream>
16#include <sstream>
17
18#include <geometry_test_common.hpp>
19
20#include <boost/geometry/algorithms/transform.hpp>
21#include <boost/geometry/strategies/strategies.hpp>
22#include <boost/geometry/geometries/geometries.hpp>
23#include <boost/geometry/geometries/point_xy.hpp>
24
25#include <boost/geometry/multi/algorithms/transform.hpp>
26
27#include <boost/geometry/multi/geometries/multi_point.hpp>
28#include <boost/geometry/multi/geometries/multi_linestring.hpp>
29#include <boost/geometry/multi/geometries/multi_polygon.hpp>
30
31#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
32#include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>
33
34
35// This test is a little different from transform.cpp test.
36// This test explicitly tests all geometries, including multi*
37// while the transform.cpp tests various strategies.
38
39template <typename Geometry>
40void test_transform(std::string const& wkt, std::string const& expected)
41{
42    typedef typename bg::point_type<Geometry>::type point_type;
43
44    Geometry geometry_in, geometry_out;
45    bg::read_wkt(wkt, geometry_in);
46    bg::transform(geometry_in, geometry_out,
47        bg::strategy::transform::scale_transformer<point_type>(2, 2));
48    std::ostringstream detected;
49    detected << bg::wkt(geometry_out);
50    BOOST_CHECK_EQUAL(detected.str(), expected);
51}
52
53
54template <typename T>
55void test_all()
56{
57    typedef bg::model::d2::point_xy<T> P;
58
59    test_transform<P>(
60            "POINT(1 1)",
61            "POINT(2 2)");
62    test_transform<bg::model::linestring<P> >(
63            "LINESTRING(1 1,2 2)",
64            "LINESTRING(2 2,4 4)");
65    test_transform<bg::model::segment<P> >(
66            "LINESTRING(1 1,2 2)",
67            "LINESTRING(2 2,4 4)");
68    test_transform<bg::model::ring<P> >(
69            "POLYGON((0 0,0 1,1 0,0 0))",
70            "POLYGON((0 0,0 2,2 0,0 0))");
71    test_transform<bg::model::polygon<P> >(
72            "POLYGON((0 0,0 1,1 0,0 0))",
73            "POLYGON((0 0,0 2,2 0,0 0))");
74    test_transform<bg::model::box<P> >(
75            "POLYGON((0 0,0 1,1 1,1 0,0 0))",
76            "POLYGON((0 0,0 2,2 2,2 0,0 0))");
77    test_transform<bg::model::multi_point<P> >(
78            "MULTIPOINT((1 1),(2 2))",
79            "MULTIPOINT((2 2),(4 4))");
80    test_transform<bg::model::multi_linestring<bg::model::linestring<P> > >(
81            "MULTILINESTRING((1 1,2 2))",
82            "MULTILINESTRING((2 2,4 4))");
83    test_transform<bg::model::multi_polygon<bg::model::polygon<P> > >(
84            "MULTIPOLYGON(((0 0,0 1,1 0,0 0)))",
85            "MULTIPOLYGON(((0 0,0 2,2 0,0 0)))");
86}
87
88
89int test_main(int, char* [])
90{
91    test_all<double>();
92
93#ifdef HAVE_TTMATH
94    test_all<ttmath_big>();
95#endif
96    return 0;
97}