Fire Core  8.0.0.alpha
GIS framework per tutti gli usi
 Tutto Classi Namespace Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Friend
Group.hpp
1 // Copyright 2015 GEOSYSTEMS SRL
2 // All Rights Reserved.
3 
4 #ifndef FIRE_GEAR_GEOM_GROUP_HPP_INCLUDED
5 #define FIRE_GEAR_GEOM_GROUP_HPP_INCLUDED
6 
7 #include <geos/index/SpatialIndex.h>
8 
9 #include <exception>
10 
11 #include "fire/export.hpp"
12 
13 #include "fire/Group.hpp"
14 #include "fire/gear/geom/event/GeometryEventListener.hpp"
15 #include "fire/gear/geom/event/GeometryEvent.hpp"
16 #include "fire/gear/geom/SpatialIndexType.hpp"
17 #include "fire/gear/geom/Filter.hpp"
18 #include "fire/gear/projection/Projection.hpp"
19 
20 namespace fire {
21 namespace gear {
22 namespace geom {
23 class Geometry;
24 } // namespace geom
25 } // namespace gear
26 } // namespace fire
27 
34 namespace fire {
41 namespace gear {
48 namespace geom {
55 class FIRE_ENGINE_DLL Group : public fire::Group< fire::gear::geom::Geometry* > {
56  private:
63  class GeometryEventListener : public fire::gear::geom::event::GeometryEventListener {
64  private:
72 
73  public:
85  explicit GeometryEventListener(fire::gear::geom::Group* group) {
86  try {
87  this->group = group;
88  } catch (const std::exception& exception) {
89  throw;
90  }
91  }
103  void handle(const fire::gear::geom::event::GeometryEvent& geometryEvent) {
104  try {
105  fire::gear::geom::Geometry* geometry = geometryEvent.getGeometry();
106  switch (geometryEvent.getType()) {
107  case fire::gear::geom::event::GeometryEventType::Unknown:
108  case fire::gear::geom::event::GeometryEventType::AfterDestroy:{
109  break;
110  }
111  case fire::gear::geom::event::GeometryEventType::BeforeUpdate: {
112  break;
113  }
114  case fire::gear::geom::event::GeometryEventType::AfterUpdate: {
115  this->group->update(geometry);
116  break;
117  }
118  case fire::gear::geom::event::GeometryEventType::BeforeDestroy: {
119  this->group->exclude(geometry);
120  break;
121  }
122  }
123  } catch (const std::exception& exception) {
124  throw;
125  }
126  }
127  };
128 
129  private:
143  std::auto_ptr< geos::index::SpatialIndex > spatialIndex;
150  int srid;
157  std::auto_ptr< fire::gear::geom::Group::GeometryEventListener > geometryEventListener;
174  void init(fire::gear::geom::SpatialIndexType::SpatialIndexType spatialIndexType, int srid);
175 
176  public:
197  Group();
209  Group(const fire::gear::geom::Group& group);
226  fire::gear::geom::Group& operator=(const fire::gear::geom::Group& group);
250  explicit Group(int srid);
286  virtual ~Group();
298  void include(fire::gear::geom::Geometry* geometry);
311  void exclude(fire::gear::geom::Geometry* geometry);
319  void clear();
332  bool contains(fire::gear::geom::Geometry* geometry) const;
350  Group filter(const fire::gear::geom::Filter& filter) const;
368  Group operator%(const fire::gear::geom::Filter& filter) const;
381  void applySpatialIndex(fire::gear::geom::SpatialIndexType::SpatialIndexType spatialIndexType);
398  void applySpatialIndex(fire::gear::geom::SpatialIndexType::SpatialIndexType spatialIndexType, int srid);
405  void revokeSpatialIndex();
417  bool isIndexed();
429  const int& getSrid() const;
441  void setSrid(int srid);
453  void update(fire::gear::geom::Geometry* geometry);
454 };
455 } // namespace geom
456 } // namespace gear
457 } // namespace fire
458 
459 #endif
Definition: Filter.hpp:51
Classe per la gestione di un evento di geometria.
Definition: GeometryEvent.hpp:46
Classe per la gestione di un gruppo di oggetti generici.
Definition: Group.hpp:33
void update(fire::gear::geom::Geometry *geometry)
fire::gear::geom::event::GeometryEventType::GeometryEventType getType() const
Restituisce il tipo dell'evento di geometria.
fire::gear::geom::Geometry * getGeometry() const
Restituisce la geometria.
Definition: Group.hpp:55
Classe per la gestione di un ascoltare di un evento di geometria.
Definition: GeometryEventListener.hpp:39
Definition: Geometry.hpp:69
SpatialIndexType
Definition: SpatialIndexType.hpp:41
void exclude(fire::gear::geom::Geometry *geometry)