Skip to content

Commit

Permalink
tweax
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Feb 9, 2024
1 parent 9894b6b commit 9c63c90
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
6 changes: 6 additions & 0 deletions include/geos/geom/GeometryFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ class GEOS_DLL GeometryFactory {
std::unique_ptr<MultiLineString> createMultiLineString(
std::vector<std::unique_ptr<Geometry>> && fromLines) const;

/// Construct an EMPTY MultiCurve
std::unique_ptr<MultiCurve> createMultiCurve() const;

/// Construct a MultiCurve taking ownership of given arguments
std::unique_ptr<MultiCurve> createMultiCurve(
std::vector<std::unique_ptr<Geometry>> && fromCurves) const;
Expand All @@ -213,6 +216,9 @@ class GEOS_DLL GeometryFactory {
std::unique_ptr<MultiPolygon> createMultiPolygon(
std::vector<std::unique_ptr<Geometry>> && fromPolys) const;

/// Construct an EMPTY MultiSurface
std::unique_ptr<MultiSurface> createMultiSurface() const;

/// Construct a MultiSurface taking ownership of given arguments
std::unique_ptr<MultiSurface> createMultiSurface(
std::vector<std::unique_ptr<Geometry>> && from) const;
Expand Down
2 changes: 1 addition & 1 deletion include/geos/geom/MultiCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GEOS_DLL MultiCurve : public GeometryCollection {

MultiCurve(const MultiCurve& mp)
: GeometryCollection(mp)
{};
{}

MultiCurve* cloneImpl() const override
{
Expand Down
4 changes: 4 additions & 0 deletions include/geos/geom/MultiSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <geos/geom/GeometryCollection.h>
#include <geos/geom/Surface.h>

namespace geos {
namespace geom {
Expand Down Expand Up @@ -68,6 +69,9 @@ class GEOS_DLL MultiSurface : public GeometryCollection {
MultiSurface(std::vector<std::unique_ptr<Geometry>>&& newPolys,
const GeometryFactory& newFactory);

MultiSurface(std::vector<std::unique_ptr<Surface>>&& newPolys,
const GeometryFactory& newFactory);

MultiSurface(const MultiSurface& mp)
: GeometryCollection(mp)
{};
Expand Down
13 changes: 13 additions & 0 deletions src/geom/GeometryFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ GeometryFactory::createMultiLineString(std::vector<std::unique_ptr<Geometry>> &&
return std::unique_ptr<MultiLineString>(new MultiLineString(std::move(fromLines), *this));
}

std::unique_ptr<MultiCurve>
GeometryFactory::createMultiCurve() const {
return createMultiCurve(std::vector<std::unique_ptr<Curve>>());
}

std::unique_ptr<MultiCurve>
GeometryFactory::createMultiCurve(std::vector<std::unique_ptr<Curve>> && fromCurves) const {
// Can't use make_unique because constructor is protected
Expand Down Expand Up @@ -382,6 +387,14 @@ GeometryFactory::createMultiPolygon(const std::vector<const Geometry*>& fromPoly
return createMultiPolygon(std::move(newGeoms));
}

std::unique_ptr<MultiSurface>
GeometryFactory::createMultiSurface() const
{
// Can't use make_unique because constructor is protected
return std::unique_ptr<MultiSurface>(new MultiSurface(std::vector<std::unique_ptr<Surface>>(), *this));
}


std::unique_ptr<MultiSurface>
GeometryFactory::createMultiSurface(std::vector<std::unique_ptr<Geometry>> && newSurfaces) const
{
Expand Down
5 changes: 5 additions & 0 deletions src/geom/MultiSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ MultiSurface::MultiSurface(std::vector<std::unique_ptr<Geometry>>&& newPolys, co
// FIXME check that all elements are in fact surfaces
}

MultiSurface::MultiSurface(std::vector<std::unique_ptr<Surface>>&& newPolys, const GeometryFactory& factory)
: GeometryCollection(std::move(newPolys), factory)
{
}

MultiSurface::~MultiSurface() {}

Dimension::DimensionType
Expand Down
22 changes: 2 additions & 20 deletions src/io/WKTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,6 @@ WKTReader::readCompoundCurveText(StringTokenizer* tokenizer, OrdinateSet& ordina
nextToken = getNextCloserOrComma(tokenizer);
} while (nextToken == ",");

#if 0
int type = tokenizer->peekNextToken();
if (type == '(') {
curves.push_back(readLineStringText(tokenizer, ordinateFlags));
} else {
auto component = readGeometryTaggedText(tokenizer, ordinateFlags);
if (dynamic_cast<SimpleCurve*>(component.get())) {
curves.emplace_back(static_cast<SimpleCurve*>(component.release()));
} else {
throw std::runtime_error("BAD!");
}
}
#endif

return geometryFactory->createCompoundCurve(std::move(curves));
}

Expand Down Expand Up @@ -556,11 +542,9 @@ std::unique_ptr<MultiCurve>
WKTReader::readMultiCurveText(StringTokenizer* tokenizer, OrdinateSet& ordinateFlags) const
{
std::string nextToken = getNextEmptyOrOpener(tokenizer, ordinateFlags);
#if 0
if(nextToken == "EMPTY") {
return geometryFactory->createMultiPolygon();
return geometryFactory->createMultiCurve();
}
#endif

std::vector<std::unique_ptr<Curve>> curves;
do {
Expand Down Expand Up @@ -592,11 +576,9 @@ std::unique_ptr<MultiSurface>
WKTReader::readMultiSurfaceText(StringTokenizer* tokenizer, OrdinateSet& ordinateFlags) const
{
std::string nextToken = getNextEmptyOrOpener(tokenizer, ordinateFlags);
#if 0
if(nextToken == "EMPTY") {
return geometryFactory->createMultiPolygon();
return geometryFactory->createMultiSurface();
}
#endif

std::vector<std::unique_ptr<Geometry>> surfaces;
do {
Expand Down

0 comments on commit 9c63c90

Please sign in to comment.