Skip to content

Commit 6a567e0

Browse files
committed
fixes for 0.5
1 parent ee47e81 commit 6a567e0

File tree

7 files changed

+42
-64
lines changed

7 files changed

+42
-64
lines changed

src/LibGEOS.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module LibGEOS
77
end
88

99
using Compat, GeoInterface
10+
import Base: normalize!, contains
1011

1112
export Point, MultiPoint, LineString, MultiLineString, LinearRing, Polygon, MultiPolygon, GeometryCollection,
1213
parseWKT, geomFromWKT, geomToWKT,

src/geos_functions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ GEOMTYPE = @compat Dict( GEOS_POINT => :Point,
1515
GEOS_GEOMETRYCOLLECTION => :GeometryCollection)
1616

1717

18-
function geomFromWKT(geom::ASCIIString)
18+
function geomFromWKT(geom::Compat.ASCIIString)
1919
result = GEOSGeomFromWKT(pointer(geom))
2020
if result == C_NULL
2121
error("LibGEOS: Error in GEOSGeomFromWKT")
2222
end
2323
result
2424
end
25-
geomToWKT(geom::Ptr{GEOSGeometry}) = bytestring(GEOSGeomToWKT(geom))
25+
geomToWKT(geom::Ptr{GEOSGeometry}) = Compat.unsafe_string(GEOSGeomToWKT(geom))
2626

2727
# -----
2828
# Coordinate Sequence functions

src/geos_operations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function geomFromGEOS(ptr::GEOSGeom)
2222
return GeometryCollection(ptr)
2323
end
2424
end
25-
parseWKT(geom::ASCIIString) = geomFromGEOS(geomFromWKT(geom))
25+
parseWKT(geom::Compat.ASCIIString) = geomFromGEOS(geomFromWKT(geom))
2626

2727
# -----
2828
# Linear referencing functions -- there are more, but these are probably sufficient for most purposes

test/runtests.jl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
import GeoInterface
2+
using FactCheck, LibGEOS
3+
4+
function factcheck_equals(obj1::Vector{Vector{Float64}},
5+
obj2::Vector{Vector{Float64}}; tol=1e-5)
6+
for (i,item) in enumerate(obj2)
7+
@fact obj1[i] --> roughly(item, tol)
8+
end
9+
end
10+
11+
function factcheck_equals(obj1::Vector{Vector{Vector{Float64}}},
12+
obj2::Vector{Vector{Vector{Float64}}}; tol=1e-5)
13+
for (i,item) in enumerate(obj2)
14+
factcheck_equals(obj1[i], item, tol=tol)
15+
end
16+
end
17+
18+
function factcheck_equals(obj1::Vector{Vector{Vector{Vector{Float64}}}},
19+
obj2::Vector{Vector{Vector{Vector{Float64}}}}; tol=1e-5)
20+
for (i,item) in enumerate(obj2)
21+
factcheck_equals(obj1[i], item, tol=tol)
22+
end
23+
end
24+
125
include("test_geos_functions.jl")
226
include("test_geos_operations.jl")
3-
include("test_geo_interface.jl")
27+
include("test_geo_interface.jl")

test/test_geo_interface.jl

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
import LibGEOS, GeoInterface
2-
using FactCheck
3-
4-
function factcheck_equals(obj1::Vector{Vector{Float64}},
5-
obj2::Vector{Vector{Float64}}; tol=1e-5)
6-
for (i,item) in enumerate(obj2)
7-
@fact obj1[i] --> roughly(item, tol)
8-
end
9-
end
10-
11-
function factcheck_equals(obj1::Vector{Vector{Vector{Float64}}},
12-
obj2::Vector{Vector{Vector{Float64}}}; tol=1e-5)
13-
for (i,item) in enumerate(obj2)
14-
factcheck_equals(obj1[i], item, tol=tol)
15-
end
16-
end
17-
18-
function factcheck_equals(obj1::Vector{Vector{Vector{Vector{Float64}}}},
19-
obj2::Vector{Vector{Vector{Vector{Float64}}}}; tol=1e-5)
20-
for (i,item) in enumerate(obj2)
21-
factcheck_equals(obj1[i], item, tol=tol)
22-
end
23-
end
241

252
pt = LibGEOS.Point(1.0,2.0)
263
@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5)

