Skip to content

Commit b0f9c42

Browse files
evetionvisr
authored andcommitted
Added isCCW function.
1 parent 353220e commit b0f9c42

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LibGEOS"
22
uuid = "a90b1aa1-3769-5649-ba7e-abc5a9d163eb"
33
license = "MIT"
4-
version = "0.6.10"
4+
version = "0.6.11"
55

66
[deps]
77
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

src/geos_functions.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ function getCoordinates(ptr::GEOSCoordSeq, context::GEOSContext = _context)
271271
coordseq
272272
end
273273

274+
function isCCW(ptr::GEOSCoordSeq, context::GEOSContext=_context)::Bool
275+
d = UInt8[1]
276+
GC.@preserve result = GEOSCoordSeq_isCCW_r(context.ptr, ptr, pointer(d))
277+
if result == C_NULL
278+
error("LibGEOS: Error in GEOSInterpolateNormalized")
279+
end
280+
Bool(d[1])
281+
end
282+
274283
# -----
275284
# Linear referencing functions -- there are more, but these are probably sufficient for most purposes
276285
# -----

test/test_geos_functions.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ end
5252
c = LibGEOS.createPoint(LibGEOS.createCoordSeq(Vector{Float64}[[1, 2]]))
5353
@test LibGEOS.getCoordinates(LibGEOS.getCoordSeq(c))[1] [1, 2] atol = 1e-5
5454

55+
# isCCW
56+
seq = Vector{Float64}[[-1, 0], [0, 0], [10, 0], [10, 10], [0, 10], [-1, 0]]
57+
a = LibGEOS.createCoordSeq(seq)
58+
@test LibGEOS.isCCW(a)
59+
a = LibGEOS.createCoordSeq(reverse(seq))
60+
@test !LibGEOS.isCCW(a)
61+
5562
# Polygons and Holes
5663
shell = LibGEOS.createLinearRing(
5764
Vector{Float64}[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]],

0 commit comments

Comments
 (0)