VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
geosGeometry.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 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 <boost/optional.hpp>
18 
19 #include <vrfutil/objectCounter.h>
20 
21 namespace MAKVRinTerra
22 {
23 
27 #ifdef DtObjectDebugger_Enable
28  , public DtObjectDebugger<DtGeosGeometry>
29 #endif
30 {
31 public:
32  typedef boost::shared_ptr<DtGeosGeometry> Ptr;
33  typedef boost::shared_ptr<const DtGeosGeometry> CPtr;
34 
37 
38  template <Type T>
39  struct GeosType
40  {
41  typedef geos::geom::Geometry type;
42  };
43 
45  DtGeosGeometry(const DtGeosGeometry& orig);
46 
47  typedef std::vector<geos::geom::Coordinate> CoordinateVector;
48 
49  static DtFeatureGeometry MakePoint(const geos::geom::Coordinate&, const DtProj&);
50  static DtFeatureGeometry MakeLineString(std::auto_ptr<CoordinateVector>, const DtProj&);
51  static DtFeatureGeometry MakeLinearRing(std::auto_ptr<CoordinateVector>, const DtProj&);
52  static DtFeatureGeometry MakePolygon(
53  std::auto_ptr<CoordinateVector>, std::auto_ptr< std::vector<CoordinateVector> >,
54  const DtProj&);
55 
56  static DtGeosGeometry::Ptr Convert(DtFeatureGeometry);
57 
58  static DtFeatureGeometry Make(geos::geom::Geometry*, const DtProj&);
59 
60  static DtFeatureGeometry MakeSet(const GeometryVector&, const DtProj&);
61 
62  static DtFeatureGeometry::Area MakeBox(
63  DtFeatureGeometry::Point, double length, double width, double rotation);
64  static DtFeatureGeometry::Area MakeBox(
65  const DtProj&, double xmin, double ymin, double xmax, double ymax);
66  static DtFeatureGeometry::Area MakeBox(const DtProj::Bounds&);
67 
68  static DtFeatureGeometry::Area MakeArea(
69  const DtProj&, const std::vector<DtPoint>& points);
70  static DtFeatureGeometry::Area MakeArea(
71  const DtProj&, const std::vector<DtVector>& points);
72 
73  static DtFeatureGeometry::Point MakePoint(const DtPoint &, const DtProj &);
74 
75  static DtFeatureGeometry::Path MakePath(std::auto_ptr<CoordinateVector>, const DtProj &);
76 
77  static std::vector<DtFeatureGeometry::Path> MergeLines(DtFeatureGeometry);
78 
79  std::string description() const;
80  std::string toWKT() const;
81 
82  std::auto_ptr<PointVector> points() const;
83 
84  unsigned numberOfPoints() const;
85 
86  bool isValid() const;
87  bool isEmpty() const;
88 
89  unsigned dimension() const;
90 
91  bool equals(DtFeatureGeometry) const;
92  bool intersects(DtFeatureGeometry) const;
93  bool overlaps(DtFeatureGeometry) const;
94  bool crosses(DtFeatureGeometry) const;
95  bool covers(DtFeatureGeometry) const;
96  bool within(DtFeatureGeometry) const;
97  bool touches(DtFeatureGeometry) const;
98  bool contains(DtFeatureGeometry) const;
99 
100  std::auto_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const;
101 
102  double length() const;
103 
104  double area() const;
105 
106  DtFeatureGeometry::Point centroid() const;
107 
108  double distanceTo(DtFeatureGeometry, const DtProj&) const;
109 
110  DtFeatureGeometry unionWith(DtFeatureGeometry) const;
111 
112  DtFeatureGeometry intersectionWith(DtFeatureGeometry) const;
113 
114  DtFeatureGeometry differenceWith(DtFeatureGeometry) const;
115 
116  DtFeatureGeometry buffer(double width, unsigned segments) const;
117 
118  DtFeatureGeometry bufferWithFlatCap(double width, unsigned segments) const;
119 
120  DtFeatureGeometry convexHull() const;
121 
122  DtFeatureGeometry boundary() const;
123 
124  DtFeatureGeometry simplify(double tolerance) const;
125 
126  DtFeatureGeometry::Point closestPointTo(
127  DtFeatureGeometry, const DtProj&, double* distanceTo = 0) const;
128 
129  virtual const geos::geom::Geometry& geosGeometry() const = 0;
130 
131  virtual const geos::geom::prep::PreparedGeometry* geosPreparedGeometry() const = 0;
132 
133  boost::shared_ptr<DtGeosGeometry> shared_from_this();
134  boost::shared_ptr<const DtGeosGeometry> shared_from_this() const;
135 
136  void markValid() { myValidFlag = true; };
137 
138 protected:
139  boost::optional<bool> myValidFlag;
140 };
141 
142 template <>
144 {
146 };
147 
148 template <>
150 {
151  typedef geos::geom::LineString type;
152 };
153 
154 template <>
156 {
157  typedef geos::geom::Polygon type;
158 };
159 
160 template <>
162 {
163  typedef geos::geom::GeometryCollection type;
164 };
165 
166 template <DtFeatureGeometry::Type T>
168  : public DtGeosGeometry
169 #ifdef DtObjectDebugger_Enable
170  , public DtObjectDebugger< DtGeosGeometryImpl<T> >
171 #endif
172 {
173 public:
174 
175  typedef boost::shared_ptr<DtGeosGeometryImpl> Ptr;
176 
179 
180  static DtGeosGeometry::Ptr Convert(const DtFeatureGeometry::Handle<T>&);
181 
182  Type type() const;
183 
184  unsigned numberOfSubGeometries() const;
185  std::auto_ptr<GeometryVector> subGeometries() const;
186 
187  const typename GeosType<T>::type& geosGeometry() const
188  {
189  DtTHROW_NEW(DtFeatureGeometry::InvalidGeometry, "Invalid geosGeometry call");
190  }
191 };
192 
197 
198 }
199 
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:41
DtFeatureGeometry implementation wrapping a geos feature.
Definition: geosGeometry.h:25
DtGeosGeometryImpl()
Definition: geosGeometry.h:177
const GeosType< T >::type & geosGeometry() const
Definition: geosGeometry.h:187
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:265
Default on in debug, off in release.
Definition: objectCounter.h:31
Definition: featureGeometry.h:60
Definition: proj.h:68
geos::geom::Point type
Definition: geosGeometry.h:145
boost::shared_ptr< DtGeosGeometryImpl > Ptr
Definition: geosGeometry.h:175
DtGeosGeometryImpl< DtFeatureGeometry::AreaType > DtGeosArea
Definition: geosGeometry.h:196
geos::geom::Geometry type
Definition: geosGeometry.h:41
geos::geom::GeometryCollection type
Definition: geosGeometry.h:163
geos::geom::Polygon type
Definition: geosGeometry.h:157
DtGeosGeometryImpl(const DtGeosGeometryImpl &orig)
Definition: geosGeometry.h:178
Definition: geosGeometry.h:39
Handle< PointType > Point
Definition: featureGeometry.h:69
Represents some coordinate system. The terms &quot;coordinate system&quot;, &quot;projection&quot;, &quot;spatial reference&quot;...
Definition: proj.h:44
Definition: vrfObjectManipulationHandlerBaseClass.h:60
DtGeosGeometry()
Definition: geosGeometry.h:44
Handle< PathType > Path
Definition: featureGeometry.h:70
boost::shared_ptr< const DtGeosGeometry > CPtr
Definition: geosGeometry.h:33
DtGeosGeometryImpl< DtFeatureGeometry::PathType > DtGeosPath
Definition: geosGeometry.h:195
Create a new MAK exception type that inherits from boost::exception. Tag is what differentiates this ...
Definition: taggedException.h:15
std::vector< geos::geom::Coordinate > CoordinateVector
Definition: geosGeometry.h:47
Definition: geosGeometry.h:167
boost::shared_ptr< DtGeosGeometry > Ptr
Definition: geosGeometry.h:32
DtFeatureGeometry::Type Type
Definition: geosGeometry.h:36
DtGeosGeometryImpl< DtFeatureGeometry::PointType > DtGeosPoint
Definition: geosGeometry.h:194
DT_DLL_vrfutil bool intersects(const DtVector &localPoint1, const DtVector &localPoint2, const DtLocalVertexList &localVertexList, const Coordinate_System &coordinateSystem)
Returns true if the line segment localPoint1-localPoint2 intersects any line segment in localVert...
geos::geom::LineString type
Definition: geosGeometry.h:151
DtFeatureGeometry::Implementation Implementation
Definition: geosGeometry.h:35
Represents a feature geometry.
Definition: featureGeometry.h:39
Definition: point.h:34
DtGeosGeometryImpl< DtFeatureGeometry::UnknownType > DtGeosUnknown
Definition: geosGeometry.h:193

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)