-
Notifications
You must be signed in to change notification settings - Fork 26
/
test_tables.jl
811 lines (764 loc) · 32.6 KB
/
test_tables.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
using Test
import ArchGDAL;
const AG = ArchGDAL;
using Tables
@testset "test_tables.jl" begin
@testset "Tables Support" begin
dataset = AG.read(joinpath(@__DIR__, "data/point.geojson"))
dataset1 = AG.read(
joinpath(@__DIR__, "data/multi_geom.csv"),
options = [
"GEOM_POSSIBLE_NAMES=point,linestring",
"KEEP_GEOM_COLUMNS=NO",
],
)
dataset2 = AG.read(
joinpath(@__DIR__, "data/missing_testcase.csv"),
options = [
"GEOM_POSSIBLE_NAMES=point,linestring",
"KEEP_GEOM_COLUMNS=NO",
],
)
@test dataset isa ArchGDAL.IDataset
@test dataset1 isa ArchGDAL.IDataset
@test dataset2 isa ArchGDAL.IDataset
layer = AG.getlayer(dataset, 0)
layer1 = AG.getlayer(dataset1, 0)
layer2 = AG.getlayer(dataset2, 0)
@testset "Tables methods" begin
@test isnothing(Tables.schema(layer1))
@test Tables.istable(typeof(layer)) == true
@test Tables.rowaccess(typeof(layer)) == true
features = collect(Tables.rows(layer1))
@test length(features) == 2
@test Tables.columnnames(features[1]) ==
(:point, :linestring, :id, :zoom, :location)
@test ismissing(Tables.getcolumn(features[2], -5))
@test ismissing(Tables.getcolumn(features[2], 0))
@test Tables.getcolumn(features[1], 1) == "5.1"
@test Tables.getcolumn(features[1], 2) == "1.0"
@test Tables.getcolumn(features[1], 3) == "Mumbai"
@test AG.toWKT(Tables.getcolumn(features[1], 4)) == "POINT (30 10)"
@test AG.toWKT(Tables.getcolumn(features[1], 5)) ==
"LINESTRING (30 10,10 30,40 40)"
@test Tables.getcolumn(features[1], :id) == "5.1"
@test Tables.getcolumn(features[1], :zoom) == "1.0"
@test Tables.getcolumn(features[1], :location) == "Mumbai"
@test AG.toWKT(Tables.getcolumn(features[1], :point)) ==
"POINT (30 10)"
@test AG.toWKT(Tables.getcolumn(features[1], :linestring)) ==
"LINESTRING (30 10,10 30,40 40)"
@test ismissing(Tables.getcolumn(features[1], :fake))
@test Tables.columnnames(features[2]) ==
(:point, :linestring, :id, :zoom, :location)
@test ismissing(Tables.getcolumn(features[2], -5))
@test ismissing(Tables.getcolumn(features[2], 0))
@test Tables.getcolumn(features[2], 1) == "5.2"
@test Tables.getcolumn(features[2], 2) == "2.0"
@test Tables.getcolumn(features[2], 3) == "New Delhi"
@test AG.toWKT(Tables.getcolumn(features[2], 4)) == "POINT (35 15)"
@test AG.toWKT(Tables.getcolumn(features[2], 5)) ==
"LINESTRING (35 15,15 35,45 45)"
@test Tables.getcolumn(features[2], :id) == "5.2"
@test Tables.getcolumn(features[2], :zoom) == "2.0"
@test Tables.getcolumn(features[2], :location) == "New Delhi"
@test AG.toWKT(Tables.getcolumn(features[2], :point)) ==
"POINT (35 15)"
@test AG.toWKT(Tables.getcolumn(features[2], :linestring)) ==
"LINESTRING (35 15,15 35,45 45)"
@test ismissing(Tables.getcolumn(features[2], :fake))
geom_names, field_names = AG.schema_names(AG.layerdefn(layer))
@test collect(geom_names) == [Symbol("")]
@test collect(field_names) == [:FID, :pointname]
geom_names, field_names = AG.schema_names(AG.layerdefn(layer1))
@test collect(geom_names) == [:point, :linestring]
@test collect(field_names) == [:id, :zoom, :location]
end
@testset "Conversion to table for drivers: GeoJSON, ESRI Shapefile" begin
TEST_DS_DRIVERS_FILE_EXTENSIONS = Dict(
"ESRI Shapefile" => "",
"GeoJSON" => ".geojson",
"CSV" => ".csv",
"GML" => ".gml",
"KML" => ".kml",
"GPKG" => ".gpkg",
"FlatGeobuf" => ".fgb",
)
TEST_DS_FILENAME_STEM = "test_ds"
"""
clean_test_files()
Cleans test files generated by `get_test_dataset`
"""
function clean_test_dataset_files()
for (drvshortname, file_extension) in
TEST_DS_DRIVERS_FILE_EXTENSIONS
isfile(
joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM * file_extension,
),
) && rm(
joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM * file_extension,
),
)
isfile(
joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM * ".xsd",
),
) && rm(
joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM * ".xsd",
),
)
isfile(
joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM * ".tmp",
),
) && rm(
joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM * ".tmp",
),
)
isdir(joinpath(@__DIR__, "tmp", TEST_DS_FILENAME_STEM)) &&
rm(
joinpath(@__DIR__, "tmp", TEST_DS_FILENAME_STEM),
recursive = true,
)
end
end
"""
get_test_dataset(
drvshortname::AbstractString = "ESRI shapefile",
geomfamily::String = "line";
withmissinggeom::Bool = true,
withmissingfield::Bool = true,
withmixedgeomtypes::Bool = true,
)::AG.IDataset
# Build a test dataset from scratch
with:
- OGR driver: `drvshortname` ∈ `["ESRI Shapefile", "GeoJSON"]`
- `"GeoJSON"` driver → 1 layer with 2 geometry columns
- `"ESRI Shapefile"` driver → 2 layers with 1 geometry column
1) with `wkbLineString` and `wkbMultiLineString` types
2) with `wkbPolygon`, `wkbMultiPolygon` types
- Layers' geometry type set to `wkbUnknown` but modified by the OGR driver according to its specifications,
- Each geometry has two additionnal fields `id::Int64` and `name::String`
# Options
- `withmissinggeom::Bool=true`: a missing geometry value per geom field
- `withmissingfield::Bool=true`: a missing field value in `id` field
- `withmixedgeomtypes::Bool=true`: a multi geometry value per geom field
# Returns
The corresponding IDataset
"""
function get_test_dataset(
drvshortname::AbstractString = "ESRI shapefile",
geomfamily::String = "line";
withmissinggeom::Bool = true,
withmissingfield::Bool = true,
withmixedgeomtypes::Bool = true,
)::AG.IDataset
# Build dataset filename
filename = joinpath(
@__DIR__,
"tmp",
TEST_DS_FILENAME_STEM *
TEST_DS_DRIVERS_FILE_EXTENSIONS[drvshortname],
)
# Clean previously created files for new dataset
clean_test_dataset_files()
# Prepare data for dataset building
data = Dict(
"line" => (
simple1 = (
name = "line1",
geom = AG.createlinestring([
(i, i + 1) for i in 1.0:3.0
]),
),
multi1 = (
name = "multiline1",
geom = AG.createmultilinestring([
[(i, i + 1) for i in j:j+3] for
j in 1.0:5.0:6.0
]),
),
simple2 = (
name = "line2",
geom = AG.createlinestring([
(i, i + 1) for i in 3.0:5.0
]),
),
emptygeom = (name = "emptygeom", geom = nothing),
emptyfield = (
name = "emptyid",
geom = AG.createlinestring([
(i, i + 1) for i in 5.0:7.0
]),
),
),
"polygon" => (
simple1 = (
name = "polygon1",
geom = AG.createpolygon([
(0.0, 0.0),
(0.0, 1.0),
(1.0, 1.0),
]),
),
multi1 = (
name = "multipolygon1",
geom = AG.createmultipolygon([
[[(0.0, 0.0), (0.0, j), (j, j)]] for
j in 1.0:-0.1:0.9
]),
),
simple2 = (
name = "polygon2",
geom = AG.createpolygon([
(0.0, 0.0),
(0.0, -1.0),
(-1.0, -1.0),
]),
),
emptygeom = (name = "emptygeom", geom = nothing),
emptyfield = (
name = "emptyid",
geom = AG.createpolygon([
(0.0, 0.0),
(-1.0, 0.0),
(-1.0, 1.0),
]),
),
),
)
# Create dataset
AG.create(
filename;
driver = AG.getdriver(drvshortname),
) do newdataset
AG.createlayer(
name = "test_layer",
dataset = newdataset,
geom = AG.wkbUnknown,
) do newlayer
# Add geom and field defn
AG.addfielddefn!(newlayer, "id", AG.OFTInteger64)
AG.addfielddefn!(newlayer, "name", AG.OFTString)
id_idx = AG.findfieldindex(AG.layerdefn(newlayer), "id")
name_idx =
AG.findfieldindex(AG.layerdefn(newlayer), "name")
# Add features
AG.addfeature(newlayer) do newfeature
AG.setfield!(newfeature, id_idx, 1)
AG.setfield!(
newfeature,
name_idx,
data[geomfamily].simple1.name,
)
return AG.setgeom!(
newfeature,
0,
data[geomfamily].simple1.geom,
)
end
if withmixedgeomtypes
AG.addfeature(newlayer) do newfeature
AG.setfield!(newfeature, id_idx, 2)
AG.setfield!(
newfeature,
name_idx,
data[geomfamily].multi1.name,
)
return AG.setgeom!(
newfeature,
0,
data[geomfamily].multi1.geom,
)
end
else
AG.addfeature(newlayer) do newfeature
AG.setfield!(newfeature, id_idx, 2)
AG.setfield!(
newfeature,
name_idx,
data[geomfamily].simple2.name,
)
return AG.setgeom!(
newfeature,
0,
data[geomfamily].simple2.geom,
)
end
end
if withmissinggeom
AG.addfeature(newlayer) do newfeature
AG.setfield!(newfeature, id_idx, 3)
return AG.setfield!(
newfeature,
name_idx,
data[geomfamily].emptygeom.name,
)
# No geom set
end
end
if withmissingfield
AG.addfeature(newlayer) do newfeature
# No Id field set
AG.setfield!(
newfeature,
name_idx,
data[geomfamily].emptyfield.name,
)
return AG.setgeom!(
newfeature,
0,
data[geomfamily].emptyfield.geom,
)
end
end
end
end
return AG.read(filename)
end
"""
map_on_test_dataset(
f::Function,
drvshortname::AbstractString="ESRI shapefile",
geomfamily::String="line";
withmissinggeom::Bool=true,
withmissingfield::Bool=true,
withmixedgeomtypes::Bool=true,
)::AG.IDataset
# Build a test dataset from scratch
with:
- OGR driver: `drvshortname` ∈ `["ESRI Shapefile", "GeoJSON"]`
- `"GeoJSON"` driver → 1 layer with 2 geometry columns
- `"ESRI Shapefile"` driver → 2 layers with 1 geometry column
1) with `wkbLineString` and `wkbMultiLineString` types
2) with `wkbPolygon`, `wkbMultiPolygon` types
- Layers' geometry type set to `wkbUnknown` but modified by the OGR driver according to its specifications,
- Each geometry has two additionnal fields `id::Int64` and `name::String`
# Options
- `withmissinggeom::Bool=true`: a missing geometry value per geom field
- `withmissingfield::Bool=true`: a missing field value in `id` field
- `withmixedgeomtypes::Bool=true`: a multi geometry value per geom field
# Returns
The result of `f` applied on the corresponding dataset
"""
function map_on_test_dataset(
f::Function,
drvshortname::AbstractString = "ESRI shapefile",
geomfamily::String = "line";
withmissinggeom::Bool = true,
withmissingfield::Bool = true,
withmixedgeomtypes::Bool = true,
)
# Build dataset
ds = get_test_dataset(
drvshortname,
geomfamily;
withmissinggeom = withmissinggeom,
withmissingfield = withmissingfield,
withmixedgeomtypes = withmixedgeomtypes,
)
return try
f(ds)
finally
(@isdefined ds) && AG.destroy(ds)
end
end
# Helper functions
function toWKT_withmissings(x)
if ismissing(x)
return missing
elseif typeof(x) <: AG.AbstractGeometry
return AG.toWKT(x)
else
return x
end
end
function columntablevalues_toWKT(x)
return Tuple(toWKT_withmissings.(x[i]) for i in 1:length(x))
end
tupleoftuples_equal = (
(x, y) ->
length(x) == length(y) &&
all([all(x[i] .=== y[i]) for i in 1:length(x)])
)
"""
layer_to_columntable_with_WKT(
drvshortname::String,
geomfamilly::String,
withmissinggeom::Bool,
withmissingfield::Bool,
withmixedgeomtypes::Bool,
)::NamedTuple
Convenience function to build new test results for `test_layer_to_table`
Creates a dataset from scratch with `get_test_dataset` and converts it to a columntable
Returns a `NamedTuple` with:
- names: layer geom and field names
- types: expected types given by `Tables.buildcolumns`
- values: expected Tables.columntable result values with geometries converted to WKT
"""
function layer_to_columntable_with_WKT(
drvshortname::String,
geomfamilly::String,
withmissinggeom::Bool,
withmissingfield::Bool,
withmixedgeomtypes::Bool,
)::NamedTuple
map_on_test_dataset(
drvshortname,
geomfamilly;
withmissinggeom = withmissinggeom,
withmissingfield = withmissingfield,
withmixedgeomtypes = withmixedgeomtypes,
) do ds
layer = AG.getlayer(ds, 0)
return (
names = keys(Tables.columntable(layer)),
types = eltype.(values(Tables.columntable(layer)),),
values = columntablevalues_toWKT(
values(Tables.columntable(layer)),
),
)
end
end
"""
test_layer_to_table(
drvshortname::String,
geomfamilly::String,
withmissinggeom::Bool,
withmissingfield::Bool,
withmixedgeomtypes::Bool,
reference_geotable::Tuple)
Creates a dataset from scratch with `get_test_dataset` and converts it to a columntable
And test Tables.columntable(::AG.IFeatureLayer) result against `reference_geotable`
"""
function test_layer_to_table(
drvshortname::String,
geomfamilly::String,
withmissinggeom::Bool,
withmissingfield::Bool,
withmixedgeomtypes::Bool,
reference_geotable::NamedTuple,
)::Bool
map_on_test_dataset(
drvshortname,
geomfamilly;
withmissinggeom = withmissinggeom,
withmissingfield = withmissingfield,
withmixedgeomtypes = withmixedgeomtypes,
) do ds
layer = AG.getlayer(ds, 0)
return all([
keys(Tables.columntable(layer)) ==
reference_geotable.names,
eltype.(values(Tables.columntable(layer))) ==
reference_geotable.types,
tupleoftuples_equal(
columntablevalues_toWKT(
values(Tables.columntable(layer)),
),
reference_geotable.values,
),
])
end
end
"""
test_layer_to_table(
layer::AG.AbstractFeatureLayer,
reference_geotable::NamedTuple,
)::Bool
test Tables.columntable(::AG.AbstractFeatureLayer) result against `reference_geotable`
"""
function test_layer_to_table(
layer::AG.AbstractFeatureLayer,
reference_geotable::NamedTuple,
)::Bool
return all([
keys(Tables.columntable(layer)) == reference_geotable.names,
eltype.(values(Tables.columntable(layer))) ==
reference_geotable.types,
tupleoftuples_equal(
columntablevalues_toWKT(
values(Tables.columntable(layer)),
),
reference_geotable.values,
),
])
end
@testset "Conversion to table for ESRI Shapefile driver" begin
ESRI_Shapefile_test_reference_geotable = (
names = (Symbol(""), :id, :name),
types = (Union{Missing,ArchGDAL.IGeometry}, Int64, String),
values = (
Union{Missing,String}[
"POLYGON ((0 0,0 1,1 1))",
"MULTIPOLYGON (((0 0,0 1,1 1)),((0.9 0.9,0.0 0.9,0 0)))",
missing,
"POLYGON ((0 0,-1 0,-1 1))",
],
[1, 2, 3, 0],
["polygon1", "multipolygon1", "emptygeom", "emptyid"],
),
)
@test test_layer_to_table(
"ESRI Shapefile",
"polygon",
true,
true,
true,
ESRI_Shapefile_test_reference_geotable,
)
ESRI_Shapefile_test_reference_geotable = (
names = (Symbol(""), :id, :name),
types = (
Union{
Missing,
ArchGDAL.IGeometry{ArchGDAL.wkbLineString},
},
Int64,
String,
),
values = (
Union{Missing,String}[
"LINESTRING (1 2,2 3,3 4)",
"LINESTRING (3 4,4 5,5 6)",
missing,
"LINESTRING (5 6,6 7,7 8)",
],
[1, 2, 3, 0],
["line1", "line2", "emptygeom", "emptyid"],
),
)
@test test_layer_to_table(
"ESRI Shapefile",
"line",
true,
true,
false,
ESRI_Shapefile_test_reference_geotable,
)
end
@testset "Conversion to table for GeoJSON driver" begin
GeoJSON_test_reference_geotable = (
names = (Symbol(""), :id, :name),
types = (
Union{Missing,ArchGDAL.IGeometry},
Union{Missing,Int32},
String,
),
values = (
Union{Missing,String}[
"POLYGON ((0 0,0 1,1 1))",
"MULTIPOLYGON (((0 0,0 1,1 1)),((0 0,0.0 0.9,0.9 0.9)))",
missing,
"POLYGON ((0 0,-1 0,-1 1))",
],
Union{Missing,Int32}[1, 2, 3, missing],
["polygon1", "multipolygon1", "emptygeom", "emptyid"],
),
)
@test test_layer_to_table(
"GeoJSON",
"polygon",
true,
true,
true,
GeoJSON_test_reference_geotable,
)
GeoJSON_test_reference_geotable = (
names = (Symbol(""), :id, :name),
types = (
Union{
Missing,
ArchGDAL.IGeometry{ArchGDAL.wkbLineString},
},
Union{Missing,Int32},
String,
),
values = (
Union{Missing,String}[
"LINESTRING (1 2,2 3,3 4)",
"LINESTRING (3 4,4 5,5 6)",
missing,
"LINESTRING (5 6,6 7,7 8)",
],
Union{Missing,Int32}[1, 2, 3, missing],
["line1", "line2", "emptygeom", "emptyid"],
),
)
@test test_layer_to_table(
"GeoJSON",
"line",
true,
true,
false,
GeoJSON_test_reference_geotable,
)
end
@testset "Conversion to table for GML driver" begin
GML_test_reference_geotable = (
names = (:geometryProperty, :fid, :id, :name),
types = (
Union{Missing,ArchGDAL.IGeometry},
String,
Union{Missing,Int64},
String,
),
values = (
Union{Missing,String}[
"LINESTRING (1 2,2 3,3 4)",
"MULTILINESTRING ((1 2,2 3,3 4,4 5),(6 7,7 8,8 9,9 10))",
missing,
"LINESTRING (5 6,6 7,7 8)",
],
[
"test_layer.0",
"test_layer.1",
"test_layer.2",
"test_layer.3",
],
Union{Missing,Int64}[1, 2, 3, missing],
["line1", "multiline1", "emptygeom", "emptyid"],
),
)
@test test_layer_to_table(
"GML",
"line",
true,
true,
true,
GML_test_reference_geotable,
)
end
@testset "Conversion to table for GPKG driver" begin
GPKG_test_reference_geotable = (
names = (:geom, :id, :name),
types = (Union{Missing,ArchGDAL.IGeometry}, Int64, String),
values = (
Union{Missing,String}[
"LINESTRING (1 2,2 3,3 4)",
"MULTILINESTRING ((1 2,2 3,3 4,4 5),(6 7,7 8,8 9,9 10))",
missing,
"LINESTRING (5 6,6 7,7 8)",
],
[1, 2, 3, 0],
["line1", "multiline1", "emptygeom", "emptyid"],
),
)
@test test_layer_to_table(
"GPKG",
"line",
true,
true,
true,
GPKG_test_reference_geotable,
)
end
@testset "Conversion to table for KML driver" begin
KML_test_reference_geotable = (
names = (Symbol(""), :Name, :Description),
types = (ArchGDAL.IGeometry, String, String),
values = (
[
"LINESTRING (1 2,2 3,3 4)",
"MULTILINESTRING ((1 2,2 3,3 4,4 5),(6 7,7 8,8 9,9 10))",
"LINESTRING (5 6,6 7,7 8)",
],
["line1", "multiline1", "emptyid"],
["", "", ""],
),
)
@test test_layer_to_table(
"KML",
"line",
true,
true,
true,
KML_test_reference_geotable,
)
end
@testset "Conversion to table for FlatGeobuf driver" begin
FlatGeobuf_test_reference_geotable = (
names = (Symbol(""), :id, :name),
types = (ArchGDAL.IGeometry, Union{Missing,Int64}, String),
values = (
[
"LINESTRING (5 6,6 7,7 8)",
"MULTILINESTRING ((1 2,2 3,3 4,4 5),(6 7,7 8,8 9,9 10))",
"LINESTRING (1 2,2 3,3 4)",
],
Union{Missing,Int64}[missing, 2, 1],
["emptyid", "multiline1", "line1"],
),
)
@test test_layer_to_table(
"FlatGeobuf",
"line",
true,
true,
true,
FlatGeobuf_test_reference_geotable,
)
end
@testset "Conversion to table for CSV driver" begin
@test begin
AG.read(
joinpath(@__DIR__, "data/multi_geom.csv"),
options = [
"GEOM_POSSIBLE_NAMES=point,linestring",
"KEEP_GEOM_COLUMNS=NO",
],
) do multigeom_test_ds
multigeom_test_layer = AG.getlayer(multigeom_test_ds, 0)
CSV_multigeom_test_reference_geotable = (
names = (
:point,
:linestring,
:id,
:zoom,
:location,
),
types = (
ArchGDAL.IGeometry{ArchGDAL.wkbPoint},
ArchGDAL.IGeometry{ArchGDAL.wkbLineString},
String,
String,
String,
),
values = (
["POINT (30 10)", "POINT (35 15)"],
[
"LINESTRING (30 10,10 30,40 40)",
"LINESTRING (35 15,15 35,45 45)",
],
["5.1", "5.2"],
["1.0", "2.0"],
["Mumbai", "New Delhi"],
),
)
return test_layer_to_table(
multigeom_test_layer,
CSV_multigeom_test_reference_geotable,
)
end
end
end
clean_test_dataset_files()
end
end
end