Loading...
Searching...
No Matches
CommonFunctions.h
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/vp/CommonDataStructures.h
22
23 \brief Utility classes, structures and definitions for Vector Processing.
24 */
25
26#ifndef __TERRALIB_VP_INTERNAL_COMMONFUNCTIONS_H
27#define __TERRALIB_VP_INTERNAL_COMMONFUNCTIONS_H
28
29//Terralib include files
30#include "Config.h"
31
32#include "../geometry/CommonDataStructures.h"
33#include "../geometry/Enums.h"
34#include "../geometry/GeometryCollection.h"
35
36
37//STL include files
38#include <vector>
39
40namespace te
41{
42 namespace gm
43 {
44 struct Coord2D;
45 class Envelope;
46 class Geometry;
47 }
48
49 namespace vp
50 {
51 class Feature;
52 class FeatureSet;
53 class GeometryInfo;
54 class SegmentInfo;
55
56
57
58 /*!
59 * \brief Gets the segment information related to all segments from the given geometry. An Optional filter can be used to filter the segments that will be returned
60 *
61 * \param geometry The geometry to be analysed
62 * \param filter The optional filter
63 * \param vecSegmentInfo [Return] The segments from the given geometry. The return is a parameter to make easier to create a list containing segments from several geometries
64 */
65 TEVPEXPORT void GetAllSegments(const te::gm::Geometry* geometry, const te::gm::Envelope& filter, std::vector<SegmentInfo>& vecSegmentInfo);
66
67 /*!
68 \brief Algorithm to fast detection of spatial relations between geometries. Very useful to fase dectect if two geomtries dont intercept themselves
69 Sometimes can generate false positives for overlaps, but never generates false positives for disjoint and touches
70
71 \param geometryA The input geometry A
72 \param geometryB The input geometry B
73
74 \return The detected spatial relation
75 */
77
78 /*!
79 \brief Algorithm to fast detection of spatial relations between geometries. Very useful to fase dectect if two geomtries dont intercept themselves
80 Sometimes can generate false positives for overlaps, but never generates false positives for disjoint and touches
81
82 \param geometryA The input geometry A
83 \param geometryB The input geometry B
84
85 \return The detected spatial relation
86 */
88
89 //!< Discards all the features from the set that have null or empty geometries
91
92 //!< Splits all feature that have geometry collections in to features that have single type geometries. All the attributes are copied
93 TEVPEXPORT void Multi2Single(const te::vp::Feature* feature, te::vp::FeatureSet& singleFeatureSet);
94
95 //!< Splits all the features that have geometry collections in to features that have single type geometries. All the attributes are copied
96 TEVPEXPORT void Multi2Single(const te::vp::FeatureSet& featureSet, te::vp::FeatureSet& singleFeatureSet);
97
98 /*!
99 \brief Adjust the given geometry to the given geometry type.
100 \param inGeomPtr Input geometry.
101 \param targetGeomType Target geometry type.
102 \return A vector of converted geometries or, if the conversion is not possible, an empty vector is returned.
103 \note The caller must take the ownership of the returned objects.
104 */
106
107 /*!
108 \brief Adjust the given geometries to the given geometry type.
109 \param vecGeometries Input geometries vector.
110 \param targetGeomType Target geometry type.
111 \return A vector of converted geometries or, if the conversion is not possible, an empty vector is returned.
112 \note The caller must take the ownership of the returned objects.
113 */
114 template< typename GeometryTypeT >
116 const std::vector< GeometryTypeT* >& vecGeometries, te::gm::GeomType geomType)
117 {
119 for (std::size_t i = 0; i < vecGeometries.size(); ++i)
120 {
122 vecGeometries.at(i), geomType);
123 result.insert(result.end(), currentResult.begin(), currentResult.end());
124 }
125
126 return result;
127 }
128
129 }
130}
131
132
133
134#endif //__TERRALIB_VP_INTERNAL_COMMONFUNCTIONS_H
An Envelope defines a 2D rectangular region.
Definition Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition Geometry.h:78
An alias for a set of Features.
Definition Feature.h:60
A feature is a composition of a geometry and its attributes.
Definition Feature.h:70
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition Enums.h:42
SpatialRelation
Spatial relations between geometric objects.
Definition Enums.h:128
std::vector< te::gm::Geometry * > GeometryVector
TEVPEXPORT te::gm::GeometryVector AdjustToGeomType(const te::gm::Geometry *inGeomPtr, te::gm::GeomType targetGeomType)
Adjust the given geometry to the given geometry type.
TEVPEXPORT void GetAllSegments(const te::gm::Geometry *geometry, const te::gm::Envelope &filter, std::vector< SegmentInfo > &vecSegmentInfo)
Gets the segment information related to all segments from the given geometry. An Optional filter can ...
TEVPEXPORT te::gm::SpatialRelation FastRelationCalculator(const te::vp::GeometryInfo *geometryInfoA, const te::vp::GeometryInfo *geometryInfoB)
Algorithm to fast detection of spatial relations between geometries. Very useful to fase dectect if t...
TEVPEXPORT void DiscardFeaturesWithNullAndEmptyGeometries(te::vp::FeatureSet &featureSet)
Splits all feature that have geometry collections in to features that have single type geometries....
TEVPEXPORT void Multi2Single(const te::vp::Feature *feature, te::vp::FeatureSet &singleFeatureSet)
Splits all the features that have geometry collections in to features that have single type geometrie...
TerraLib.
#define TEVPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition Config.h:61
Proxy configuration file for TerraView (see terraview_config.h).