VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include <geos/geom/prep/PreparedGeometryFactory.h>
16 
17 #include <tbb/recursive_mutex.h>
18 
19 #include <boost/optional.hpp>
20 
21 #include <vrfutil/objectCounter.h>
22 
23 namespace MAKVRinTerra
24 {
25 
29  , public DtObjectDebugger<DtGeosGeometry>
30 {
31 public:
32  typedef boost::shared_ptr<DtGeosGeometry> Ptr;
33  typedef boost::shared_ptr<const DtGeosGeometry> CPtr;
34 
37 
38  typedef tbb::recursive_mutex Mutex;
39 
40  template <Type T>
41  struct GeosType
42  {
43  typedef geos::geom::Geometry type;
44  };
45 
46  typedef std::vector<geos::geom::Coordinate> CoordinateVector;
47 
48  static DtFeatureGeometry MakePoint(const geos::geom::Coordinate&, const DtProj&);
49  static DtFeatureGeometry MakeLineString(std::auto_ptr<CoordinateVector>, const DtProj&);
50  static DtFeatureGeometry MakeLinearRing(std::auto_ptr<CoordinateVector>, const DtProj&);
51  static DtFeatureGeometry MakePolygon(
52  std::auto_ptr<CoordinateVector>, std::auto_ptr< std::vector<CoordinateVector> >,
53  const DtProj&);
54 
55  static DtGeosGeometry::Ptr Convert(DtFeatureGeometry);
56 
57  static DtFeatureGeometry Make(geos::geom::Geometry*, const DtProj&);
58 
59  static DtFeatureGeometry MakeSet(const GeometryVector&, const DtProj&);
60 
61  static DtFeatureGeometry::Area MakeBox(
62  DtFeatureGeometry::Point, double length, double width, double rotation);
63  static DtFeatureGeometry::Area MakeBox(
64  const DtProj&, double xmin, double ymin, double xmax, double ymax);
65  static DtFeatureGeometry::Area MakeBox(const DtProj::Bounds&);
66 
67  static DtFeatureGeometry::Area MakeArea(
68  const DtProj&, const std::vector<DtPoint>& points);
69  static DtFeatureGeometry::Area MakeArea(
70  const DtProj&, const std::vector<DtVector>& points);
71 
72  static DtFeatureGeometry::Point MakePoint(const DtPoint &, const DtProj &);
73 
74  static DtFeatureGeometry::Path MakePath(std::auto_ptr<CoordinateVector>, const DtProj &);
75 
76  static std::vector<DtFeatureGeometry::Path> MergeLines(DtFeatureGeometry);
77 
78  std::string description() const;
79 
80  std::auto_ptr<PointVector> points() const;
81 
82  unsigned numberOfPoints() const;
83 
84  bool isValid() const;
85  bool isEmpty() const;
86 
87  unsigned dimension() const;
88 
89  bool equals(DtFeatureGeometry) const;
90  bool intersects(DtFeatureGeometry) const;
91  bool overlaps(DtFeatureGeometry) const;
92  bool crosses(DtFeatureGeometry) const;
93  bool covers(DtFeatureGeometry) const;
94  bool within(DtFeatureGeometry) const;
95  bool touches(DtFeatureGeometry) const;
96  bool contains(DtFeatureGeometry) const;
97 
98  std::auto_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const;
99 
100  double length() const;
101 
102  double area() const;
103 
104  DtFeatureGeometry::Point centroid() const;
105 
106  double distanceTo(DtFeatureGeometry, const DtProj&) const;
107 
108  DtFeatureGeometry unionWith(DtFeatureGeometry) const;
109 
110  DtFeatureGeometry intersectionWith(DtFeatureGeometry) const;
111 
112  DtFeatureGeometry differenceWith(DtFeatureGeometry) const;
113 
114  DtFeatureGeometry buffer(double width, unsigned segments) const;
115 
116  DtFeatureGeometry convexHull() const;
117 
118  DtFeatureGeometry boundary() const;
119 
120  DtFeatureGeometry simplify(double tolerance) const;
121 
122  DtFeatureGeometry::Point closestPointTo(
123  DtFeatureGeometry, const DtProj&, double* distanceTo = 0) const;
124 
125  virtual const geos::geom::Geometry& geosGeometry() const = 0;
126  virtual const geos::geom::prep::PreparedGeometry* geosPreparedGeometry() const = 0;
127 
128  boost::shared_ptr<DtGeosGeometry> shared_from_this();
129  boost::shared_ptr<const DtGeosGeometry> shared_from_this() const;
130 
131 protected:
132  boost::optional<bool> myValidFlag;
133 };
134 
135 template <>
137 {
139 };
140 
141 template <>
143 {
144  typedef geos::geom::LineString type;
145 };
146 
147 template <>
149 {
150  typedef geos::geom::Polygon type;
151 };
152 
153 template <>
155 {
156  typedef geos::geom::GeometryCollection type;
157 };
158 
159 template <DtFeatureGeometry::Type T>
161  : public DtGeosGeometry
162  , public DtObjectDebugger< DtGeosGeometryImpl<T> >
163 {
164 public:
165 
166  typedef boost::shared_ptr<DtGeosGeometryImpl> Ptr;
167 
168  static DtGeosGeometry::Ptr Convert(const DtFeatureGeometry::Handle<T>&);
169 
170  Type type() const;
171 
172  unsigned numberOfSubGeometries() const;
173  std::auto_ptr<GeometryVector> subGeometries() const;
174 
175  const typename GeosType<T>::type& geosGeometry() const = 0;
176 };
177 
182 
183 }
184 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)