BinarySpatialOp.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 BinarySpatialOp.cpp
22 
23  \brief A class for binary spatial operators.
24  */
25 
26 // TerraLib
27 #include "../geometry/Geometry.h"
28 #include "../gml/Envelope.h"
29 #include "BinarySpatialOp.h"
30 #include "Globals.h"
31 #include "PropertyName.h"
32 
33 // STL
34 #include <cassert>
35 
37  : SpatialOp(opName),
38  m_property(nullptr),
39  m_geom(nullptr),
40  m_box(nullptr)
41 {
42 }
43 
45  : SpatialOp(opName),
46  m_property(p),
47  m_geom(g),
48  m_box(nullptr)
49 {
50 }
51 
53  : SpatialOp(opName),
54  m_property(p),
55  m_geom(nullptr),
56  m_box(e)
57 {
58 }
59 
61 {
62  delete m_property;
63  delete m_geom;
64  delete m_box;
65 }
66 
68 {
69  delete m_property;
70  m_property = p;
71 }
72 
74 {
75  return m_property;
76 }
77 
79 {
80  delete m_geom;
81  m_geom = g;
82 }
83 
85 {
86  return m_geom;
87 }
88 
90 {
91  delete m_box;
92  m_box = e;
93 }
94 
96 {
97  return m_box;
98 }
99 
101 {
102  BinarySpatialOp* binOp = new BinarySpatialOp;
103 
104  if(m_name)
105  binOp->setName(m_name);
106 
107  if(m_property)
108  binOp->setProperty(new PropertyName(m_property->getName()));
109 
110  if(m_geom)
111  binOp->setGeometry(static_cast<te::gm::Geometry*>(m_geom->clone()));
112 
113  if(m_box)
115 
116  return binOp;
117 }
118 
const std::string & getName() const
It returns the property name.
te::gm::Envelope * getCoordinates() const
te::gm::Geometry * getGeometry() const
It returns the geometry.
void setName(const char *opName)
It sets the operator name.
Definition: AbstractOp.h:89
te::gm::Geometry * m_geom
A literal geometric value. (It must be omitted if m_envelope is given)
A spatial operator determines whether its geometric arguments satisfy the stated spatial relationship...
Definition: SpatialOp.h:52
void setProperty(PropertyName *p)
It sets the property name.
A class for binary spatial operators.
A class for binary spatial operators.
PropertyName * getProperty() const
It returns the property name.
int getSRID() const
BinarySpatialOp(const char *opName=0)
It initializes the BinarySpatialOp.
An static class with global definitions.
void setEnvelope(te::gml::Envelope *e)
It sets the envelope.
void setGeometry(te::gm::Geometry *g)
It sets the geometry.
This class is used to encode the name of any property of an object.
te::gm::Polygon * p
virtual AbstractData * clone() const =0
It returns a clone of this object.
Envelope defines an extent using a pair of positions defining opposite corners in arbitrary dimension...
Definition: gml/Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
AbstractOp * clone() const
It creates a new copy of this object.
An abstract interface for operators.
Definition: AbstractOp.h:47
te::gml::Envelope * getEnvelope() const
It returns the envelope.
virtual ~BinarySpatialOp()
Destructor.
te::gml::Envelope * m_box
A convenient and more compact way of encoding the very common bounding box constraint. (It must be omitted ig m_box is given)
PropertyName * m_property
A geometric property. (Mandatory)
const char * m_name
Operator name.
Definition: AbstractOp.h:123