test/test_geos_functions.jl

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
using LibGEOS, FactCheck
2-
3-
function factcheck_equals(obj1::Vector{Vector{Float64}},
4-
obj2::Vector{Vector{Float64}}; tol=1e-5)
5-
for (i,item) in enumerate(obj2)
6-
@fact obj1[i] --> roughly(item, tol)
7-
end
8-
end
9-
10-
function factcheck_equals(obj1::Vector{Vector{Vector{Float64}}},
11-
obj2::Vector{Vector{Vector{Float64}}}; tol=1e-5)
12-
for (i,item) in enumerate(obj2)
13-
factcheck_equals(obj1[i], item, tol=tol)
14-
end
15-
end
16-
17-
function factcheck_equals(obj1::Vector{Vector{Vector{Vector{Float64}}}},
18-
obj2::Vector{Vector{Vector{Vector{Float64}}}}; tol=1e-5)
19-
for (i,item) in enumerate(obj2)
20-
factcheck_equals(obj1[i], item, tol=tol)
21-
end
22-
end
231

242
a = LibGEOS.createCoordSeq(Vector{Float64}[[1,2,3],[4,5,6]])
253
b = LibGEOS.cloneCoordSeq(a)

test/test_geos_operations.jl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
using LibGEOS, FactCheck
2-
import GeoInterface
3-
4-
function equivalent_to_wkt(geom::GeoInterface.AbstractGeometry, wkt::ASCIIString)
1+
function equivalent_to_wkt(geom::GeoInterface.AbstractGeometry, wkt::Compat.ASCIIString)
52
test_geom = parseWKT(wkt)
63
@fact geomToWKT(geom) --> geomToWKT(test_geom)
74
end
85

9-
function factcheck(f::Function, geom::ASCIIString, expected::ASCIIString)
6+
function factcheck(f::Function, geom::Compat.ASCIIString, expected::Compat.ASCIIString)
107
result = f(parseWKT(geom))
118
equivalent_to_wkt(result, expected)
129
end
1310

14-
function factcheck(f::Function, geom::ASCIIString, expected::Bool)
11+
function factcheck(f::Function, geom::Compat.ASCIIString, expected::Bool)
1512
@fact f(parseWKT(geom)) --> expected
1613
end
1714

18-
function factcheck(f::Function, g1::ASCIIString, g2::ASCIIString, expected::ASCIIString)
15+
function factcheck(f::Function, g1::Compat.ASCIIString, g2::Compat.ASCIIString, expected::Compat.ASCIIString)
1916
result = f(parseWKT(g1),parseWKT(g2))
2017
equivalent_to_wkt(result, expected)
2118
end
2219

23-
function factcheck(f::Function, g1::ASCIIString, g2::ASCIIString, expected::Bool)
20+
function factcheck(f::Function, g1::Compat.ASCIIString, g2::Compat.ASCIIString, expected::Bool)
2421
@fact f(parseWKT(g1),parseWKT(g2)) --> expected
2522
end
2623

@@ -52,6 +49,7 @@ g2 = parseWKT("POLYGON((1 1,1 2,2 2,2 1,1 1))")
5249
@fact LibGEOS.contains(g1, g2) --> true
5350
@fact LibGEOS.contains(g1, g2) --> false
5451

