|
| 1 | +facts("Geo interface") do |
| 2 | + pt = LibGEOS.Point(1.0,2.0) |
| 3 | + @fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5) |
| 4 | + @fact GeoInterface.geotype(pt) --> :Point |
1 | 5 |
|
2 | | -pt = LibGEOS.Point(1.0,2.0) |
3 | | -@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5) |
4 | | -@fact GeoInterface.geotype(pt) --> :Point |
| 6 | + pt = LibGEOS.Point(1, 2) |
| 7 | + @fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5) |
| 8 | + @fact GeoInterface.geotype(pt) --> :Point |
5 | 9 |
|
6 | | -pt = LibGEOS.Point(1, 2) |
7 | | -@fact GeoInterface.coordinates(pt) --> roughly([1,2], 1e-5) |
8 | | -@fact GeoInterface.geotype(pt) --> :Point |
9 | 10 |
|
| 11 | + pt = LibGEOS.Point(LibGEOS.geomFromWKT("POINT EMPTY")) |
| 12 | + @fact GeoInterface.coordinates(pt) --> roughly(Float64[], 1e-5) |
| 13 | + @fact GeoInterface.geotype(pt) --> :Point |
10 | 14 |
|
11 | | -pt = LibGEOS.Point(LibGEOS.geomFromWKT("POINT EMPTY")) |
12 | | -@fact GeoInterface.coordinates(pt) --> roughly(Float64[], 1e-5) |
13 | | -@fact GeoInterface.geotype(pt) --> :Point |
| 15 | + mpt = LibGEOS.MultiPoint(LibGEOS.geomFromWKT("MULTIPOINT(0 0, 10 0, 10 10, 11 10)")) |
| 16 | + @fact GeoInterface.coordinates(mpt) --> Vector{Float64}[[0,0],[10,0],[10,10],[11,10]] |
| 17 | + @fact GeoInterface.geotype(mpt) --> :MultiPoint |
14 | 18 |
|
15 | | -mpt = LibGEOS.MultiPoint(LibGEOS.geomFromWKT("MULTIPOINT(0 0, 10 0, 10 10, 11 10)")) |
16 | | -factcheck_equals(GeoInterface.coordinates(mpt), Vector{Float64}[[0,0],[10,0],[10,10],[11,10]]) |
17 | | -@fact GeoInterface.geotype(mpt) --> :MultiPoint |
| 19 | + coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2]] |
| 20 | + ls = LibGEOS.LineString(coords) |
| 21 | + @fact GeoInterface.coordinates(ls) --> coords |
| 22 | + @fact GeoInterface.geotype(ls) --> :LineString |
18 | 23 |
|
19 | | -coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2]] |
20 | | -ls = LibGEOS.LineString(coords) |
21 | | -factcheck_equals(GeoInterface.coordinates(ls), coords) |
22 | | -@fact GeoInterface.geotype(ls) --> :LineString |
| 24 | + ls = LibGEOS.LineString(LibGEOS.geomFromWKT("LINESTRING EMPTY")) |
| 25 | + @fact GeoInterface.coordinates(ls) --> [] |
| 26 | + @fact GeoInterface.geotype(ls) --> :LineString |
23 | 27 |
|
24 | | -ls = LibGEOS.LineString(LibGEOS.geomFromWKT("LINESTRING EMPTY")) |
25 | | -factcheck_equals(GeoInterface.coordinates(ls), Vector{Float64}[[]]) |
26 | | -@fact GeoInterface.geotype(ls) --> :LineString |
| 28 | + mls = LibGEOS.MultiLineString(LibGEOS.geomFromWKT("MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))")) |
| 29 | + @fact GeoInterface.coordinates(mls) --> [[[5,0],[10,0]],[[0,0],[5,0]]] |
| 30 | + @fact GeoInterface.geotype(mls) --> :MultiLineString |
27 | 31 |
|
28 | | -mls = LibGEOS.MultiLineString(LibGEOS.geomFromWKT("MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))")) |
29 | | -factcheck_equals(GeoInterface.coordinates(mls), Vector{Vector{Float64}}[Vector{Float64}[[5,0],[0,0],[5,0]]]) |
30 | | -@fact GeoInterface.geotype(mls) --> :MultiLineString |
| 32 | + coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]] |
| 33 | + lr = LibGEOS.LinearRing(coords) |
| 34 | + @fact GeoInterface.coordinates(lr) --> coords |
| 35 | + @fact GeoInterface.geotype(lr) --> :LineString |
31 | 36 |
|
32 | | -coords = Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]] |
33 | | -lr = LibGEOS.LinearRing(coords) |
34 | | -factcheck_equals(GeoInterface.coordinates(lr), coords) |
35 | | -@fact GeoInterface.geotype(lr) --> :LineString |
| 37 | + coords = Vector{Vector{Float64}}[Vector{Float64}[[0,0],[10,0],[10,10],[0,10],[0,0]], |
| 38 | + Vector{Float64}[[1,8],[2,8],[2,9],[1,9],[1,8]], |
| 39 | + Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]]] |
| 40 | + polygon = LibGEOS.Polygon(coords) |
| 41 | + @fact GeoInterface.coordinates(polygon) --> coords |
| 42 | + @fact GeoInterface.geotype(polygon) --> :Polygon |
36 | 43 |
|
37 | | -coords = Vector{Vector{Float64}}[Vector{Float64}[[0,0],[10,0],[10,10],[0,10],[0,0]], |
38 | | - Vector{Float64}[[1,8],[2,8],[2,9],[1,9],[1,8]], |
39 | | - Vector{Float64}[[8,1],[9,1],[9,2],[8,2],[8,1]]] |
40 | | -polygon = LibGEOS.Polygon(coords) |
41 | | -factcheck_equals(GeoInterface.coordinates(polygon), coords) |
42 | | -@fact GeoInterface.geotype(polygon) --> :Polygon |
| 44 | + polygon = LibGEOS.Polygon(LibGEOS.geomFromWKT("POLYGON EMPTY")) |
| 45 | + @fact GeoInterface.coordinates(polygon) --> [[]] |
| 46 | + @fact GeoInterface.geotype(polygon) --> :Polygon |
43 | 47 |
|
44 | | -polygon = LibGEOS.Polygon(LibGEOS.geomFromWKT("POLYGON EMPTY")) |
45 | | -factcheck_equals(GeoInterface.coordinates(polygon), Vector{Vector{Float64}}[[]]) |
46 | | -@fact GeoInterface.geotype(polygon) --> :Polygon |
| 48 | + multipolygon = LibGEOS.MultiPolygon(LibGEOS.geomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))")) |
| 49 | + @fact GeoInterface.coordinates(multipolygon) --> Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[0,0],[0,10],[10,10],[10,0],[0,0]]]] |
| 50 | + @fact GeoInterface.geotype(multipolygon) --> :MultiPolygon |
47 | 51 |
|
48 | | -multipolygon = LibGEOS.MultiPolygon(LibGEOS.geomFromWKT("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))")) |
49 | | -factcheck_equals(GeoInterface.coordinates(multipolygon), Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[0,0],[0,10],[10,10],[10,0],[0,0]]]]) |
50 | | -@fact GeoInterface.geotype(multipolygon) --> :MultiPolygon |
| 52 | + geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))")) |
| 53 | + collection = GeoInterface.geometries(geomcollection) |
| 54 | + coords = Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[8.0,2.0],[10.0,10.0],[8.5,1.0],[8.0,2.0]]], |
| 55 | + Vector{Vector{Float64}}[Vector{Float64}[[7.0,8.0],[10.0,10.0],[8.0,2.0],[7.0,8.0]]], |
| 56 | + Vector{Vector{Float64}}[Vector{Float64}[[3.0,8.0],[10.0,10.0],[7.0,8.0],[3.0,8.0]]], |
| 57 | + Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 8.0, 2.0],[8.5,1.0],[2.0,2.0]]], |
| 58 | + Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 7.0, 8.0],[8.0,2.0],[2.0,2.0]]], |
| 59 | + Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 3.0, 8.0],[7.0,8.0],[2.0,2.0]]], |
| 60 | + Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[10.0,10.0],[3.0,8.0],[0.5,9.0]]], |
| 61 | + Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[ 3.0, 8.0],[2.0,2.0],[0.5,9.0]]], |
| 62 | + Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 2.0, 2.0],[8.5,1.0],[0.0,0.0]]], |
| 63 | + Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 0.5, 9.0],[2.0,2.0],[0.0,0.0]]]] |
| 64 | + @fact map(GeoInterface.coordinates,collection) --> coords |
| 65 | + @fact GeoInterface.geotype(geomcollection) --> :GeometryCollection |
51 | 66 |
|
52 | | -geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))")) |
53 | | -collection = GeoInterface.geometries(geomcollection) |
54 | | -coords = Vector{Vector{Vector{Float64}}}[Vector{Vector{Float64}}[Vector{Float64}[[8.0,2.0],[10.0,10.0],[8.5,1.0],[8.0,2.0]]], |
55 | | - Vector{Vector{Float64}}[Vector{Float64}[[7.0,8.0],[10.0,10.0],[8.0,2.0],[7.0,8.0]]], |
56 | | - Vector{Vector{Float64}}[Vector{Float64}[[3.0,8.0],[10.0,10.0],[7.0,8.0],[3.0,8.0]]], |
57 | | - Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 8.0, 2.0],[8.5,1.0],[2.0,2.0]]], |
58 | | - Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 7.0, 8.0],[8.0,2.0],[2.0,2.0]]], |
59 | | - Vector{Vector{Float64}}[Vector{Float64}[[2.0,2.0],[ 3.0, 8.0],[7.0,8.0],[2.0,2.0]]], |
60 | | - Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[10.0,10.0],[3.0,8.0],[0.5,9.0]]], |
61 | | - Vector{Vector{Float64}}[Vector{Float64}[[0.5,9.0],[ 3.0, 8.0],[2.0,2.0],[0.5,9.0]]], |
62 | | - Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 2.0, 2.0],[8.5,1.0],[0.0,0.0]]], |
63 | | - Vector{Vector{Float64}}[Vector{Float64}[[0.0,0.0],[ 0.5, 9.0],[2.0,2.0],[0.0,0.0]]]] |
64 | | -factcheck_equals(map(GeoInterface.coordinates,collection),coords) |
65 | | -@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection |
| 67 | + geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))")) |
| 68 | + collection = GeoInterface.geometries(geomcollection) |
| 69 | + coords = Vector[Vector{Float64}[[0.0,0.0],[0.0,0.0],[1.0,1.0]], |
| 70 | + Vector{Float64}[[1.0,1.0],[2.0,2.0],[2.0,2.0],[0.0,0.0]], |
| 71 | + Vector{Vector{Float64}}[Vector{Float64}[[5.0,5.0],[0.0,0.0],[0.0,2.0],[2.0,2.0],[5.0,5.0]]]] |
| 72 | + geotypes = [:MultiPoint,:LineString,:Polygon] |
| 73 | + for (i,item) in enumerate(collection) |
| 74 | + @fact GeoInterface.coordinates(item) --> coords[i] |
| 75 | + @fact GeoInterface.geotype(item) --> geotypes[i] |
| 76 | + end |
| 77 | + @fact GeoInterface.geotype(geomcollection) --> :GeometryCollection |
66 | 78 |
|
67 | | -geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION(MULTIPOINT(0 0, 0 0, 1 1),LINESTRING(1 1, 2 2, 2 2, 0 0),POLYGON((5 5, 0 0, 0 2, 2 2, 5 5)))")) |
68 | | -collection = GeoInterface.geometries(geomcollection) |
69 | | -coords = Vector[Vector{Float64}[[0.0,0.0],[0.0,0.0],[1.0,1.0]], |
70 | | - Vector{Float64}[[1.0,1.0],[2.0,2.0],[2.0,2.0],[0.0,0.0]], |
71 | | - Vector{Vector{Float64}}[Vector{Float64}[[5.0,5.0],[0.0,0.0],[0.0,2.0],[2.0,2.0],[5.0,5.0]]]] |
72 | | -geotypes = [:MultiPoint,:LineString,:Polygon] |
73 | | -for (i,item) in enumerate(collection) |
74 | | - factcheck_equals(GeoInterface.coordinates(item), coords[i]) |
75 | | - @fact GeoInterface.geotype(item) --> geotypes[i] |
| 79 | + geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION EMPTY")) |
| 80 | + collection = GeoInterface.geometries(geomcollection) |
| 81 | + @fact length(collection) --> 0 |
| 82 | + @fact GeoInterface.geotype(geomcollection) --> :GeometryCollection |
76 | 83 | end |
77 | | -@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection |
78 | | - |
79 | | -geomcollection = LibGEOS.GeometryCollection(LibGEOS.geomFromWKT("GEOMETRYCOLLECTION EMPTY")) |
80 | | -collection = GeoInterface.geometries(geomcollection) |
81 | | -@fact length(collection) --> 0 |
82 | | -@fact GeoInterface.geotype(geomcollection) --> :GeometryCollection |
|
0 commit comments