Skip to content

Commit b3fd3fc

Browse files
committed
Merge pull request #14 from JuliaGeo/relax-types
Relax types
2 parents afee7e8 + 3635ba2 commit b3fd3fc

File tree

9 files changed

+364
-362
lines changed

9 files changed

+364
-362
lines changed

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
julia 0.3
1+
julia 0.4
22
GeoInterface
33
BinDeps
44
@osx Homebrew
5-
Compat
65
@windows WinRPM

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
environment:
22
matrix:
3-
- JULIAVERSION: "julialang/bin/winnt/x86/0.3/julia-0.3-latest-win32.exe"
4-
- JULIAVERSION: "julialang/bin/winnt/x64/0.3/julia-0.3-latest-win64.exe"
3+
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
4+
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
55
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
66
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
77

src/geos_c.jl

Lines changed: 106 additions & 106 deletions
Large diffs are not rendered by default.

src/geos_functions.jl

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ geomToWKT(geom::Ptr{GEOSGeometry}) = bytestring(GEOSGeomToWKT(geom))
2929
# -----
3030

3131
# Create a Coordinate sequence with ``size'' coordinates of ``dims'' dimensions (Return NULL on exception)
32-
function createCoordSeq(size::Int, ndim::Int)
32+
function createCoordSeq(size::Integer, ndim::Integer)
3333
@assert ndim >= 2
34-
result = GEOSCoordSeq_create(@compat(UInt32(size)), @compat(UInt32(ndim)))
34+
result = GEOSCoordSeq_create(size, ndim)
3535
if result == C_NULL
3636
error("LibGEOS: Error in GEOSCoordSeq_create")
3737
end
@@ -56,49 +56,49 @@ function destroyCoordSeq(ptr::GEOSCoordSeq)
5656
end
5757

5858
# Set ordinate values in a Coordinate Sequence (Return 0 on exception)
59-
function setX!(ptr::GEOSCoordSeq, i::Int, value::Float64)
60-
result = GEOSCoordSeq_setX(ptr, @compat(UInt32(i-1)), value)
59+
function setX!(ptr::GEOSCoordSeq, i::Integer, value::Real)
60+
result = GEOSCoordSeq_setX(ptr, i-1, value)
6161
if result == 0
6262
error("LibGEOS: Error in GEOSCoordSeq_setX")
6363
end
6464
result
6565
end
6666

67-
function setY!(ptr::GEOSCoordSeq, i::Int, value::Float64)
68-
result = GEOSCoordSeq_setY(ptr, @compat(UInt32(i-1)), value)
67+
function setY!(ptr::GEOSCoordSeq, i::Integer, value::Real)
68+
result = GEOSCoordSeq_setY(ptr, i-1, value)
6969
if result == 0
7070
error("LibGEOS: Error in GEOSCoordSeq_setY")
7171
end
7272
result
7373
end
7474

75-
function setZ!(ptr::GEOSCoordSeq, i::Int, value::Float64)
76-
result = GEOSCoordSeq_setZ(ptr, @compat(UInt32(i-1)), value)
75+
function setZ!(ptr::GEOSCoordSeq, i::Integer, value::Real)
76+
result = GEOSCoordSeq_setZ(ptr, i-1, value)
7777
if result == 0
7878
error("LibGEOS: Error in GEOSCoordSeq_setZ")
7979
end
8080
result
8181
end
8282

8383
# Get ordinate values from a Coordinate Sequence (Return 0 on exception)
84-
function getX!(ptr::GEOSCoordSeq, index::Int, coord::Vector{Float64})
85-
result = GEOSCoordSeq_getX(ptr, @compat(UInt32(index-1)), pointer(coord))
84+
function getX!(ptr::GEOSCoordSeq, index::Integer, coord::Vector{Float64})
85+
result = GEOSCoordSeq_getX(ptr, index-1, pointer(coord))
8686
if result == 0
8787
error("LibGEOS: Error in GEOSCoordSeq_getX")
8888
end
8989
result
9090
end
9191

92-
function getY!(ptr::GEOSCoordSeq, index::Int, coord::Vector{Float64})
93-
result = GEOSCoordSeq_getY(ptr, @compat(UInt32(index-1)), pointer(coord))
92+
function getY!(ptr::GEOSCoordSeq, index::Integer, coord::Vector{Float64})
93+
result = GEOSCoordSeq_getY(ptr, index-1, pointer(coord))
9494
if result == 0
9595
error("LibGEOS: Error in GEOSCoordSeq_getY")
9696
end
9797
result
9898
end
9999

