VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
76  std::auto_ptr<PointVector> points() const;
77 
78  unsigned numberOfPoints() const;
79 
80  bool isValid() const;
81  bool isEmpty() const;
82 
83  unsigned dimension() const;
84 
85  bool equals(DtFeatureGeometry) const;
86  bool intersects(DtFeatureGeometry) const;
87  bool overlaps(DtFeatureGeometry) const;
88  bool crosses(DtFeatureGeometry) const;
89  bool covers(DtFeatureGeometry) const;
90  bool within(DtFeatureGeometry) const;
91  bool touches(DtFeatureGeometry) const;
92  bool contains(DtFeatureGeometry) const;
93 
94  std::auto_ptr<DtFeatureGeometry::RelationshipMatrix> relate(DtFeatureGeometry) const;
95 
96  double length() const;
97 
98  double area() const;
99 
100  DtFeatureGeometry::Point centroid() const;
101 
102  double distanceTo(DtFeatureGeometry, const DtProj&) const;
103 
104  DtFeatureGeometry unionWith(DtFeatureGeometry) const;
105 
106  DtFeatureGeometry intersectionWith(DtFeatureGeometry) const;
107 
108  DtFeatureGeometry differenceWith(DtFeatureGeometry) const;
109 
110  DtFeatureGeometry buffer(double width, unsigned segments) const;
111 
112  DtFeatureGeometry convexHull() const;
113 
114  DtFeatureGeometry boundary() const;
115 
116  DtFeatureGeometry simplify(double tolerance) const;
117 
118  DtFeatureGeometry::Point closestPointTo(
119  DtFeatureGeometry, const DtProj&, double* distanceTo = 0) const;
120 
121  virtual const geos::geom::Geometry& geosGeometry() const = 0;
122  virtual const geos::geom::prep::PreparedGeometry* geosPreparedGeometry() const = 0;
123 
124  boost::shared_ptr<DtGeosGeometry> shared_from_this();
125  boost::shared_ptr<const DtGeosGeometry> shared_from_this() const;
126 
127 protected:
128  boost::optional<bool> myValidFlag;
129 };
130 
131 template <>
133 {
135 };
136 
137 template <>
139 {
140  typedef geos::geom::LineString type;
141 };
142 
143 template <>
145 {
146  typedef geos::geom::Polygon type;
147 };
148 
149 template <>
151 {
152  typedef geos::geom::GeometryCollection type;
153 };
154 
155 template <DtFeatureGeometry::Type T>
157  : public DtGeosGeometry
158  , public DtObjectDebugger< DtGeosGeometryImpl<T> >
159 {
160 public:
161 
162  typedef boost::shared_ptr<DtGeosGeometryImpl> Ptr;
163 
164  static DtGeosGeometry::Ptr Convert(const DtFeatureGeometry::Handle<T>&);
165 
166  Type type() const;
167 
168  unsigned numberOfSubGeometries() const;
169  std::auto_ptr<GeometryVector> subGeometries() const;
170 
171  const typename GeosType<T>::type& geosGeometry() const = 0;
172 };
173 
178 
179 }
180 

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)