TsMoveGeometry.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/unittest/edit/movegeometry/TsMoveGeometry.cpp
22 
23  \brief A test suit for the Move Geometries.
24 */
25 
26 // TerraLib
27 #include "../Config.h"
28 #include <terralib/edit/Utils.h>
29 #include <terralib/geometry.h>
30 
31 // STL
32 #include <memory>
33 
34 // Boost
35 #define BOOST_TEST_NO_MAIN
36 #include <boost/test/unit_test.hpp>
37 
38 BOOST_AUTO_TEST_SUITE(movegeometry_tests);
39 
40 BOOST_AUTO_TEST_CASE(movePolygon_test)
41 {
43  line->setPoint(0, 1.0, 1.5);
44  line->setPoint(1, 1.0, 3.3);
45  line->setPoint(2, 3.0, 3.3);
46  line->setPoint(3, 3.0, 1.5);
47  line->setPoint(4, 1.0, 1.5); // closing
48 
50  poly->setRingN(0, line);
51 
52  te::gm::Point* pOrigin = poly->getCentroid();
53 
54  //move geometry
55  te::edit::MoveGeometry(poly, 1, 1);
56 
57  double distance = pOrigin->distance(poly->getCentroid());
58 
59  //moved?
60  BOOST_CHECK(distance > 0.);
61 }
62 
63 BOOST_AUTO_TEST_SUITE_END()
Utility functions for TerraLib Edit module.
virtual double distance(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns the shortest distance between any two points in the two geometry objects.
BOOST_AUTO_TEST_CASE(movePolygon_test)
BOOST_AUTO_TEST_SUITE(movegeometry_tests)
unsigned int line
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
A point with x and y coordinate values.
Definition: Point.h:50
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
TEEDITEXPORT void MoveGeometry(te::gm::Geometry *geom, const double &deltax, const double &deltay)
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
Point * getCentroid() const
It returns the mathematical centroid for this surface as a point.
This file contains include headers for the Vector Geometry model of TerraLib.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.