@@ -7,8 +7,8 @@ import GeoDataFrames as GDF
77import GeoFormatTypes as GFT
88
99# Use ArchGDAL datasets to test with
10- const testdatadir = @__DIR__
11-
10+ const testdatadir = joinpath ( @__DIR__ , " data " )
11+ isdir (testdatadir) || mkdir (testdatadir)
1212REPO_URL = " https://github.com/yeesian/ArchGDALDatasets/blob/master/"
1313
1414remotefiles = [
@@ -23,7 +23,7 @@ remotefiles = [
2323for (f, sha) in remotefiles
2424 localfn = joinpath (testdatadir, basename (f))
2525 url = REPO_URL * f * " ?raw=true"
26- PlatformEngines. download_verify (url, sha, localfn; force = true )
26+ PlatformEngines. download_verify (url, sha, localfn; force= true )
2727end
2828
2929
6363
6464 @testset " Read self written file" begin
6565 # Save table with a few random points
66- table = DataFrame (geom = AG. createpoint .(coords), name = " test" )
66+ table = DataFrame (geom= AG. createpoint .(coords), name= " test" )
6767 GDF. write (" test_points.shp" , table)
68- GDF. write (" test_points.gpkg" , table, layer_name = " test_points" )
69- GDF. write (" test_points.geojson" , table, layer_name = " test_points" )
68+ GDF. write (" test_points.gpkg" , table, layer_name= " test_points" )
69+ GDF. write (" test_points.geojson" , table, layer_name= " test_points" )
7070
7171 ntable = GDF. read (" test_points.shp" )
7272 @test nrow (ntable) == 10
8181 t = GDF. read (fn)
8282
8383 # Save table from reading
84- GDF. write (" test_read.shp" , t, layer_name = " test_coastline" )
85- GDF. write (" test_read.gpkg" , t, layer_name = " test_coastline" )
86- GDF. write (" test_read.geojson" , t, layer_name = " test_coastline" )
84+ GDF. write (" test_read.shp" , t, layer_name= " test_coastline" )
85+ GDF. write (" test_read.gpkg" , t, layer_name= " test_coastline" )
86+ GDF. write (" test_read.geojson" , t, layer_name= " test_coastline" )
8787
8888 end
8989
9090 @testset " Write shapefile with non-GDAL types" begin
91- coords = zip (rand (Float32, 2 ), rand (Float32, 2 ))
91+ coords = collect ( zip (rand (Float32, 2 ), rand (Float32, 2 ) ))
9292 t = DataFrame (
93- geom = AG. createpoint .(coords),
94- name = [" test" , " test2" ],
95- flag = [typemax (UInt8), typemax (UInt8)],
96- ex1 = [typemax (Int8), typemax (Int8)],
97- ex2 = [typemax (UInt16), typemax (UInt16)],
98- ex3 = [typemax (UInt32), typemax (UInt32)],
99- check = [false , true ],
100- z = [Float32 (8 ), Float32 (- 1 )],
101- odd = [1 , missing ],
102- date = [now (), now ()]
93+ geom= AG. createpoint .(coords),
94+ name= [" test" , " test2" ],
95+ flag= UInt8[typemin (UInt8), typemax (UInt8)],
96+ ex1= Int16[typemin (Int8), typemax (Int8)],
97+ ex2= Int32[typemin (UInt16), typemax (UInt16)],
98+ ex3= Int64[typemin (UInt32), typemax (UInt32)],
99+ check= [false , true ],
100+ z= Float32[Float32 (8 ), Float32 (- 1 )],
101+ y= Float16[Float16 (8 ), Float16 (- 1 )],
102+ odd= [1 , missing ],
103+ date= [DateTime (" 2022-03-31T15:38:41" ), DateTime (" 2022-03-31T15:38:41" )]
103104 )
104-
105105 GDF. write (" test_exotic.shp" , t)
106106 GDF. write (" test_exotic.gpkg" , t)
107107 GDF. write (" test_exotic.geojson" , t)
108+ tt = GDF. read (" test_exotic.gpkg" )
109+ @test AG. getx .(tt. geom, 0 ) == AG. getx .(t. geom, 0 )
110+ @test tt. flag == t. flag
111+ @test tt. ex1 == t. ex1
112+ @test tt. ex2 == t. ex2
113+ @test tt. ex3 == t. ex3
114+ @test tt. check == t. check
115+ @test tt. z == t. z
116+ @test tt. y == t. y
117+ @test ismissing .(tt. odd) == ismissing .(t. odd)
118+ @test tt. date == t. date
108119 end
109120
110121 @testset " Read shapefile with non-GDAL types" begin
111- t = GDF. read (" test_exotic.shp" )
122+ GDF. read (" test_exotic.shp" )
112123 GDF. read (" test_exotic.gpkg" )
113124 GDF. read (" test_exotic.geojson" )
114125 end
115126
116127 @testset " Spatial operations" begin
117- table = DataFrame (geom = AG. createpoint .(coords), name = " test" )
128+ table = DataFrame (geom= AG. createpoint .(coords), name= " test" )
118129
119130 # Buffer to also write polygons
120131 table. geom = AG. buffer (table. geom, 10 )
124135 end
125136
126137 @testset " Reproject" begin
127- table = DataFrame (geom = AG. createpoint .([[0 , 0 , 0 ]]), name = " test" )
138+ table = DataFrame (geom= AG. createpoint .([[0 , 0 , 0 ]]), name= " test" )
128139 AG. reproject (table. geom, GFT. EPSG (4326 ), GFT. EPSG (28992 ))
129140 @test GDF. AG. getpoint (table. geom[1 ], 0 )[1 ] ≈ - 587791.596556932
130- GDF. write (" test_reprojection.gpkg" , table, crs = GFT. EPSG (28992 ))
141+ GDF. write (" test_reprojection.gpkg" , table, crs= GFT. EPSG (28992 ))
131142 end
132143end
0 commit comments