VR-Forces 4.10 Class Documentation
 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 
44  typedef std::vector<geos::geom::Coordinate> CoordinateVector;
45 
46  static DtFeatureGeometry MakePoint(const geos::geom::Coordinate&, const DtProj&);
47  static DtFeatureGeometry MakeLineString(std::auto_ptr<CoordinateVector>, const DtProj&);
48  static DtFeatureGeometry MakeLinearRing(std::auto_ptr<CoordinateVector>, const DtProj&);
49  static DtFeatureGeometry MakePolygon(
50  std::auto_ptr<CoordinateVector>, std::auto_ptr< std::vector<CoordinateVector> >,
51  const DtProj&);
52 
53  static DtGeosGeometry::Ptr Convert(DtFeatureGeometry);
54 
55  static DtFeatureGeometry Make(geos::geom::Geometry*, const DtProj&);
56 
57  static DtFeatureGeometry MakeSet(const GeometryVector&, const DtProj&);
58 
59  static DtFeatureGeometry::Area MakeBox(
60  DtFeatureGeometry::Point, double length, double width, double rotation);
61  static DtFeatureGeometry::Area MakeBox(
62  const DtProj&, double xmin, double ymin, double xmax, double ymax);
63  static DtFeatureGeometry::Area MakeBox(const DtProj::Bounds&);
64 
65  static DtFeatureGeometry::Area MakeArea(
66  const DtProj&, const std::vector<DtPoint>& points);
67  static DtFeatureGeometry::Area MakeArea(
68  const DtProj&, const std::vector<DtVector>& points);
69 
70  static DtFeatureGeometry::Point MakePoint(const DtPoint &, const DtProj &);
71 
72  static DtFeatureGeometry::Path MakePath(std::auto_ptr<CoordinateVector>, const DtProj &);
73 
74  static std::vector<DtFeatureGeometry::Path> MergeLines(DtFeatureGeometry);
75 
76  std::string description() const;
77  std::string toWKT() const;
78 
79  std::auto_ptr<PointVector> points() const;
80 
81  unsigned numberOfPoints() const;
82 
83  bool isValid() const;
84  bool isEmpty() const;
85 
86  unsigned dimension() const;
87 
88  bool equals(DtFeatureGeometry) const;
89  bool intersects(DtFeatureGeometry) const;
90  bool overlaps(DtFeatureGeometry) const;
91  bool crosses(DtFeatureGeometry) const;
92  bool covers(DtFeatureGeometry) const;
93  bool within(DtFeatureGeometry) const;
94  bool touches(DtFeatureGeometry) const;
95  bool contains(DtFeatureGeometry) const;
96 
97  std::auto_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const;
98 
99  double length() const;
100 
101  double area() const;
102 
103  DtFeatureGeometry::Point centroid() const;
104 
105  double distanceTo(DtFeatureGeometry, const DtProj&) const;
106 
107  DtFeatureGeometry unionWith(DtFeatureGeometry) const;
108 
109  DtFeatureGeometry intersectionWith(DtFeatureGeometry) const;
110 
111  DtFeatureGeometry differenceWith(DtFeatureGeometry) const;
112 
113  DtFeatureGeometry buffer(double width, unsigned segments) const;
114 
115  DtFeatureGeometry bufferWithFlatCap(double width, unsigned segments) const;
116 
117  DtFeatureGeometry convexHull() const;
118 
119  DtFeatureGeometry boundary() const;
120 
121  DtFeatureGeometry simplify(double tolerance) const;
122 
123  DtFeatureGeometry::Point closestPointTo(
124  DtFeatureGeometry, const DtProj&, double* distanceTo = 0) const;
125 
126  virtual const geos::geom::Geometry& geosGeometry() const = 0;
127 
128  virtual const geos::geom::prep::PreparedGeometry* geosPreparedGeometry() const = 0;
129 
130  boost::shared_ptr<DtGeosGeometry> shared_from_this();
131  boost::shared_ptr<const DtGeosGeometry> shared_from_this() const;
132 
133 protected:
134  boost::optional<bool> myValidFlag;
135 };
136 
137 template <>
139 {
141 };
142 
143 template <>
145 {
146  typedef geos::geom::LineString type;
147 };
148 
149 template <>
151 {
152  typedef geos::geom::Polygon type;
153 };
154 
155 template <>
157 {
158  typedef geos::geom::GeometryCollection type;
159 };
160 
161 template <DtFeatureGeometry::Type T>
163  : public DtGeosGeometry
164 #ifdef DtObjectDebugger_Enable
165  , public DtObjectDebugger< DtGeosGeometryImpl<T> >
166 #endif
167 {
168 public:
169 
170  typedef boost::shared_ptr<DtGeosGeometryImpl> Ptr;
171 
172  static DtGeosGeometry::Ptr Convert(const DtFeatureGeometry::Handle<T>&);
173 
174  Type type() const;
175 
176  unsigned numberOfSubGeometries() const;
177  std::auto_ptr<GeometryVector> subGeometries() const;
178 
179  const typename GeosType<T>::type& geosGeometry() const
180  {
181  DtTHROW_NEW(DtFeatureGeometry::InvalidGeometry, "Invalid geosGeometry call");
182  }
183 };
184 
189 
190 }
191 
#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
const GeosType< T >::type & geosGeometry() const
Definition: geosGeometry.h:179
#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:56
Definition: proj.h:68
geos::geom::Point type
Definition: geosGeometry.h:140
boost::shared_ptr< DtGeosGeometryImpl > Ptr
Definition: geosGeometry.h:170
DtGeosGeometryImpl< DtFeatureGeometry::AreaType > DtGeosArea
Definition: geosGeometry.h:188
geos::geom::Geometry type
Definition: geosGeometry.h:41
geos::geom::GeometryCollection type
Definition: geosGeometry.h:158
geos::geom::Polygon type
Definition: geosGeometry.h:152
Definition: geosGeometry.h:39
Handle< PointType > Point
Definition: featureGeometry.h:65
Represents some coordinate system.
Definition: proj.h:44
Definition: vrfObjectManipulationHandlerBaseClass.h:59
Handle< PathType > Path
Definition: featureGeometry.h:66
boost::shared_ptr< const DtGeosGeometry > CPtr
Definition: geosGeometry.h:33
DtGeosGeometryImpl< DtFeatureGeometry::PathType > DtGeosPath
Definition: geosGeometry.h:187
Create a new MAK exception type that inherits from boost::exception.
Definition: taggedException.h:15
std::vector< geos::geom::Coordinate > CoordinateVector
Definition: geosGeometry.h:44
Definition: geosGeometry.h:162
boost::shared_ptr< DtGeosGeometry > Ptr
Definition: geosGeometry.h:32
DtFeatureGeometry::Type Type
Definition: geosGeometry.h:36
DtGeosGeometryImpl< DtFeatureGeometry::PointType > DtGeosPoint
Definition: geosGeometry.h:186
boost::optional< bool > myValidFlag
Definition: geosGeometry.h:134
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.
geos::geom::LineString type
Definition: geosGeometry.h:146
DtFeatureGeometry::Implementation Implementation
Definition: geosGeometry.h:35
Represents a feature geometry.
Definition: featureGeometry.h:35
Definition: point.h:34
DtGeosGeometryImpl< DtFeatureGeometry::UnknownType > DtGeosUnknown
Definition: geosGeometry.h:185

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)