Skip to content

Commit 63513b7

Browse files
committed
Update to GEOS 3.9.1
1 parent bf897b9 commit 63513b7

File tree

16 files changed

+83
-310
lines changed

16 files changed

+83
-310
lines changed

Sources/geos/capi/geos_ts_c.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,22 +2408,31 @@ extern "C" {
24082408
//assert(0 != holes);
24092409

24102410
return execute(extHandle, [&]() {
2411-
auto vholes = geos::detail::make_unique<std::vector<LinearRing*>>(nholes);
24122411

2412+
std::vector<LinearRing*> tmpholes(nholes);
24132413
for (size_t i = 0; i < nholes; i++) {
2414-
(*vholes)[i] = dynamic_cast<LinearRing*>(holes[i]);
2415-
if ((*vholes)[i] == nullptr) {
2414+
LinearRing* lr = dynamic_cast<LinearRing*>(holes[i]);
2415+
if (! lr) {
24162416
throw IllegalArgumentException("Hole is not a LinearRing");
24172417
}
2418+
tmpholes[i] = lr;
24182419
}
2419-
24202420
LinearRing* nshell = dynamic_cast<LinearRing*>(shell);
24212421
if(! nshell) {
24222422
throw IllegalArgumentException("Shell is not a LinearRing");
24232423
}
2424-
const GeometryFactory* gf = shell->getFactory();
2424+
GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2425+
const GeometryFactory* gf = handle->geomFactory;
2426+
2427+
/* Create unique_ptr version for constructor */
2428+
std::vector<std::unique_ptr<LinearRing>> vholes;
2429+
vholes.reserve(nholes);
2430+
for (LinearRing* lr: tmpholes) {
2431+
vholes.emplace_back(lr);
2432+
}
2433+
std::unique_ptr<LinearRing> shell(nshell);
24252434

2426-
return gf->createPolygon(nshell, vholes.release());
2435+
return gf->createPolygon(std::move(shell), std::move(vholes)).release();
24272436
});
24282437
}
24292438

Sources/geos/include/acconfig.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

Sources/geos/include/geos/algorithm/Orientation.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,32 @@ class GEOS_DLL Orientation {
8989
*/
9090
static bool isCCW(const geom::CoordinateSequence* ring);
9191

92+
/**
93+
* Tests if a ring defined by a CoordinateSequence is
94+
* oriented counter-clockwise, using the signed area of the ring.
95+
*
96+
* * The list of points is assumed to have the first and last points equal.
97+
* * This handles coordinate lists which contain repeated points.
98+
* * This handles rings which contain collapsed segments
99+
* (in particular, along the top of the ring).
100+
* * This handles rings which are invalid due to self-intersection
101+
*
102+
* This algorithm is guaranteed to work with valid rings.
103+
* For invalid rings (containing self-intersections),
104+
* the algorithm determines the orientation of
105+
* the largest enclosed area (including overlaps).
106+
* This provides a more useful result in some situations, such as buffering.
107+
*
108+
* However, this approach may be less accurate in the case of
109+
* rings with almost zero area.
110+
* (Note that the orientation of rings with zero area is essentially
111+
* undefined, and hence non-deterministic.)
112+
*
113+
* @param ring a CoordinateSequence forming a ring (with first and last point identical)
114+
* @return true if the ring is oriented counter-clockwise.
115+
*/
116+
static bool isCCWArea(const geom::CoordinateSequence* ring);
117+
92118
};
93119

94120

Sources/geos/include/geos/algorithm/PointInRing.h

Lines changed: 0 additions & 43 deletions
This file was deleted.

Sources/geos/include/geos/algorithm/SimplePointInRing.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

Sources/geos/include/geos/operation/overlayng/EdgeMerger.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,23 @@ namespace overlayng { // geos.operation.overlayng
5959
* This ensures that the overlay output line direction will be as consistent
6060
* as possible with input lines.
6161
*
62+
* The merger also preserves the order of the edges in the input.
63+
* This means that for polygon-line overlay
64+
* the result lines will be in the same order as in the input
65+
* (possibly with multiple result lines for a single input line).
66+
*
6267
* @author mdavis
6368
*
6469
*/
6570
class GEOS_DLL EdgeMerger {
6671

67-
private:
68-
69-
70-
// Members
71-
std::vector<Edge*>& edges;
72-
std::map<EdgeKey, Edge*> edgeMap;
73-
7472
public:
7573

76-
// Methods
77-
EdgeMerger(std::vector<Edge*>& p_edges);
78-
7974
static std::vector<Edge*> merge(std::vector<Edge*>& edges);
8075

81-
std::vector<Edge*> merge();
82-
83-
8476
};
8577

8678

8779
} // namespace geos.operation.overlayng
8880
} // namespace geos.operation
8981
} // namespace geos
90-

Sources/geos/include/geos/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#endif
2424

2525
#ifndef GEOS_VERSION_PATCH
26-
#define GEOS_VERSION_PATCH 0
26+
#define GEOS_VERSION_PATCH 1
2727
#endif
2828

2929
#ifndef GEOS_VERSION
30-
#define GEOS_VERSION "3.9.0"
30+
#define GEOS_VERSION "3.9.1"
3131
#endif
3232

