All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SpatialOperator.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 SpatialOperator.cpp
22 
23  \brief Spatial operator.
24  */
25 
26 // TerraLib
27 #include "GeometryOperands.h"
28 #include "Globals.h"
29 #include "SpatialOperator.h"
30 
31 // STL
32 #include <cassert>
33 
34 std::set<const char*, te::common::LessCmp<const char*> > te::fe::SpatialOperator::sm_validSpatialOperators;
35 
37  : m_name(opName),
38  m_geometryOperands(0)
39 {
40  assert(opName);
41 }
42 
44 {
45  delete m_geometryOperands;
46 }
47 
49 {
50  return m_name;
51 }
52 
54 {
55  delete m_geometryOperands;
56  m_geometryOperands = gOps;
57 }
58 
60 {
61  return m_geometryOperands;
62 }
63 
64 const char* te::fe::SpatialOperator::findOperator(const char* o)
65 {
66  assert(o);
67 
68  std::set<const char*, te::common::LessCmp<const char*> >::const_iterator it = sm_validSpatialOperators.find(o);
69 
70  if(it != sm_validSpatialOperators.end())
71  return *it;
72 
73  return 0;
74 }
75 
77 {
78  sm_validSpatialOperators.insert(Globals::sm_bbox);
79  sm_validSpatialOperators.insert(Globals::sm_equals);
80  sm_validSpatialOperators.insert(Globals::sm_disjoint);
81  sm_validSpatialOperators.insert(Globals::sm_touches);
82  sm_validSpatialOperators.insert(Globals::sm_within);
83  sm_validSpatialOperators.insert(Globals::sm_overlaps);
84  sm_validSpatialOperators.insert(Globals::sm_crosses);
85  sm_validSpatialOperators.insert(Globals::sm_intersects);
86  sm_validSpatialOperators.insert(Globals::sm_contains);
87  sm_validSpatialOperators.insert(Globals::sm_dWithin);
88  sm_validSpatialOperators.insert(Globals::sm_beyond);
89 }
90 
92 {
93  sm_validSpatialOperators.clear();
94 }
95 
static const char * sm_touches
Definition: Globals.h:76
SpatialOperator(const char *opName)
It initializes a new SpatialOperator.
static const char * sm_dWithin
Definition: Globals.h:83
~SpatialOperator()
Destructor.
static const char * sm_contains
Definition: Globals.h:81
static const char * sm_crosses
Definition: Globals.h:79
Geometry operands.
static const char * sm_intersects
Definition: Globals.h:80
static const char * sm_disjoint
Definition: Globals.h:75
static const char * sm_within
Definition: Globals.h:77
Geometry operands.
static std::set< const char *, te::common::LessCmp< const char * > > sm_validSpatialOperators
The list of valid spatial operators.
static const char * findOperator(const char *o)
It checks if operator 'o' is a valid operator. It returns a pointer to the found operator or NULL oth...
static const char * sm_beyond
Definition: Globals.h:84
static void loadValidOperatorList()
It loads the valid spatial operator list.
const char * getOpName() const
It returns the operator name.
const GeometryOperands * getGeometryOperands() const
It returns the geometry operands.
An static class with global definitions.
void setGeometryOperands(GeometryOperands *gOps)
It sets the geometry operands.
static void clearValidOperatorList()
It clears the valid operator list.
static const char * sm_equals
Definition: Globals.h:74
static const char * sm_overlaps
Definition: Globals.h:78
static const char * sm_bbox
Definition: Globals.h:72
Spatial operator.