VR-Forces 4.6 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  virtual const geos::geom::prep::PreparedGeometry* geosPreparedGeometry() const = 0;
126 
127  boost::shared_ptr<DtGeosGeometry> shared_from_this();
128  boost::shared_ptr<const DtGeosGeometry> shared_from_this() const;
129 
130 protected:
131  boost::optional<bool> myValidFlag;
132 };
133 
134 template <>
136 {
138 };
139 
140 template <>
142 {
143  typedef geos::geom::LineString type;
144 };
145 
146 template <>
148 {
149  typedef geos::geom::Polygon type;
150 };
151 
152 template <>
154 {
155  typedef geos::geom::GeometryCollection type;
156 };
157 
158 template <DtFeatureGeometry::Type T>
160  : public DtGeosGeometry
161  , public DtObjectDebugger< DtGeosGeometryImpl<T> >
162 {
163 public:
164 
165  typedef boost::shared_ptr<DtGeosGeometryImpl> Ptr;
166 
167  static DtGeosGeometry::Ptr Convert(const DtFeatureGeometry::Handle<T>&);
168 
169  Type type() const;
170 
171  unsigned numberOfSubGeometries() const;
172  std::auto_ptr<GeometryVector> subGeometries() const;
173 
174  const typename GeosType<T>::type& geosGeometry() const = 0;
175 };
176 
181 
182 }
183 

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)