3333
#ifndef GEOS_JTS_PORT

Sources/geos/public/geos_c.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ extern "C" {
6060
#define GEOS_VERSION_MINOR 9
6161
#endif
6262
#ifndef GEOS_VERSION_PATCH
63-
#define GEOS_VERSION_PATCH 0
63+
#define GEOS_VERSION_PATCH 1
6464
#endif
6565
#ifndef GEOS_VERSION
66-
#define GEOS_VERSION "3.9.0"
66+
#define GEOS_VERSION "3.9.1"
6767
#endif
6868
#ifndef GEOS_JTS_PORT
6969
#define GEOS_JTS_PORT "1.17.0"
7070
#endif
7171

7272
#define GEOS_CAPI_VERSION_MAJOR 1
7373
#define GEOS_CAPI_VERSION_MINOR 14
74-
#define GEOS_CAPI_VERSION_PATCH 1
75-
#define GEOS_CAPI_VERSION "3.9.0-CAPI-1.14.1"
74+
#define GEOS_CAPI_VERSION_PATCH 2
75+
#define GEOS_CAPI_VERSION "3.9.1-CAPI-1.14.2"
7676

7777
#define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
7878
#define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)

Sources/geos/src/algorithm/Orientation.cpp

Lines changed: 3 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cmath>
2121
#include <vector>
2222

23+
#include <geos/algorithm/Area.h>
2324
#include <geos/algorithm/Orientation.h>
2425
#include <geos/algorithm/CGAlgorithmsDD.h>
2526
#include <geos/geom/CoordinateSequence.h>
@@ -134,92 +135,12 @@ Orientation::isCCW(const geom::CoordinateSequence* ring)
134135
}
135136
}
136137

137-
#if 0
138138
/* public static */
139139
bool
140-
Orientation::isCCW(const geom::CoordinateSequence* ring)
140+
Orientation::isCCWArea(const geom::CoordinateSequence* ring)
141141
{
142-
// sanity check
143-
if(ring->getSize() < 4) {
144-
throw util::IllegalArgumentException("Ring has fewer than 4 points, so orientation cannot be determined");
145-
}
146-
147-
// # of points without closing endpoint
148-
const std::size_t nPts = ring->getSize() - 1;
149-
assert(nPts >= 3); // This is here for scan-build
150-
151-
// find highest point
152-
const geom::Coordinate* hiPt = &ring->getAt(0);
153-
size_t hiIndex = 0;
154-
for(std::size_t i = 1; i <= nPts; ++i) {
155-
const geom::Coordinate* p = &ring->getAt(i);
156-
if(p->y > hiPt->y) {
157-
hiPt = p;
158-
hiIndex = i;
159-
}
160-
}
161-
162-
// find distinct point before highest point
163-
auto iPrev = hiIndex;
164-
do {
165-
if(iPrev == 0) {
166-
iPrev = nPts;
167-
}
168-
iPrev = iPrev - 1;
169-
}
170-
while(ring->getAt(iPrev) == *hiPt && iPrev != hiIndex);
171-
172-
// find distinct point after highest point
173-
auto iNext = hiIndex;
174-
do {
175-
iNext = (iNext + 1) % nPts;
176-
}
177-
while(ring->getAt(iNext) == *hiPt && iNext != hiIndex);
178-
179-
const geom::Coordinate* prev = &ring->getAt(iPrev);
180-
const geom::Coordinate* next = &ring->getAt(iNext);
181-
182-
/*
183-
* This check catches cases where the ring contains an A-B-A
184-
* configuration of points.
185-
* This can happen if the ring does not contain 3 distinct points
186-
* (including the case where the input array has fewer than 4 elements),
187-
* or it contains coincident line segments.
188-
*/
189-
if(prev->equals2D(*hiPt) || next->equals2D(*hiPt) ||
190-
prev->equals2D(*next)) {
191-
return false;
192-
// MD - don't bother throwing exception,
193-
// since this isn't a complete check for ring validity
194-
//throw IllegalArgumentException("degenerate ring (does not contain 3 distinct points)");
195-
}
196-
197-
int disc = Orientation::index(*prev, *hiPt, *next);
198-
199-
/*
200-
* If disc is exactly 0, lines are collinear.
201-
* There are two possible cases:
202-
* (1) the lines lie along the x axis in opposite directions
203-
* (2) the lines lie on top of one another
204-
*
205-
* (1) is handled by checking if next is left of prev ==> CCW
206-
* (2) should never happen, so we're going to ignore it!
207-
* (Might want to assert this)
208-
*/
209-
bool isCCW = false;
210-
211-
if(disc == 0) {
212-
// poly is CCW if prev x is right of next x
213-
isCCW = (prev->x > next->x);
214-
}
215-
else {
216-
// if area is positive, points are ordered CCW
217-
isCCW = (disc > 0);
218-
}
219-
220-
return isCCW;
142+
return algorithm::Area::ofRingSigned(ring) < 0;
221143
}
222-
#endif
223144

224145

225146
} // namespace geos.algorithm

0 commit comments

Comments
 (0)