GeometryConstructors.cpp
Go to the documentation of this file.
1 // Examples
2 #include "GeometryExamples.h"
3 
4 #include <terralib_buildconfig.h>
5 
6 te::gm::Point* createPoint(const double& x, const double& y)
7 {
8  te::gm::Point* p = new te::gm::Point(x, y);
9  return p;
10 }
11 
12 te::gm::Point* createPointZ(const double& x, const double& y, const double& z)
13 {
15  p->setX(x);
16  p->setY(y);
17  p->setZ(z);
18  return p;
19 }
20 
21 te::gm::LineString* createLineString(const double& xi, const double& yi,
22  const double& xf, const double& yf)
23 {
25  l->setPoint(0, xi, yi);
26  l->setPoint(1, xf, yf);
27  return l;
28 }
29 
30 te::gm::LinearRing* createSquare(const double& xc, const double& yc, const double& size)
31 {
33  double halfSize = size * 0.5;
34  s->setPoint(0, xc - halfSize, yc - halfSize); // lower left
35  s->setPoint(1, xc - halfSize, yc + halfSize); // upper left
36  s->setPoint(2, xc + halfSize, yc + halfSize); // upper rigth
37  s->setPoint(3, xc + halfSize, yc - halfSize); // lower rigth
38  s->setPoint(4, xc - halfSize, yc - halfSize); // closing
39  return s;
40 }
41 
43 {
45  p->push_back(createSquare(5, 5, 10));
46  return p;
47 }
48 
50 {
52  p->push_back(createSquare(5, 5, 10)); // external square
53  p->push_back(createSquare(5, 5, 5)); // internal square (the hole!)
54  return p;
55 }
56 
58 {
60  gColl->add(createPoint(0.0, 0.0));
61  gColl->add(createLineString(0.0, 0.0, 10.0, 10.0));
62  gColl->add(createLineString(0.0, 10.0, 10.0, 0.0));
63  gColl->add(createPolygon());
64  gColl->add(createPolygonWithHole());
65  return gColl;
66 }
void push_back(Curve *ring)
It adds the curve to the curve polygon.
te::gm::Polygon * createPolygon()
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
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.
te::gm::Point * createPointZ(const double &x, const double &y, const double &z)
te::gm::Polygon * p
te::gm::Point * createPoint(const double &x, const double &y)
te::gm::Polygon * createPolygonWithHole()
te::gm::GeometryCollection * createGeometryCollection()
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:145
void add(Geometry *g)
It adds the geometry into the collection.
A set of geometry examples.
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:159
It is a collection of other geometric objects.
te::gm::LinearRing * createSquare(const double &xc, const double &yc, const double &size)
void setZ(const double &z)
It sets the Point z-coordinate value.
Definition: Point.h:173
te::gm::LineString * createLineString(const double &xi, const double &yi, const double &xf, const double &yf)