100-
function getZ!(ptr::GEOSCoordSeq, index::Int, coord::Vector{Float64})
101-
result = GEOSCoordSeq_getZ(ptr, @compat(UInt32(index-1)), pointer(coord))
100+
function getZ!(ptr::GEOSCoordSeq, index::Integer, coord::Vector{Float64})
101+
result = GEOSCoordSeq_getZ(ptr, index-1, pointer(coord))
102102
if result == 0
103103
error("LibGEOS: Error in GEOSCoordSeq_getZ")
104104
end
@@ -130,7 +130,7 @@ let out = Array(UInt32, 1)
130130
end
131131

132132
# convenience functions
133-
function setCoordSeq!(ptr::GEOSCoordSeq, i::Int, coords::Vector{Float64})
133+
function setCoordSeq!(ptr::GEOSCoordSeq, i::Integer, coords::Vector{Float64})
134134
ndim = length(coords)
135135
@assert ndim >= 2
136136
setX!(ptr, i, coords[1])
@@ -139,14 +139,14 @@ function setCoordSeq!(ptr::GEOSCoordSeq, i::Int, coords::Vector{Float64})
139139
ptr
140140
end
141141

142-
function createCoordSeq(x::Float64, y::Float64)
142+
function createCoordSeq(x::Real, y::Real)
143143
coordinates = createCoordSeq(1, 2)
144144
setX!(coordinates, 1, x)
145145
setY!(coordinates, 1, y)
146146
coordinates
147147
end
148148

149-
function createCoordSeq(x::Float64, y::Float64, z::Float64)
149+
function createCoordSeq(x::Real, y::Real, z::Real)
150150
coordinates = createCoordSeq(1, 3)
151151
setX!(coordinates, 1, x)
152152
setY!(coordinates, 1, y)
@@ -174,7 +174,7 @@ end
174174

175175
let out = Array(Float64, 1)
176176
global getX
177-
function getX(ptr::GEOSCoordSeq, i::Int)
177+
function getX(ptr::GEOSCoordSeq, i::Integer)
178178
getX!(ptr, i, out)
179179
out[1]
180180
end
@@ -186,14 +186,14 @@ function getX(ptr::GEOSCoordSeq)
186186
start = pointer(xcoords)
187187
floatsize = sizeof(Float64)
188188
for i=0:ncoords-1
189-
GEOSCoordSeq_getX(ptr, @compat(UInt32(i)), start + i*floatsize)
189+
GEOSCoordSeq_getX(ptr, i, start + i*floatsize)
190190
end
191191
xcoords
192192
end
193193

194194
let out = Array(Float64, 1)
195195
global getY
196-
function getY(ptr::GEOSCoordSeq, i::Int)
196+
function getY(ptr::GEOSCoordSeq, i::Integer)
197197
out = Array(Float64, 1)
198198
getY!(ptr, i, out)
199199
out[1]
@@ -206,14 +206,14 @@ function getY(ptr::GEOSCoordSeq)
206206
start = pointer(ycoords)
207207
floatsize = sizeof(Float64)
208208
for i=0:ncoords-1
209-
GEOSCoordSeq_getY(ptr, @compat(UInt32(i)), start + i*floatsize)
209+
GEOSCoordSeq_getY(ptr, i, start + i*floatsize)
210210
end
211211
ycoords
212212
end
213213

214214
let out = Array(Float64, 1)
215215
global getZ
216-
function getZ(ptr::GEOSCoordSeq, i::Int)
216+
function getZ(ptr::GEOSCoordSeq, i::Integer)
217217
getZ!(ptr, i, out)
218218
out[1]
219219
end
@@ -225,20 +225,20 @@ function getZ(ptr::GEOSCoordSeq)
225225
start = pointer(zcoords)
226226
floatsize = sizeof(Float64)
227227
for i=0:ncoords-1
228-
GEOSCoordSeq_getZ(ptr, @compat(UInt32(i)), start + i*floatsize)
228+
GEOSCoordSeq_getZ(ptr, i, start + i*floatsize)
229229
end
230230
zcoords
231231
end
232232

233-
function getCoordinates(ptr::GEOSCoordSeq, i::Int)
233+
function getCoordinates(ptr::GEOSCoordSeq, i::Integer)
234234
ndim = getDimensions(ptr)
235235
coord = Array(Float64, ndim)
236236
start = pointer(coord)
237237
floatsize = sizeof(Float64)
238-
GEOSCoordSeq_getX(ptr, @compat(UInt32(i-1)), start)
239-
GEOSCoordSeq_getY(ptr, @compat(UInt32(i-1)), start+floatsize)
238+
GEOSCoordSeq_getX(ptr, i-1, start)
239+
GEOSCoordSeq_getY(ptr, i-1, start+floatsize)
240240
if ndim == 3
241-
GEOSCoordSeq_getZ(ptr, @compat(UInt32(i-1)), start+2*floatsize)
241+
GEOSCoordSeq_getZ(ptr, i-1, start+2*floatsize)
242242
end
243243
coord
244244
end
@@ -262,7 +262,7 @@ end
262262
# Return distance of point 'p' projected on 'g' from origin of 'g'. Geometry 'g' must be a lineal geometry
263263
project(g::GEOSGeom, p::GEOSGeom) = GEOSProject(g, p)
264264
# Return closest point to given distance within geometry (Geometry must be a LineString)
265-
function interpolate(ptr::GEOSGeom, d::Float64)
265+
function interpolate(ptr::GEOSGeom, d::Real)
266266
result = GEOSInterpolate(ptr, d)
267267
if result == C_NULL
268268
error("LibGEOS: Error in GEOSInterpolate")
@@ -272,7 +272,7 @@ end
272272

