Skip to content

Commit

Permalink
Convert GeometricShapeFactory to 2D
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Nov 4, 2022
1 parent 797111f commit 2787972
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions include/geos/geom/PrecisionModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions include/geos/util/GeometricShapeFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/geom/util/SineStarFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SineStarFactory::createSineStar() const
double centreX = env->getMinX() + radius;
double centreY = env->getMinY() + radius;

std::vector<Coordinate> pts(nPts + 1);
std::vector<CoordinateXY> 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]
Expand Down
24 changes: 12 additions & 12 deletions src/util/GeometricShapeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -94,7 +94,7 @@ GeometricShapeFactory::createRectangle()
double XsegLen = env->getWidth() / nSide;
double YsegLen = env->getHeight() / nSide;

std::vector<Coordinate> vc(4 * nSide + 1);
std::vector<CoordinateXY> vc(4 * nSide + 1);

for(i = 0; i < nSide; i++) {
double x = env->getMinX() + i * XsegLen;
Expand Down Expand Up @@ -134,7 +134,7 @@ GeometricShapeFactory::createCircle()
double centreY = env->getMinY() + yRadius;
env.reset();

std::vector<Coordinate> pts(nPts + 1);
std::vector<CoordinateXY> pts(nPts + 1);
uint32_t iPt = 0;
for(uint32_t i = 0; i < nPts; i++) {
double ang = i * (2 * 3.14159265358979 / nPts);
Expand Down Expand Up @@ -166,7 +166,7 @@ GeometricShapeFactory::createArc(double startAng, double angExtent)
}
double angInc = angSize / (nPts - 1);

std::vector<Coordinate> pts(nPts);
std::vector<CoordinateXY> pts(nPts);
uint32_t iPt = 0;
for(uint32_t i = 0; i < nPts; i++) {
double ang = startAng + i * angInc;
Expand Down Expand Up @@ -196,7 +196,7 @@ GeometricShapeFactory::createArcPolygon(double startAng, double angExtent)
}
double angInc = angSize / (nPts - 1);

std::vector<Coordinate> pts(nPts + 2);
std::vector<CoordinateXY> pts(nPts + 2);
uint32_t iPt = 0;
pts[iPt++] = coord(centreX, centreY);
for(uint32_t i = 0; i < nPts; i++) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2787972

Please sign in to comment.