All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EWKBSize.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/sqlite/EWKBSize.cpp
22 
23  \brief A class that helps to determine the size of a SpatiaLite geometry.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "../geometry/GeometryCollection.h"
29 #include "../geometry/LinearRing.h"
30 #include "../geometry/LineString.h"
31 #include "../geometry/MultiLineString.h"
32 #include "../geometry/MultiPoint.h"
33 #include "../geometry/MultiPolygon.h"
34 #include "../geometry/PointM.h"
35 #include "../geometry/PointZ.h"
36 #include "../geometry/PointZM.h"
37 #include "../geometry/Polygon.h"
38 #include "EWKBSize.h"
39 
41  : m_size(0)
42 {
43 }
44 
46 {
47 }
48 
50 {
51  EWKBSize ws;
52 
53  ws.m_size = 44;
54 
55  geom->accept(ws);
56 
57  return ws.m_size;
58 }
59 
61 {
62  std::size_t ngeoms = visited.getNumGeometries();
63 
64  m_size += 4 + (5 * ngeoms);
65 
66  for(unsigned int i = 0; i < ngeoms; ++i)
67  visited.getGeometryN(i)->accept(*this);
68 }
69 
71 {
72  int dim = 2;
73 
74  if(visited.getZ())
75  ++dim;
76 
77  if(visited.getM())
78  ++dim;
79 
80  m_size += visited.getNPoints() * 8 * dim + 4;
81 }
82 
84 {
85  int dim = 2;
86 
87  if(visited.getZ())
88  ++dim;
89 
90  if(visited.getM())
91  ++dim;
92 
93  m_size += visited.getNPoints() * 8 * dim + 4;
94 }
95 
97 {
98  visit((const te::gm::GeometryCollection&)visited);
99 }
100 
102 {
103  visit((const te::gm::GeometryCollection&)visited);
104 }
105 
107 {
108  visit((const te::gm::GeometryCollection&)visited);
109 }
110 
112 {
113  m_size += 16;
114 }
115 
117 {
118  m_size += 24;
119 }
120 
122 {
123  m_size += 24;
124 }
125 
127 {
128  m_size += 32;
129 }
130 
132 {
133  m_size += 4;
134 
135  std::size_t nrings = visited.getNumRings();
136 
137  for(std::size_t i = 0; i < nrings; ++i)
138  visited.getRingN(i)->accept(*this);
139 }
140 
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
Definition: CurvePolygon.h:153
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
std::size_t m_size
Definition: EWKBSize.h:76
A point with a z-coordinate value and an associated measurement.
Definition: PointZM.h:51
A point with an associated measure.
Definition: PointM.h:51
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
A point with z-coordinate value.
Definition: PointZ.h:51
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
A class that helps to determine the size of a SpatiaLite geometry.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
void visit(const te::gm::Curve &)
Definition: EWKBSize.h:49
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
Definition: LineString.cpp:397
const double & getM(std::size_t i) const
It returns the n-th m measure value.
Definition: LineString.cpp:403
It is a collection of other geometric objects.
static std::size_t getEWKBSize(const te::gm::Geometry *g)
Definition: EWKBSize.cpp:49
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
Definition: CurvePolygon.h:193