273273
projectNormalized(g::GEOSGeom, p::GEOSGeom) = GEOSProjectNormalized(g, p)
274274

275-
function interpolateNormalized(ptr::GEOSGeom, d::Float64)
275+
function interpolateNormalized(ptr::GEOSGeom, d::Real)
276276
result = GEOSInterpolateNormalized(ptr, d)
277277
if result == C_NULL
278278
error("LibGEOS: Error in GEOSInterpolateNormalized")
@@ -288,7 +288,7 @@ end
288288
# The user can control the accuracy of the curve approximation by specifying the number of linear segments with which to approximate a curve.
289289

290290
# Always returns a polygon. The negative or zero-distance buffer of lines and points is always an empty Polygon.
291-
buffer(ptr::GEOSGeom, width::Float64, quadsegs::Int=8) = GEOSBuffer(ptr, width, @compat(Int32(quadsegs)))
291+
buffer(ptr::GEOSGeom, width::Real, quadsegs::Integer=8) = GEOSBuffer(ptr, width, @compat(Int32(quadsegs)))
292292

293293
# enum GEOSBufCapStyles
294294
# enum GEOSBufJoinStyles
@@ -316,8 +316,8 @@ function createPoint(ptr::GEOSCoordSeq)
316316
end
317317
result
318318
end
319-
createPoint(x::Float64, y::Float64) = createPoint(createCoordSeq(x,y))
320-
createPoint(x::Float64, y::Float64, z::Float64) = createPoint(createCoordSeq(x,y,z))
319+
createPoint(x::Real, y::Real) = createPoint(createCoordSeq(x,y))
320+
createPoint(x::Real, y::Real, z::Real) = createPoint(createCoordSeq(x,y,z))
321321
createPoint(coords::Vector{Vector{Float64}}) = createPoint(createCoordSeq(coords))
322322
createPoint(coords::Vector{Float64}) = createPoint(createCoordSeq(Vector{Float64}[coords]))
323323

