GEOS  3.13.0dev
GeometricShapeFactory.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: util/GeometricShapeFactory.java rev 1.14 (JTS-1.10+)
17  * (2009-03-19)
18  *
19  **********************************************************************/
20 
21 #pragma once
22 
23 #include <geos/export.h>
24 #include <cassert>
25 #include <memory>
26 
27 #include <geos/geom/Coordinate.h>
28 
29 #ifdef _MSC_VER
30 #pragma warning(push)
31 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32 #endif
33 
34 // Forward declarations
35 namespace geos {
36 namespace geom {
37 class Coordinate;
38 class Envelope;
39 class Polygon;
40 class GeometryFactory;
41 class PrecisionModel;
42 class LineString;
43 }
44 }
45 
46 namespace geos {
47 namespace util { // geos::util
48 
49 
66 class GEOS_DLL GeometricShapeFactory {
67 protected:
68  class Dimensions {
69  public:
70  Dimensions();
71  geom::CoordinateXY base;
72  geom::CoordinateXY centre;
73  double width;
74  double height;
75  void setBase(const geom::CoordinateXY& newBase);
76  void setCentre(const geom::CoordinateXY& newCentre);
77  void setSize(double size);
78  void setWidth(double nWidth);
79  void setHeight(double nHeight);
80 
81  // Return newly-allocated object, ownership transferred
82  std::unique_ptr<geom::Envelope> getEnvelope() const;
83  };
84  const geom::GeometryFactory* geomFact; // externally owned
85  const geom::PrecisionModel* precModel; // externally owned
86  Dimensions dim;
87  uint32_t nPts;
88 
89  geom::CoordinateXY coord(double x, double y) const;
90 
91 public:
92 
102 
103  virtual
105 
115  std::unique_ptr<geom::LineString> createArc(double startAng, double angExtent);
116 
128  std::unique_ptr<geom::Polygon> createArcPolygon(double startAng, double angExt);
129 
135  std::unique_ptr<geom::Polygon> createCircle();
136 
142  std::unique_ptr<geom::Polygon> createRectangle();
143 
152  void setBase(const geom::CoordinateXY& base);
153 
161  void setCentre(const geom::CoordinateXY& centre);
162 
168  void setHeight(double height);
169 
173  void setNumPoints(uint32_t nNPts);
174 
181  void setSize(double size);
182 
188  void setWidth(double width);
189 
190 };
191 
192 } // namespace geos::util
193 } // namespace geos
194 
195 #ifdef _MSC_VER
196 #pragma warning(pop)
197 #endif
198 
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:65
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
Computes various kinds of common geometric shapes.
Definition: GeometricShapeFactory.h:66
std::unique_ptr< geom::Polygon > createRectangle()
Creates a rectangular Polygon.
std::unique_ptr< geom::LineString > createArc(double startAng, double angExtent)
Creates an elliptical arc, as a LineString.
void setHeight(double height)
Sets the height of the shape.
std::unique_ptr< geom::Polygon > createCircle()
Creates a circular Polygon.
void setNumPoints(uint32_t nNPts)
Sets the total number of points in the created Geometry.
GeometricShapeFactory(const geom::GeometryFactory *factory)
Create a shape factory which will create shapes using the given GeometryFactory.
void setCentre(const geom::CoordinateXY &centre)
Sets the location of the shape by specifying the centre of the shape's bounding box.
void setWidth(double width)
Sets the width of the shape.
void setBase(const geom::CoordinateXY &base)
Sets the location of the shape by specifying the base coordinate (which in most cases is the * lower ...
std::unique_ptr< geom::Polygon > createArcPolygon(double startAng, double angExt)
Creates an elliptical arc polygon.
void setSize(double size)
Sets the size of the extent of the shape in both x and y directions.
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25