VR-Forces 4.8 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) 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 <boost/optional.hpp>
18 
19 #include <vrfutil/objectCounter.h>
20 
21 namespace MAKVRinTerra
22 {
23 
27  , public DtObjectDebugger<DtGeosGeometry>
28 {
29 public:
30  typedef boost::shared_ptr<DtGeosGeometry> Ptr;
31  typedef boost::shared_ptr<const DtGeosGeometry> CPtr;
32 
35 
36  template <Type T>
37  struct GeosType
38  {
39  typedef geos::geom::Geometry type;
40  };
41 
42  typedef std::vector<geos::geom::Coordinate> CoordinateVector;
43 
44  static DtFeatureGeometry MakePoint(const geos::geom::Coordinate&, const DtProj&);
45  static DtFeatureGeometry MakeLineString(std::auto_ptr<CoordinateVector>, const DtProj&);
46  static DtFeatureGeometry MakeLinearRing(std::auto_ptr<CoordinateVector>, const DtProj&);
47  static DtFeatureGeometry MakePolygon(
48  std::auto_ptr<CoordinateVector>, std::auto_ptr< std::vector<CoordinateVector> >,
49  const DtProj&);
50 
51  static DtGeosGeometry::Ptr Convert(DtFeatureGeometry);
52 
53  static DtFeatureGeometry Make(geos::geom::Geometry*, const DtProj&);
54 
55  static DtFeatureGeometry MakeSet(const GeometryVector&, const DtProj&);
56 
57  static DtFeatureGeometry::Area MakeBox(
58  DtFeatureGeometry::Point, double length, double width, double rotation);
59  static DtFeatureGeometry::Area MakeBox(
60  const DtProj&, double xmin, double ymin, double xmax, double ymax);
61  static DtFeatureGeometry::Area MakeBox(const DtProj::Bounds&);
62 
63  static DtFeatureGeometry::Area MakeArea(
64  const DtProj&, const std::vector<DtPoint>& points);
65  static DtFeatureGeometry::Area MakeArea(
66  const DtProj&, const std::vector<DtVector>& points);
67 
68  static DtFeatureGeometry::Point MakePoint(const DtPoint &, const DtProj &);
69 
70  static DtFeatureGeometry::Path MakePath(std::auto_ptr<CoordinateVector>, const DtProj &);
71 
72  static std::vector<DtFeatureGeometry::Path> MergeLines(DtFeatureGeometry);
73 
74  std::string description() const;
75  std::string toWKT() const;
76 
77  std::auto_ptr<PointVector> points() const;
78 
79  unsigned numberOfPoints() const;
80 
81  bool isValid() const;
82  bool isEmpty() const;
83 
84  unsigned dimension() const;
85 
86  bool equals(DtFeatureGeometry) const;
87  bool intersects(DtFeatureGeometry) const;
88  bool overlaps(DtFeatureGeometry) const;
89  bool crosses(DtFeatureGeometry) const;
90  bool covers(DtFeatureGeometry) const;
91  bool within(DtFeatureGeometry) const;
92  bool touches(DtFeatureGeometry) const;
93  bool contains(DtFeatureGeometry) const;
94 
95  std::auto_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const;
96 
97  double length() const;
98 
99  double area() const;
100 
101  DtFeatureGeometry::Point centroid() const;
102 
103  double distanceTo(DtFeatureGeometry, const DtProj&) const;
104 
105  DtFeatureGeometry unionWith(DtFeatureGeometry) const;
106 
107  DtFeatureGeometry intersectionWith(DtFeatureGeometry) const;
108 
109  DtFeatureGeometry differenceWith(DtFeatureGeometry) const;
110 
111  DtFeatureGeometry buffer(double width, unsigned segments) const;
112 
113  DtFeatureGeometry bufferWithFlatCap(double width, unsigned segments) const;
114 
115  DtFeatureGeometry convexHull() const;
116 
117  DtFeatureGeometry boundary() const;
118 
119  DtFeatureGeometry simplify(double tolerance) const;
120 
121  DtFeatureGeometry::Point closestPointTo(
122  DtFeatureGeometry, const DtProj&, double* distanceTo = 0) const;
123 
124  virtual const geos::geom::Geometry& geosGeometry() const = 0;
125 
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
176  {
177  DtTHROW_NEW(DtFeatureGeometry::InvalidGeometry, "Invalid geosGeometry call");
178  }
179 };
180 
185 
186 }
187 
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:36
DtFeatureGeometry implementation wrapping a geos feature.
Definition: geosGeometry.h:25
const GeosType< T >::type & geosGeometry() const
Definition: geosGeometry.h:175
#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:54
Definition: proj.h:68
geos::geom::Point type
Definition: geosGeometry.h:138
boost::shared_ptr< DtGeosGeometryImpl > Ptr
Definition: geosGeometry.h:166
DtGeosGeometryImpl< DtFeatureGeometry::AreaType > DtGeosArea
Definition: geosGeometry.h:184
geos::geom::Geometry type
Definition: geosGeometry.h:39
geos::geom::GeometryCollection type
Definition: geosGeometry.h:156
geos::geom::Polygon type
Definition: geosGeometry.h:150
Definition: geosGeometry.h:37
Handle< PointType > Point
Definition: featureGeometry.h:63
Represents some coordinate system.
Definition: proj.h:44
Definition: vrfObjectManipulationHandlerBaseClass.h:61
Handle< PathType > Path
Definition: featureGeometry.h:64
boost::shared_ptr< const DtGeosGeometry > CPtr
Definition: geosGeometry.h:31
DtGeosGeometryImpl< DtFeatureGeometry::PathType > DtGeosPath
Definition: geosGeometry.h:183
Create a new MAK exception type that inherits from boost::exception.
Definition: taggedException.h:15
std::vector< geos::geom::Coordinate > CoordinateVector
Definition: geosGeometry.h:42
Definition: geosGeometry.h:160
boost::shared_ptr< DtGeosGeometry > Ptr
Definition: geosGeometry.h:30
DtFeatureGeometry::Type Type
Definition: geosGeometry.h:34
DtGeosGeometryImpl< DtFeatureGeometry::PointType > DtGeosPoint
Definition: geosGeometry.h:182
boost::optional< bool > myValidFlag
Definition: geosGeometry.h:132
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:144
DtFeatureGeometry::Implementation Implementation
Definition: geosGeometry.h:33
Represents a feature geometry.
Definition: featureGeometry.h:35
Definition: point.h:34
DtGeosGeometryImpl< DtFeatureGeometry::UnknownType > DtGeosUnknown
Definition: geosGeometry.h:181

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)