Skip to content

Commit 0e42c2b

Browse files
authored
enable some tests (#175)
* enable some tests * curl only seems to be working properly on 1.6+
1 parent 6b1b72f commit 0e42c2b

File tree

6 files changed

+48
-58
lines changed

6 files changed

+48
-58
lines changed

test/test_fielddefn.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ end
7171
AG.setspatialref!(gfd, AG.importEPSG(4326))
7272
@test sprint(print, AG.getspatialref(gfd)) == "Spatial Reference System: +proj=longlat +datum=WGS84 +no_defs"
7373
AG.getspatialref(gfd) do spref
74-
if !Sys.iswindows()
75-
@test sprint(print, spref) == "Spatial Reference System: +proj=longlat +datum=WGS84 +no_defs"
76-
# NOTE(yeesian): we get the following error on x86 in Appveyor
77-
# Expression: sprint(print, spref) == "Spatial Reference System: +proj=longlat +datum=WGS84 +no_defs "
78-
# GDALError (CE_Failure, code 6):
79-
# No translation for an empty SRS to PROJ.4 format is known.
80-
end
74+
@test sprint(print, spref) == "Spatial Reference System: +proj=longlat +datum=WGS84 +no_defs"
8175
end
8276

8377
@test AG.isignored(gfd) == false

test/test_gdal_tutorials.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import GDAL
33
import ArchGDAL; const AG = ArchGDAL
44

55
@testset "Raster Tutorial" begin
6+
driver = AG.getdriver("GTiff")
7+
68
AG.read("data/utmsmall.tif") do dataset
7-
driver = AG.getdriver("GTiff")
89
@test AG.shortname(driver) == "GTiff"
910
@test AG.longname(driver) == "GeoTIFF"
1011
@test AG.width(dataset) == 100
@@ -56,8 +57,8 @@ import ArchGDAL; const AG = ArchGDAL
5657
end
5758

5859
# Techniques for Creating Files
59-
#@test GDAL.getmetadataitem(driver, "DCAP_CREATE", "") == "YES"
60-
#@test GDAL.getmetadataitem(driver, "DCAP_CREATECOPY", "") == "YES"
60+
@test GDAL.gdalgetmetadataitem(driver.ptr, "DCAP_CREATE", "") == "YES"
61+
@test GDAL.gdalgetmetadataitem(driver.ptr, "DCAP_CREATECOPY", "") == "YES"
6162

6263
AG.read("data/utmsmall.tif") do ds_src
6364
AG.write(ds_src, "/vsimem/utmsmall.tif")
@@ -72,8 +73,8 @@ end
7273
@test AG.nlayer(dataset) == 1
7374
layer = AG.getlayer(dataset, 0)
7475
@test (AG.getname(layer) in ["point", "OGRGeoJSON"]) == true
75-
# layerbyname = AG.getlayer(dataset, "point")
76-
# @test layerbyname.ptr == layer.ptr
76+
layerbyname = AG.getlayer(dataset, "point")
77+
@test layerbyname.ptr == layer.ptr
7778
AG.resetreading!(layer)
7879

7980
featuredefn = AG.layerdefn(layer)

test/test_gdalutilities.jl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,14 @@ AG.read("data/utmsmall.tif") do ds_small
6060
end
6161
end
6262

63-
# cannot reproject file on AppVeyor yet
64-
# GDALError (CE_Failure, code 4):
65-
# Unable to open EPSG support file gcs.csv. Try setting the
66-
# GDAL_DATA environment variable to point to the directory
67-
# containing EPSG csv files.
68-
# @testset "GDAL Warp" begin
69-
# AG.gdalwarp([ds_small], ["-of","MEM","-t_srs","EPSG:4326"]) do ds_warped
70-
# @test AG.width(ds_small) == 100
71-
# @test AG.height(ds_small) == 100
72-
# @test AG.width(ds_warped) == 109
73-
# @test AG.height(ds_warped) == 91
74-
# end
75-
# end
63+
@testset "GDAL Warp" begin
64+
AG.gdalwarp([ds_small], ["-of","MEM","-t_srs","EPSG:4326"]) do ds_warped
65+
@test AG.width(ds_small) == 100
66+
@test AG.height(ds_small) == 100
67+
@test AG.width(ds_warped) == 109
68+
@test AG.height(ds_warped) == 91
69+
end
70+
end
7671
@testset "GDAL Warp" begin
7772
AG.gdalwarp([ds_small], ["-of","MEM"]) do ds_warped
7873
@test AG.width(ds_small) == 100

test/test_geos_operations.jl

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,24 @@ function test_method(f::Function, wkt1::AbstractString,
131131
end
132132
end
133133

134-
# TODO: fix #47
135-
# @testset "Intersection" begin
136-
# test_method(AG.intersection,
137-
# "POLYGON EMPTY",
138-
# "POLYGON EMPTY",
139-
# "GEOMETRYCOLLECTION EMPTY")
140-
# test_method(AG.intersection,
141-
# "POLYGON((1 1,1 5,5 5,5 1,1 1))",
142-
# "POINT(2 2)",
143-
# "POINT (2 2)")
144-
# test_method(AG.intersection,
145-
# "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
146-
# "POLYGON((-1 1,-1 2,2 2,2 1,-1 1))",
147-
# "POLYGON ((0 1,0 2,2 2,2 1,0 1))")
148-
# test_method(AG.intersection,
149-
# "MULTIPOLYGON(((0 0,5 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1),(100 100,100 102,102 102,102 100,100 100)))",
150-
# "POLYGON((0 1,0 2,10 2,10 1,0 1))",
151-
# "GEOMETRYCOLLECTION (LINESTRING (1 2,2 2),LINESTRING (2 1,1 1),POLYGON ((0.5 1.0,1 2,1 1,0.5 1.0)),POLYGON ((9 2,9.5 1.0,2 1,2 2,9 2)))")
152-
# end
134+
@testset "Intersection" begin
135+
test_method(AG.intersection,
136+
"POLYGON EMPTY",
137+
"POLYGON EMPTY",
138+
"POLYGON EMPTY")
139+
test_method(AG.intersection,
140+
"POLYGON((1 1,1 5,5 5,5 1,1 1))",
141+
"POINT(2 2)",
142+
"POINT (2 2)")
143+
test_method(AG.intersection,
144+
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
145+
"POLYGON((-1 1,-1 2,2 2,2 1,-1 1))",
146+
"POLYGON ((0 2,2 2,2 1,0 1,0 2))")
147+
test_method(AG.intersection,
148+
"MULTIPOLYGON(((0 0,5 10,10 0,0 0),(1 1,1 2,2 2,2 1,1 1),(100 100,100 102,102 102,102 100,100 100)))",
149+
"POLYGON((0 1,0 2,10 2,10 1,0 1))",
150+
"GEOMETRYCOLLECTION (POLYGON ((0.5 1.0,1 2,1 1,0.5 1.0)),POLYGON ((2 2,9 2,9.5 1.0,2 1,2 2)),LINESTRING (2 1,1 1),LINESTRING (1 2,2 2))")
151+
end
153152

154153
function test_predicate(f::Function, wkt1, wkt2, result::Bool)
155154
AG.fromWKT(wkt1) do geom1

test/test_spatialref.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,21 @@ import GeoFormatTypes; const GFT = GeoFormatTypes
212212
AG.importXML!(spatialref2, xml4326)
213213
@test startswith(AG.toXML(spatialref2), "<gml:GeographicCRS")
214214
end
215+
end
215216

216-
# ERROR: GDALError (CE_Failure, code 6):
217-
# GDAL/OGR not compiled with libcurl support, remote requests not supported.
218-
# url4326 = "http://spatialreference.org/ref/epsg/4326/ogcwkt/"
219-
# proj4326 = "+proj=longlat +datum=WGS84 +no_defs "
220-
# urlsample = "http://spatialreference.org/ref/epsg/2039/esriwkt/"
221-
# projsample = "+proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +units=m +no_defs "
222-
# AG.importURL(url4326) do spatialref
223-
# spatialref2 = AG.importURL(urlsample)
224-
# @test AG.toWKT(spatialref2) == projsample
225-
# AG.importURL!(spatialref2, url4326)
226-
# @test AG.toWKT(spatialref2) == proj4326
227-
# end
217+
if VERSION >= v"1.6.0-"
218+
@testset "URL Import" begin
219+
url4326 = "http://spatialreference.org/ref/epsg/4326/ogcwkt/"
220+
wkt4326 = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"
221+
urlsample = "http://spatialreference.org/ref/epsg/2039/esriwkt/"
222+
wktsample = "PROJCS[\"Israel / Israeli TM Grid\",GEOGCS[\"Israel\",DATUM[\"Israel_1993\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],AUTHORITY[\"EPSG\",\"6141\"]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",31.7343936111111],PARAMETER[\"central_meridian\",35.2045169444444],PARAMETER[\"scale_factor\",1.0000067],PARAMETER[\"false_easting\",219529.584],PARAMETER[\"false_northing\",626907.39],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]"
223+
AG.importURL(url4326) do spatialref
224+
spatialref2 = AG.importURL(urlsample)
225+
@test AG.toWKT(spatialref2) == wktsample
226+
AG.importURL!(spatialref2, url4326)
227+
@test AG.toWKT(spatialref2) == wkt4326
228+
end
229+
end
228230
end
229231

230232
@testset "generic importCRS" begin

test/test_types.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import ArchGDAL; const AG = ArchGDAL
2222
@test AG.getname(GDAL.GARIO_COMPLETE) == "COMPLETE"
2323
@test AG.asyncstatustype("COMPLETE") == GDAL.GARIO_COMPLETE
2424
@test AG.asyncstatustype("ERROR") == GDAL.GARIO_ERROR
25-
# uncomment after https://github.com/JuliaGeo/GDALBuilder/issues/3
26-
# @test AG.asyncstatustype("PENDING") == GDAL.GARIO_PENDING
25+
@test AG.asyncstatustype("PENDING") == GDAL.GARIO_PENDING
2726
@test AG.asyncstatustype("UPDATE") == GDAL.GARIO_UPDATE
2827

2928
@test AG.colorinterp("Hue") == GDAL.GCI_HueBand

0 commit comments

Comments
 (0)