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
Geometry.hpp
1 // Copyright 2015 GEOSYSTEMS SRL
2 // All Rights Reserved.
3 
4 #ifndef FIRE_GEAR_GEOM_GEOMETRY_HPP_INCLUDED
5 #define FIRE_GEAR_GEOM_GEOMETRY_HPP_INCLUDED
6 
7 #include <geos/io/WKBWriter.h>
8 
9 #include <exception>
10 #include <string>
11 #include <cstddef>
12 #include <vector>
13 
14 #include "fire/gear/Entity.hpp"
15 #include "fire/gear/geom/PrecisionModel.hpp"
16 #include "fire/gear/geom/GeometryCache.hpp"
17 #include "fire/gear/geom/GeometryType.hpp"
18 #include "fire/gear/geom/DimensionType.hpp"
19 #include "fire/gear/geom/Envelope.hpp"
20 #include "fire/gear/geom/event/GeometryEvent.hpp"
21 
22 namespace Json {
23 class Value;
24 }
25 
26 namespace fire {
27 namespace gear {
28 namespace geom {
29 class Point;
30 } // namespace geom
31 } // namespace gear
32 } // namespace fire
33 
34 namespace geos {
35 namespace geom {
36 class Envelope;
37 } // namespace geom
38 } // namespace geos
39 
40 namespace fire {
41 namespace gear {
42 namespace io {
43 class JsonReader;
44 } // namespace io
45 } // namespace gear
46 } // namespace fire
47 
48 namespace fire {
55 namespace gear {
62 namespace geom {
69 class FIRE_ENGINE_DLL Geometry : public fire::gear::Entity {
70  friend class GeometryConverter; // Per permettere l' accesso alla cache
71  friend class GeometryCollection; // Per permettere l' accesso al metodo protected loadJsonValueGeometry
72  friend class io::JsonReader; // Per permettere l' accesso al metodo protected setCoordinatesFromJsonValue
73 
74  private:
75 
76  enum Relation_Type {
77  _DISJOINT,
78  _TOUCHES,
79  _INTERSECT,
80  _CROSSES,
81  _WITHIN,
82  _CONTAINS,
83  _OVERLAPS,
84  _RELATE,
85  _EQUALS,
86  _COVERS,
87  _COVEREDBY
88  };
89 
90  enum Operation_Type {
91  _INTERSECTION,
92  _UNION
93  };
100  PrecisionModel precisionModelGeom;
107  int srid;
114  GeometryCache cache;
131  bool checkWktDimension(const int dimension, int& newdimension) const;
138  Geometry* operation(const Geometry& other, Operation_Type operation) const;
139  bool relation(const Geometry& other, Relation_Type operation, const char* string = NULL) const;
140 
149  virtual void setUpdated(bool value);
150 
151  static const int getByteOrderOnMachine();
152 
153  protected:
172  virtual void loadJsonValueGeometry(Json::Value& value) const = 0;
184  virtual void setCoordinatesFromJsonValue(Json::Value& value) = 0;
185 
186  public:
193  Geometry();
210  Geometry(PrecisionModel* precisionModel, int srid);
227  Geometry(const PrecisionModel& precisionModel, int srid);
234  Geometry(const Geometry& geometry);
241  virtual Geometry& operator=(const Geometry& geometry);
248  virtual ~Geometry();
260  PrecisionModel* getPrecisionModel() const;
272  void setPrecisionModel(PrecisionModel* precisionModel);
284  int getSrid() const;
296  void setSrid(const int& value);
308  virtual GeometryType::GeometryType getGeometryType() const = 0;
320  virtual bool isEmpty() const = 0;
332  bool isSimple() const;
344  bool isValid() const;
351  Envelope* getEnvelope();
358  double getMaxY() const;
365  double getMaxX() const;
372  double getMinY() const;
379  double getMinX() const;
391  virtual DimensionType::DimensionType getDimensionType() const = 0;
403  Point* getCentroid() const;
415  Point* getInteriorPoint() const;
427  virtual double getLength() const = 0;
439  virtual double getArea() const = 0;
451  virtual std::size_t getCoordinatesCount() const = 0;
458  virtual bool normalize() = 0;
470  virtual Geometry* clone() const = 0;
482  virtual std::string toString() const;
504  virtual std::string toWkt(bool oldStyle = false, int dimension = 3, int decimalPrecision = -1) const;
526  virtual std::string toJson(bool onlyGeom = true, bool pretty = false) const;
553  virtual void toWkb(std::ostream& outputStream, const int dimension = 3, const int newByteOrder = Geometry::getByteOrderOnMachine(), const bool includeSRID = false) const;
561  virtual bool isUpdated() const;
567  void invalidateUpdated();
587  virtual bool isZ_DoubleNotANumber() const = 0;
596  void beforeUpdateOperations();
606  void afterUpdateOperations();
607 
608  virtual Geometry* intersection(const Geometry& other) const;
609  Geometry* Union(const Geometry& other) const;
610  virtual bool disjoint(const Geometry& other) const;
611  virtual bool touches(const Geometry& other) const;
612  virtual bool intersects(const Geometry& other) const;
613  virtual bool crosses(const Geometry& other) const;
614  virtual bool within(const Geometry& other) const;
615  virtual bool contains(const Geometry& other) const;
616  virtual bool overlaps(const Geometry& other) const;
617  virtual bool relate(const Geometry& other, const std::string& intersectionPattern) const;
634  virtual bool equals(const Geometry& other) const;
635  bool covers(const Geometry& other) const;
636  bool coveredBy(const Geometry& other) const;
637 
638  void beforeDestroy();
639 };
640 
641 } // namespace geom
642 } // namespace gear
643 } // namespace fire
644 
645 #endif
Definition: PrecisionModel.hpp:50
Definition: GeometryConverter.hpp:67
Definition: GeometryCollection.hpp:51
Definition: Entity.hpp:44
classe che specializza l' interfaccia del reader delle geometrie per il formato GeoJson ...
Definition: JsonReader.hpp:46
Classe per la gestione di un evento di geometria.
Definition: GeometryEvent.hpp:46
Definition: Envelope.hpp:31
GeometryType
Definition: GeometryType.hpp:43
fire::gear::geom::event::GeometryEvent geometryEvent
Definition: Geometry.hpp:160
Definition: Point.hpp:48
Definition: Geometry.hpp:69
Definition: GeometryCache.hpp:55
DimensionType
Definition: DimensionType.hpp:41