From 27879724035289ce82adf86d8e6c5605a608559d Mon Sep 17 00:00:00 2001 From: Daniel Baston Date: Wed, 2 Nov 2022 16:54:56 -0400 Subject: [PATCH] Convert GeometricShapeFactory to 2D --- include/geos/geom/PrecisionModel.h | 4 ++-- include/geos/util/GeometricShapeFactory.h | 14 ++++++------- src/geom/util/SineStarFactory.cpp | 2 +- src/util/GeometricShapeFactory.cpp | 24 +++++++++++------------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/geos/geom/PrecisionModel.h b/include/geos/geom/PrecisionModel.h index 6305f6c047..e6732fa9d4 100644 --- a/include/geos/geom/PrecisionModel.h +++ b/include/geos/geom/PrecisionModel.h @@ -183,7 +183,7 @@ class GEOS_DLL PrecisionModel { double makePrecise(double val) const; /// Rounds the given Coordinate to the PrecisionModel grid. - void makePrecise(Coordinate& coord) const + void makePrecise(CoordinateXY& coord) const { // optimization for full precision if(modelType == FLOATING) { @@ -194,7 +194,7 @@ class GEOS_DLL PrecisionModel { coord.y = makePrecise(coord.y); }; - void makePrecise(Coordinate* coord) const + void makePrecise(CoordinateXY* coord) const { assert(coord); return makePrecise(*coord); diff --git a/include/geos/util/GeometricShapeFactory.h b/include/geos/util/GeometricShapeFactory.h index 2cc54707fb..99146e1612 100644 --- a/include/geos/util/GeometricShapeFactory.h +++ b/include/geos/util/GeometricShapeFactory.h @@ -68,12 +68,12 @@ class GEOS_DLL GeometricShapeFactory { class Dimensions { public: Dimensions(); - geom::Coordinate base; - geom::Coordinate centre; + geom::CoordinateXY base; + geom::CoordinateXY centre; double width; double height; - void setBase(const geom::Coordinate& newBase); - void setCentre(const geom::Coordinate& newCentre); + void setBase(const geom::CoordinateXY& newBase); + void setCentre(const geom::CoordinateXY& newCentre); void setSize(double size); void setWidth(double nWidth); void setHeight(double nHeight); @@ -86,7 +86,7 @@ class GEOS_DLL GeometricShapeFactory { Dimensions dim; uint32_t nPts; - geom::Coordinate coord(double x, double y) const; + geom::CoordinateXY coord(double x, double y) const; public: @@ -149,7 +149,7 @@ class GEOS_DLL GeometricShapeFactory { * * @param base the base coordinate of the shape */ - void setBase(const geom::Coordinate& base); + void setBase(const geom::CoordinateXY& base); /** * \brief @@ -158,7 +158,7 @@ class GEOS_DLL GeometricShapeFactory { * * @param centre the centre coordinate of the shape */ - void setCentre(const geom::Coordinate& centre); + void setCentre(const geom::CoordinateXY& centre); /** * \brief Sets the height of the shape. diff --git a/src/geom/util/SineStarFactory.cpp b/src/geom/util/SineStarFactory.cpp index dfa37ce23e..84a723cece 100644 --- a/src/geom/util/SineStarFactory.cpp +++ b/src/geom/util/SineStarFactory.cpp @@ -56,7 +56,7 @@ SineStarFactory::createSineStar() const double centreX = env->getMinX() + radius; double centreY = env->getMinY() + radius; - std::vector pts(nPts + 1); + std::vector pts(nPts + 1); uint32_t iPt = 0; for(uint32_t i = 0; i < nPts; i++) { // the fraction of the way thru the current arm - in [0,1] diff --git a/src/util/GeometricShapeFactory.cpp b/src/util/GeometricShapeFactory.cpp index 3f04ee4434..e387334cbc 100644 --- a/src/util/GeometricShapeFactory.cpp +++ b/src/util/GeometricShapeFactory.cpp @@ -46,13 +46,13 @@ GeometricShapeFactory::GeometricShapeFactory(const GeometryFactory* factory) } void -GeometricShapeFactory::setBase(const Coordinate& base) +GeometricShapeFactory::setBase(const CoordinateXY& base) { dim.setBase(base); } void -GeometricShapeFactory::setCentre(const Coordinate& centre) +GeometricShapeFactory::setCentre(const CoordinateXY& centre) { dim.setCentre(centre); } @@ -94,7 +94,7 @@ GeometricShapeFactory::createRectangle() double XsegLen = env->getWidth() / nSide; double YsegLen = env->getHeight() / nSide; - std::vector vc(4 * nSide + 1); + std::vector vc(4 * nSide + 1); for(i = 0; i < nSide; i++) { double x = env->getMinX() + i * XsegLen; @@ -134,7 +134,7 @@ GeometricShapeFactory::createCircle() double centreY = env->getMinY() + yRadius; env.reset(); - std::vector pts(nPts + 1); + std::vector pts(nPts + 1); uint32_t iPt = 0; for(uint32_t i = 0; i < nPts; i++) { double ang = i * (2 * 3.14159265358979 / nPts); @@ -166,7 +166,7 @@ GeometricShapeFactory::createArc(double startAng, double angExtent) } double angInc = angSize / (nPts - 1); - std::vector pts(nPts); + std::vector pts(nPts); uint32_t iPt = 0; for(uint32_t i = 0; i < nPts; i++) { double ang = startAng + i * angInc; @@ -196,7 +196,7 @@ GeometricShapeFactory::createArcPolygon(double startAng, double angExtent) } double angInc = angSize / (nPts - 1); - std::vector pts(nPts + 2); + std::vector pts(nPts + 2); uint32_t iPt = 0; pts[iPt++] = coord(centreX, centreY); for(uint32_t i = 0; i < nPts; i++) { @@ -215,19 +215,19 @@ GeometricShapeFactory::createArcPolygon(double startAng, double angExtent) GeometricShapeFactory::Dimensions::Dimensions() : - base(Coordinate::getNull()), - centre(Coordinate::getNull()) + base(CoordinateXY::getNull()), + centre(CoordinateXY::getNull()) { } void -GeometricShapeFactory::Dimensions::setBase(const Coordinate& newBase) +GeometricShapeFactory::Dimensions::setBase(const CoordinateXY& newBase) { base = newBase; } void -GeometricShapeFactory::Dimensions::setCentre(const Coordinate& newCentre) +GeometricShapeFactory::Dimensions::setCentre(const CoordinateXY& newCentre) { centre = newCentre; } @@ -264,10 +264,10 @@ GeometricShapeFactory::Dimensions::getEnvelope() const } /*protected*/ -Coordinate +CoordinateXY GeometricShapeFactory::coord(double x, double y) const { - Coordinate ret(x, y); + CoordinateXY ret(x, y); precModel->makePrecise(&ret); return ret; }