52+
5553
# GEOSConvexHullTest
5654
input = parseWKT("MULTIPOINT (130 240, 130 240, 130 240, 570 240, 570 240, 570 240, 650 240)")
5755
expected = parseWKT("LINESTRING (130 240, 650 240)")
@@ -100,14 +98,14 @@ g1 = parseWKT("GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2,
10098
@fact LibGEOS.equals(uniquePoints(g1), parseWKT("MULTIPOINT(0 0, 1 1, 2 2, 5 5, 0 2)")) --> true
10199

102100
# GEOSGetCentroidTest
103-
test_centroid(geom::ASCIIString, expected::ASCIIString) = factcheck(centroid, geom, expected)
101+
test_centroid(geom::Compat.ASCIIString, expected::Compat.ASCIIString) = factcheck(centroid, geom, expected)
104102
test_centroid("POINT(10 0)", "POINT (10 0)")
105103
test_centroid("LINESTRING(0 0, 10 0)", "POINT (5 0)")
106104
test_centroid("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", "POINT (5 5)")
107105
test_centroid("LINESTRING EMPTY", "POINT EMPTY")
108106

109107
# GEOSIntersectionTest
110-
test_intersection(g1::ASCIIString, g2::ASCIIString, expected::ASCIIString) = factcheck(intersection, g1, g2, expected)
108+
test_intersection(g1::Compat.ASCIIString, g2::Compat.ASCIIString, expected::Compat.ASCIIString) = factcheck(intersection, g1, g2, expected)
111109
test_intersection("POLYGON EMPTY", "POLYGON EMPTY", "GEOMETRYCOLLECTION EMPTY")
112110
test_intersection("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", "POINT(2 2)")
113111
test_intersection("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "POLYGON((-1 1,-1 2,2 2,2 1,-1 1))", "POLYGON ((0 1, 0 2, 2 2, 2 1, 0 1))")
@@ -116,7 +114,7 @@ test_intersection("MULTIPOLYGON(((0 0,5 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1),(100
116114
"GEOMETRYCOLLECTION (LINESTRING (1 2, 2 2), LINESTRING (2 1, 1 1), POLYGON ((0.5 1, 1 2, 1 1, 0.5 1)), POLYGON ((9 2, 9.5 1, 2 1, 2 2, 9 2)))")
117115

118116
# GEOSIntersectsTest
119-
test_intersects(g1::ASCIIString, g2::ASCIIString, expected::Bool) = factcheck(intersects, g1, g2, false)
117+
test_intersects(g1::Compat.ASCIIString, g2::Compat.ASCIIString, expected::Bool) = factcheck(intersects, g1, g2, false)
120118
test_intersects("POLYGON EMPTY", "POLYGON EMPTY", false)
121119
test_intersects("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", true)
122120
test_intersects("POINT(2 2)", "POLYGON((1 1,1 5,5 5,5 1,1 1))", true)
@@ -158,7 +156,7 @@ LibGEOS.normalize!(g1)
158156
equivalent_to_wkt(g1, "MULTILINESTRING ((2 0, 4 0), (0 0, 2 0))")
159157

160158
# GEOSPointOnSurfaceTest
161-
test_pointonsurface(geom::ASCIIString, expected::ASCIIString) = factcheck(pointOnSurface, geom, expected)
159+
test_pointonsurface(geom::Compat.ASCIIString, expected::Compat.ASCIIString) = factcheck(pointOnSurface, geom, expected)
162160
test_pointonsurface("POINT(10 0)", "POINT (10 0)")
163161
test_pointonsurface("LINESTRING(0 0, 5 0, 10 0)", "POINT (5 0)")
164162
test_pointonsurface("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", "POINT (5 5)")
@@ -194,7 +192,7 @@ equivalent_to_wkt(simplify(g1, 0.0), "POLYGON EMPTY")
194192
@fact equals(g1, topologyPreserveSimplify(g1, 43.2)) --> true
195193

196194
# GEOSSnapTest
197-
function test_snap(g1::ASCIIString, g2::ASCIIString, expected::ASCIIString, tol::Float64=0.0)
195+
function test_snap(g1::Compat.ASCIIString, g2::Compat.ASCIIString, expected::Compat.ASCIIString, tol::Float64=0.0)
198196
equivalent_to_wkt(snap(parseWKT(g1), parseWKT(g2), tol), expected)
199197
end
200198
test_snap("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))", "POINT(0.5 0)",
@@ -219,7 +217,7 @@ test_snap("LINESTRING(-71.1317 42.2511,-71.1317 42.2509)", "MULTIPOINT(-71.1261
219217
"LINESTRING (-71.1257 42.2703, -71.1261 42.2703, -71.1261 42.2702, -71.1317 42.2509)", .5)
220218

221219
# GEOSUnaryUnionTest
222-
test_unaryunion(geom::ASCIIString, expected::ASCIIString) = factcheck(unaryUnion, geom, expected)
220+
test_unaryunion(geom::Compat.ASCIIString, expected::Compat.ASCIIString) = factcheck(unaryUnion, geom, expected)
223221
test_unaryunion("POINT EMPTY", "GEOMETRYCOLLECTION EMPTY")
224222
test_unaryunion("POINT (6 3)", "POINT (6 3)")
225223
test_unaryunion("POINT (4 5 6)", "POINT Z (4 5 6)")
@@ -234,7 +232,7 @@ test_unaryunion("GEOMETRYCOLLECTION (MULTILINESTRING((5 7, 12 7), (4 5, 6 5), (5
234232
"GEOMETRYCOLLECTION (POINT (6 6.5), POINT (12 2), LINESTRING (5 7, 7 7), LINESTRING (10 7, 12 7), LINESTRING (5.5 7.5, 6.5 7.5), POLYGON ((10 7, 10 0, 0 0, 0 10, 10 10, 10 7), (5 6, 7 6, 7 7, 7 8, 5 8, 5 7, 5 6)))")
235233

236234
# GEOSWithinTest
237-
test_within(g1::ASCIIString, g2::ASCIIString, expected::Bool) = factcheck(within, g1, g2, expected)
235+
test_within(g1::Compat.ASCIIString, g2::Compat.ASCIIString, expected::Bool) = factcheck(within, g1, g2, expected)
238236
test_within("POLYGON EMPTY", "POLYGON EMPTY", false)
239237
test_within("POLYGON((1 1,1 5,5 5,5 1,1 1))", "POINT(2 2)", false)
240238
test_within("POINT(2 2)", "POLYGON((1 1,1 5,5 5,5 1,1 1))", true)

0 commit comments

Comments
 (0)