VR-Forces 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/Point.h>
16 #include <geos/geom/LineString.h>
17 #include <geos/geom/Polygon.h>
18 #include <geos/geom/GeometryCollection.h>
19 #include <geos/geom/prep/PreparedGeometry.h>
20 
21 #include <boost/optional.hpp>
22 
23 #include <vrfutil/objectCounter.h>
24 
25 namespace MAKVRinTerra
26 {
27 
31 #ifdef DtObjectDebugger_Enable
32  , public DtObjectDebugger<DtGeosGeometry>
33 #endif
34 {
35 public:
36  typedef std::shared_ptr<DtGeosGeometry> Ptr;
37  typedef std::shared_ptr<const DtGeosGeometry> CPtr;
38 
41 
42  template <Type T>
43  struct GeosType
44  {
45  typedef geos::geom::Geometry type;
46  };
47 
49  DtGeosGeometry(const DtGeosGeometry& orig);
50 
51  typedef std::vector<geos::geom::Coordinate> CoordinateVector;
52 
53  static DtFeatureGeometry MakePoint(const geos::geom::Coordinate&, const DtProj&);
54  static DtFeatureGeometry MakeLineString(std::unique_ptr<CoordinateVector>, const DtProj&);
55  static DtFeatureGeometry MakeLinearRing(std::unique_ptr<CoordinateVector>, const DtProj&);
56  static DtFeatureGeometry MakePolygon(
57  std::unique_ptr<CoordinateVector>, std::unique_ptr< std::vector<CoordinateVector> >,
58  const DtProj&);
59 
60  static DtGeosGeometry::Ptr Convert(DtFeatureGeometry);
61 
62  static DtFeatureGeometry Make(geos::geom::Geometry*, const DtProj&);
63 
64  static DtFeatureGeometry MakeSet(const GeometryVector&, const DtProj&);
65 
66  static DtFeatureGeometry::Area MakeBox(
67  DtFeatureGeometry::Point, double length, double width, double rotation);
68  static DtFeatureGeometry::Area MakeBox(
69  const DtProj&, double xmin, double ymin, double xmax, double ymax);
70  static DtFeatureGeometry::Area MakeBox(const DtProj::Bounds&);
71 
72  static DtFeatureGeometry::Area MakeArea(
73  const DtProj&, const std::vector<DtPoint>& points);
74  static DtFeatureGeometry::Area MakeArea(
75  const DtProj&, const std::vector<DtVector>& points);
76 
77  static DtFeatureGeometry::Point MakePoint(const DtPoint &, const DtProj &);
78 
79  static DtFeatureGeometry::Path MakePath(std::unique_ptr<CoordinateVector>, const DtProj &);
80 
81  static std::vector<DtFeatureGeometry::Path> MergeLines(DtFeatureGeometry);
82 
83  virtual std::string description() const override;
84  virtual std::string toWKT() const override;
85 
86  virtual std::unique_ptr<PointVector> points() const override;
87 
88  virtual unsigned numberOfPoints() const override;
89 
90  virtual bool isValid() const override;
91  virtual bool isEmpty() const override;
92 
93  virtual unsigned dimension() const override;
94 
95  virtual bool equals(DtFeatureGeometry) const override;
96  virtual bool intersects(DtFeatureGeometry) const override;
97  virtual bool overlaps(DtFeatureGeometry) const override;
98  virtual bool crosses(DtFeatureGeometry) const override;
99  virtual bool covers(DtFeatureGeometry) const override;
100  virtual bool within(DtFeatureGeometry) const override;
101  virtual bool touches(DtFeatureGeometry) const override;
102  virtual bool contains(DtFeatureGeometry) const override;
103 
104  virtual std::unique_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const override;
105 
106  virtual double length() const override;
107 
108  virtual double area() const override;
109 
110  virtual DtFeatureGeometry::Point centroid() const override;
111 
112  virtual double distanceTo(DtFeatureGeometry, const DtProj&) const override;
113 
114  virtual DtFeatureGeometry unionWith(DtFeatureGeometry) const override;
115 
116  virtual DtFeatureGeometry intersectionWith(DtFeatureGeometry) const override;
117 
118  virtual DtFeatureGeometry differenceWith(DtFeatureGeometry) const override;
119 
120  virtual DtFeatureGeometry buffer(double width, unsigned segments) const override;
121 
122  virtual DtFeatureGeometry bufferWithFlatCap(double width, unsigned segments) const override;
123 
124  virtual DtFeatureGeometry convexHull() const override;
125 
126  virtual DtFeatureGeometry boundary() const override;
127 
128  virtual DtFeatureGeometry simplify(double tolerance) const override;
129 
130  virtual DtFeatureGeometry::Point closestPointTo(
131  DtFeatureGeometry, const DtProj&, double* distanceTo = 0) const override;
132 
133  virtual const geos::geom::Geometry& geosGeometry() const = 0;
134 
135  virtual const geos::geom::prep::PreparedGeometry* geosPreparedGeometry() const = 0;
136 
137  std::shared_ptr<DtGeosGeometry> shared_from_this();
138  std::shared_ptr<const DtGeosGeometry> shared_from_this() const;
139 
140  void markValid() { myValidFlag = true; };
141 
142 protected:
143  boost::optional<bool> myValidFlag;
144 };
145 
146 template <>
148 {
150 };
151 
152 template <>
154 {
155  typedef geos::geom::LineString type;
156 };
157 
158 template <>
160 {
161  typedef geos::geom::Polygon type;
162 };
163 
164 template <>
166 {
167  typedef geos::geom::GeometryCollection type;
168 };
169 
170 template <DtFeatureGeometry::Type T>
172  : public DtGeosGeometry
173 #ifdef DtObjectDebugger_Enable
174  , public DtObjectDebugger< DtGeosGeometryImpl<T> >
175 #endif
176 {
177 public:
178 
179  typedef std::shared_ptr<DtGeosGeometryImpl> Ptr;
180 
183 
184  static DtGeosGeometry::Ptr Convert(const DtFeatureGeometry::Handle<T>&);
185 
186  virtual Type type() const override;
187 
188  virtual unsigned numberOfSubGeometries() const override;
189  virtual std::unique_ptr<GeometryVector> subGeometries() const override;
190 
191  virtual const typename GeosType<T>::type& geosGeometry() const override
192  {
193  DtTHROW_NEW(DtFeatureGeometry::InvalidGeometry, "Invalid geosGeometry call");
194  }
195 };
196 
201 
202 }
203 
#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:29
DtGeosGeometryImpl()
Definition: geosGeometry.h:181
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:31
Default on in debug, off in release.
Definition: objectCounter.h:27
Definition: featureGeometry.h:61
Definition: proj.h:76
geos::geom::Point type
Definition: geosGeometry.h:149
DtGeosGeometryImpl< DtFeatureGeometry::AreaType > DtGeosArea
Definition: geosGeometry.h:200
geos::geom::Geometry type
Definition: geosGeometry.h:45
geos::geom::GeometryCollection type
Definition: geosGeometry.h:167
geos::geom::Polygon type
Definition: geosGeometry.h:161
DtGeosGeometryImpl(const DtGeosGeometryImpl &orig)
Definition: geosGeometry.h:182
Definition: geosGeometry.h:43
Handle< PointType > Point
Definition: featureGeometry.h:70
virtual const GeosType< T >::type & geosGeometry() const override
Definition: geosGeometry.h:191
Represents some coordinate system. The terms &quot;coordinate system&quot;, &quot;projection&quot;, &quot;spatial reference&quot;...
Definition: proj.h:52
std::shared_ptr< DtGeosGeometryImpl > Ptr
Definition: geosGeometry.h:179
Definition: vrfObjectManipulationHandlerBaseClass.h:60
DtGeosGeometry()
Definition: geosGeometry.h:48
Handle< PathType > Path
Definition: featureGeometry.h:71
std::shared_ptr< DtGeosGeometry > Ptr
Definition: geosGeometry.h:36
DtGeosGeometryImpl< DtFeatureGeometry::PathType > DtGeosPath
Definition: geosGeometry.h:199
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:51
Definition: geosGeometry.h:171
DtFeatureGeometry::Type Type
Definition: geosGeometry.h:40
DT_DLL_VRVCORE double length(const makVrv::DtCoordinateSystem &, const std::vector< DtVector > &vertices)
Returns the total distance of a segmented line defined by the provided vector of vertices. Coordinates are in local database coordinates. The coordinate system is used to convert between the local database coordinates and geocentric. All distance is in 2D – the Z value is ignored.
DtGeosGeometryImpl< DtFeatureGeometry::PointType > DtGeosPoint
Definition: geosGeometry.h:198
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:155
DtFeatureGeometry::Implementation Implementation
Definition: geosGeometry.h:39
std::shared_ptr< const DtGeosGeometry > CPtr
Definition: geosGeometry.h:37
Represents a feature geometry.
Definition: featureGeometry.h:40
Definition: point.h:34
DtGeosGeometryImpl< DtFeatureGeometry::UnknownType > DtGeosUnknown
Definition: geosGeometry.h:197

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)