GeometricShapeFactory.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: util/GeometricShapeFactory.java rev 1.14 (JTS-1.10+)
* (2009-03-19)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <cassert>
#include <memory>
#include <geos/geom/Coordinate.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
class Envelope;
class Polygon;
class GeometryFactory;
class PrecisionModel;
class LineString;
}
}
namespace geos {
namespace util { // geos::util
class GEOS_DLL GeometricShapeFactory {
protected:
class Dimensions {
public:
Dimensions();
geom::CoordinateXY base;
geom::CoordinateXY centre;
double width;
double height;
void setBase(const geom::CoordinateXY& newBase);
void setCentre(const geom::CoordinateXY& newCentre);
void setSize(double size);
void setWidth(double nWidth);
void setHeight(double nHeight);
// Return newly-allocated object, ownership transferred
std::unique_ptr<geom::Envelope> getEnvelope() const;
};
const geom::GeometryFactory* geomFact; // externally owned
const geom::PrecisionModel* precModel; // externally owned
Dimensions dim;
uint32_t nPts;
geom::CoordinateXY coord(double x, double y) const;
public:
GeometricShapeFactory(const geom::GeometryFactory* factory);
virtual
~GeometricShapeFactory() {}
std::unique_ptr<geom::LineString> createArc(double startAng, double angExtent);
std::unique_ptr<geom::Polygon> createArcPolygon(double startAng, double angExt);
std::unique_ptr<geom::Polygon> createCircle();
std::unique_ptr<geom::Polygon> createRectangle();
void setBase(const geom::CoordinateXY& base);
void setCentre(const geom::CoordinateXY& centre);
void setHeight(double height);
void setNumPoints(uint32_t nNPts);
void setSize(double size);
void setWidth(double width);
};
} // namespace geos::util
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::LineString
Definition LineString.h:66
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geom::PrecisionModel
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
geos::util::GeometricShapeFactory::createRectangle
std::unique_ptr< geom::Polygon > createRectangle()
Creates a rectangular Polygon.
geos::util::GeometricShapeFactory::setHeight
void setHeight(double height)
Sets the height of the shape.
geos::util::GeometricShapeFactory::setNumPoints
void setNumPoints(uint32_t nNPts)
Sets the total number of points in the created Geometry.
geos::util::GeometricShapeFactory::GeometricShapeFactory
GeometricShapeFactory(const geom::GeometryFactory *factory)
Create a shape factory which will create shapes using the given GeometryFactory.
geos::util::GeometricShapeFactory::createCircle
std::unique_ptr< geom::Polygon > createCircle()
Creates a circular Polygon.
geos::util::GeometricShapeFactory::createArcPolygon
std::unique_ptr< geom::Polygon > createArcPolygon(double startAng, double angExt)
Creates an elliptical arc polygon.
geos::util::GeometricShapeFactory::setCentre
void setCentre(const geom::CoordinateXY &centre)
Sets the location of the shape by specifying the centre of the shape's bounding box.
geos::util::GeometricShapeFactory::setWidth
void setWidth(double width)
Sets the width of the shape.
geos::util::GeometricShapeFactory::createArc
std::unique_ptr< geom::LineString > createArc(double startAng, double angExtent)
Creates an elliptical arc, as a LineString.
geos::util::GeometricShapeFactory::setBase
void setBase(const geom::CoordinateXY &base)
Sets the location of the shape by specifying the base coordinate (which in most cases is the * lower ...
geos::util::GeometricShapeFactory::setSize
void setSize(double size)
Sets the size of the extent of the shape in both x and y directions.
geos::geom
Definition Angle.h:26
geos::util
Utility classes for GEOS.
Definition namespaces.h:314
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38