VR-Forces 4.2 Class Documentation
geosGeometry.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <geos.h>
15 
16 #include <tbb/recursive_mutex.h>
17 
18 #include <boost/optional.hpp>
19 
20 namespace MAKVRinTerra
21 {
22 
24 class DT_DLL_features DtGeosGeometry : public DtFeatureGeometry::Implementation
25 {
26 public:
27  typedef boost::shared_ptr<DtGeosGeometry> Ptr;
28  typedef boost::shared_ptr<const DtGeosGeometry> CPtr;
29 
30  typedef DtFeatureGeometry::Implementation Implementation;
32 
33  typedef tbb::recursive_mutex Mutex;
34 
35  template <Type T>
36  struct GeosType
37  {
38  typedef geos::geom::Geometry type;
39  };
40 
41  typedef std::vector<geos::geom::Coordinate> CoordinateVector;
42 
43  static DtFeatureGeometry MakePoint(const geos::geom::Coordinate&, const DtProj&);
44  static DtFeatureGeometry MakeLineString(std::auto_ptr<CoordinateVector>, const DtProj&);
45  static DtFeatureGeometry MakeLinearRing(std::auto_ptr<CoordinateVector>, const DtProj&);
46  static DtFeatureGeometry MakePolygon(
47  std::auto_ptr<CoordinateVector>, std::auto_ptr< std::vector<CoordinateVector> >,
48  const DtProj&);
49 
50  static DtFeatureGeometry Convert(DtFeatureGeometry);
51 
52  static DtFeatureGeometry Make(geos::geom::Geometry*, const DtProj&);
53 
54  static DtFeatureGeometry MakeSet(const GeometryVector&);
55 
56  static DtFeatureGeometry::Area MakeBox(
57  DtFeatureGeometry::Point, double length, double width, double rotation);
58  static DtFeatureGeometry::Area MakeBox(
59  const DtProj&, double xmin, double ymin, double xmax, double ymax);
60  static DtFeatureGeometry::Area MakeBox(const DtProj::Bounds&);
61 
62  static DtFeatureGeometry::Area MakeArea(
63  const DtProj&, std::vector<DtPoint> points);
64  static DtFeatureGeometry::Area MakeArea(
65  const DtProj&, std::vector<DtVector> points);
66 
67  static DtFeatureGeometry::Point MakePoint(const DtPoint &, const DtProj &);
68 
69  static DtFeatureGeometry::Path MakePath(std::auto_ptr<CoordinateVector>, const DtProj &);
70 
71  static std::vector<DtFeatureGeometry::Path> MergeLines(DtFeatureGeometry);
72 
73  std::string description() const;
74 
75  std::auto_ptr<PointVector> points() const;
76 
77  unsigned numberOfPoints() const;
78 
79  bool isValid() const;
80  bool isEmpty() const;
81 
82  unsigned dimension() const;
83 
84  bool equals(DtFeatureGeometry) const;
85  bool intersects(DtFeatureGeometry) const;
86  bool overlaps(DtFeatureGeometry) const;
87  bool covers(DtFeatureGeometry) const;
88  bool within(DtFeatureGeometry) const;
89  bool touches(DtFeatureGeometry) const;
90 
91  std::auto_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const;
92 
93  double length() const;
94 
95  double area() const;
96 
97  DtFeatureGeometry::Point centroid() const;
98 
99  double distanceTo(DtFeatureGeometry, const DtProj&) const;
100 
101  DtFeatureGeometry unionWith(DtFeatureGeometry) const;
102 
103  DtFeatureGeometry intersectionWith(DtFeatureGeometry) const;
104 
105  DtFeatureGeometry differenceWith(DtFeatureGeometry) const;
106 
107  DtFeatureGeometry buffer(double width, unsigned segments) const;
108 
109  DtFeatureGeometry convexHull() const;
110 
111  DtFeatureGeometry boundary() const;
112 
113  DtFeatureGeometry::Point closestPointTo(DtFeatureGeometry, double* distanceTo = NULL) const;
114 
115  virtual const geos::geom::Geometry& geosGeometry() const = 0;
116 
117  boost::shared_ptr<DtGeosGeometry> shared_from_this();
118  boost::shared_ptr<const DtGeosGeometry> shared_from_this() const;
119 
120 protected:
121  boost::optional<bool> myValidFlag;
122 };
123 
124 template <>
126 {
127  typedef geos::geom::Point type;
128 };
129 
130 template <>
132 {
133  typedef geos::geom::LineString type;
134 };
135 
136 template <>
138 {
139  typedef geos::geom::Polygon type;
140 };
141 
142 template <>
144 {
145  typedef geos::geom::GeometryCollection type;
146 };
147 
148 template <DtFeatureGeometry::Type T>
150 {
151 public:
152  typedef boost::shared_ptr<DtGeosGeometryImpl> Ptr;
153 
154  static DtFeatureGeometry Convert(DtFeatureGeometry::Handle<T>);
155 
156  Type type() const;
157 
158  unsigned numberOfSubGeometries() const;
159  std::auto_ptr<GeometryVector> subGeometries() const;
160 
161  const typename GeosType<T>::type& geosGeometry() const = 0;
162 };
163 
168 
169 }

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)