@@ -343,24 +343,23 @@ createLineString(coords::Vector{Vector{Float64}}) = GEOSGeom_createLineString(cr
343343
# The caller remains owner of the array, but pointed-to
344344
# objects become ownership of the returned GEOSGeometry.
345345
function createPolygon(shell::GEOSGeom, holes::Vector{GEOSGeom})
346-
result = GEOSGeom_createPolygon(shell, pointer(holes), @compat(UInt32(length(holes))))
346+
result = GEOSGeom_createPolygon(shell, pointer(holes), length(holes))
347347
if result == C_NULL
348348
error("LibGEOS: Error in GEOSGeom_createPolygon")
349349
end
350350
result
351351
end
352352

353-
354-
function createCollection(geomtype::Int, geoms::Vector{GEOSGeom})
355-
result = GEOSGeom_createCollection(@compat(Int32(geomtype)), pointer(geoms), @compat(UInt32(length(geoms))))
353+
function createCollection(geomtype::Integer, geoms::Vector{GEOSGeom})
354+
result = GEOSGeom_createCollection(geomtype, pointer(geoms), length(geoms))
356355
if result == C_NULL
357356
error("LibGEOS: Error in GEOSGeom_createCollection")
358357
end
359358
result
360359
end
361360

362-
function createEmptyCollection(geomtype::Int)
363-
result = GEOSGeom_createEmptyCollection(@compat(Int32(geomtype)))
361+
function createEmptyCollection(geomtype::Integer)
362+
result = GEOSGeom_createEmptyCollection(geomtype)
364363
if result == C_NULL
365364
error("LibGEOS: Error in GEOSGeom_createEmptyCollection")
366365
end
@@ -493,15 +492,15 @@ function lineMerge(ptr::GEOSGeom)
493492
result
494493
end
495494

496-
function simplify(ptr::GEOSGeom, tol::Float64)
495+
function simplify(ptr::GEOSGeom, tol::Real)
497496
result = GEOSSimplify(ptr, tol)
498497
if result == C_NULL
499498
error("LibGEOS: Error in GEOSSimplify")
500499
end
501500
result
502501
end
503502

504-
function topologyPreserveSimplify(ptr::GEOSGeom, tol::Float64)
503+
function topologyPreserveSimplify(ptr::GEOSGeom, tol::Real)
505504
result = GEOSTopologyPreserveSimplify(ptr, tol)
506505
if result == C_NULL
507506
error("LibGEOS: Error in GEOSTopologyPreserveSimplify")
@@ -536,7 +535,7 @@ end
536535

537536
# Snap first geometry on to second with given tolerance
538537
# (Returns a newly allocated geometry, or NULL on exception)
539-
function snap(g1::GEOSGeom, g2::GEOSGeom, tol::Float64)
538+
function snap(g1::GEOSGeom, g2::GEOSGeom, tol::Real)
540539
result = GEOSSnap(g1, g2, tol)
541540
if result == C_NULL
542541
error("LibGEOS: Error in GEOSSnap")
@@ -552,7 +551,7 @@ end
552551
# return a GEOMETRYCOLLECTION containing triangular POLYGONs.
553552
#
554553
# @return a newly allocated geometry, or NULL on exception
555-
function delaunayTriangulation(ptr::GEOSGeom, tol::Float64=0.0, onlyEdges::Bool=false)
554+
function delaunayTriangulation(ptr::GEOSGeom, tol::Real=0.0, onlyEdges::Bool=false)
556555
result = GEOSDelaunayTriangulation(ptr, tol, @compat(Int32(onlyEdges)))
557556
if result == C_NULL
558557
error("LibGEOS: Error in GEOSDelaunayTriangulation")
@@ -627,7 +626,7 @@ function equals(g1::GEOSGeom, g2::GEOSGeom)
627626
result != 0x00
628627
end
629628

630-
function equalsexact(g1::GEOSGeom, g2::GEOSGeom, tol::Float64)
629+
function equalsexact(g1::GEOSGeom, g2::GEOSGeom, tol::Real)
631630
result = GEOSEqualsExact(g1, g2, tol)
632631
if result == 0x02
633632
error("LibGEOS: Error in GEOSEqualsExact")
@@ -886,8 +885,8 @@ end
886885
# it must NOT be destroyed directly.
887886
# Up to GEOS 3.2.0 the input geometry must be a Collection, in
888887
# later version it doesn't matter (i.e. getGeometryN(0) for a single will return the input).
889-
function getGeometry(ptr::GEOSGeom, n::Int)
890-
result = GEOSGetGeometryN(ptr, @compat(Int32(n-1)))
888+
function getGeometry(ptr::GEOSGeom, n::Integer)
889+
result = GEOSGetGeometryN(ptr, n-1)
891890
if result == C_NULL
892891
error("LibGEOS: Error in GEOSGetGeometryN")
893892
end
@@ -948,8 +947,8 @@ end
948947

949948
# Return NULL on exception, Geometry must be a Polygon.
950949
# Returned object is a pointer to internal storage: it must NOT be destroyed directly.
951-
function interiorRing(ptr::GEOSGeom, n::Int)
952-
result = GEOSGetInteriorRingN(ptr, @compat(Int32(n-1)))
950+
function interiorRing(ptr::GEOSGeom, n::Integer)
951+
result = GEOSGetInteriorRingN(ptr, n-1)
953952
if result == C_NULL
954953
error("LibGEOS: Error in GEOSGetInteriorRingN")
955954
end
@@ -998,11 +997,11 @@ end
998997
getGeomDimensions(ptr::GEOSGeom) = GEOSGeom_getDimensions(ptr)
999998

1000999
# Return 2 or 3.
1001-
getCoordinateDimension(ptr::GEOSGeom) = int(GEOSGeom_getCoordinateDimension(ptr))
1000+
getCoordinateDimension(ptr::GEOSGeom) = GEOSGeom_getCoordinateDimension(ptr)
10021001

10031002
# Call only on LINESTRING, and must be freed by caller (Returns NULL on exception)
1004-
function getPoint(ptr::GEOSGeom, n::Int)
1005-
result = GEOSGeomGetPointN(ptr, @compat(Int32(n-1)))
1003+
function getPoint(ptr::GEOSGeom, n::Integer)
1004+
result = GEOSGeomGetPointN(ptr, n-1)
10061005
if result == C_NULL
10071006
error("LibGEOS: Error in GEOSGeomGetPointN")
10081007
end
@@ -1080,7 +1079,7 @@ end
10801079

10811080
let out = Array(Float64, 1)
10821081
global hausdorffdistance
1083-
function hausdorffdistance(g1::GEOSGeom, g2::GEOSGeom, densifyFrac::Float64)
1082+
function hausdorffdistance(g1::GEOSGeom, g2::GEOSGeom, densifyFrac::Real)
10841083
# Return 0 on exception, 1 otherwise
10851084
result = GEOSHausdorffDistanceDensify(g1, g2, densifyFrac, pointer(out))
10861085
if result == 0

0 commit comments

Comments
 (0)