@@ -6,131 +6,131 @@ using GeometryBasics: attributes
6
6
@testset " GeometryBasics" begin
7
7
8
8
#= This left till meta is removed completely
9
- @testset "embedding metadata" begin
10
- @testset "Meshes" begin
11
-
12
- @testset "per vertex attributes" begin
13
- points = rand(Point{3, Float64}, 8)
14
- tfaces = TetrahedronFace{Int}[(1, 2, 3, 4), (5, 6, 7, 8)]
15
- normals = rand(SVector{3, Float64}, 8)
16
- stress = LinRange(0, 1, 8)
17
- mesh = Mesh(meta(points, normals = normals, stress = stress), tfaces)
18
-
19
- @test hasproperty(coordinates(mesh), :stress)
20
- @test hasproperty(coordinates(mesh), :normals)
21
- @test coordinates(mesh).stress === stress
22
- @test coordinates(mesh).normals === normals
23
- @test coordinates(mesh).normals === normals
24
- @test GeometryBasics.faces(mesh) === tfaces
25
- @test propertynames(coordinates(mesh)) == (:position, :normals, :stress)
26
-
27
- end
28
-
29
- @testset "per face attributes" begin
30
-
31
- # Construct a cube out of Quads
32
- points = Point{3, Float64}[
33
- (0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
34
- (2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
35
- (0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
36
- (2.0, 2.0, 12.0), (0.0, 2.0, 12.0)
37
- ]
38
-
39
- facets = QuadFace{Cint}[
40
- 1:4,
41
- 5:8,
42
- [1,5,6,2],
43
- [2,6,7,3],
44
- [3, 7, 8, 4],
45
- [4, 8, 5, 1]
46
- ]
47
-
48
- markers = Cint[-1, -2, 0, 0, 0, 0]
49
- # attach some additional information to our faces!
50
- mesh = Mesh(points, meta(facets, markers = markers))
51
- @test hasproperty(GeometryBasics.faces(mesh), :markers)
52
- # test with === to assert we're not doing any copies
53
- @test GeometryBasics.faces(mesh).markers === markers
54
- @test coordinates(mesh) === points
55
- @test metafree(GeometryBasics.faces(mesh)) === facets
56
-
57
- end
58
-
59
- end
9
+ # @testset "embedding metadata" begin
10
+ # @testset "Meshes" begin
11
+
12
+ # @testset "per vertex attributes" begin
13
+ # points = rand(Point{3, Float64}, 8)
14
+ # tfaces = TetrahedronFace{Int}[(1, 2, 3, 4), (5, 6, 7, 8)]
15
+ # normals = rand(SVector{3, Float64}, 8)
16
+ # stress = LinRange(0, 1, 8)
17
+ # mesh = Mesh(meta(points, normals = normals, stress = stress), tfaces)
18
+
19
+ # @test hasproperty(coordinates(mesh), :stress)
20
+ # @test hasproperty(coordinates(mesh), :normals)
21
+ # @test coordinates(mesh).stress === stress
22
+ # @test coordinates(mesh).normals === normals
23
+ # @test coordinates(mesh).normals === normals
24
+ # @test GeometryBasics.faces(mesh) === tfaces
25
+ # @test propertynames(coordinates(mesh)) == (:position, :normals, :stress)
26
+
27
+ # end
28
+
29
+ # @testset "per face attributes" begin
30
+
31
+ # # Construct a cube out of Quads
32
+ # points = Point{3, Float64}[
33
+ # (0.0, 0.0, 0.0), (2.0, 0.0, 0.0),
34
+ # (2.0, 2.0, 0.0), (0.0, 2.0, 0.0),
35
+ # (0.0, 0.0, 12.0), (2.0, 0.0, 12.0),
36
+ # (2.0, 2.0, 12.0), (0.0, 2.0, 12.0)
37
+ # ]
38
+
39
+ # facets = QuadFace{Cint}[
40
+ # 1:4,
41
+ # 5:8,
42
+ # [1,5,6,2],
43
+ # [2,6,7,3],
44
+ # [3, 7, 8, 4],
45
+ # [4, 8, 5, 1]
46
+ # ]
47
+
48
+ # markers = Cint[-1, -2, 0, 0, 0, 0]
49
+ # # attach some additional information to our faces!
50
+ # mesh = Mesh(points, meta(facets, markers = markers))
51
+ # @test hasproperty(GeometryBasics.faces(mesh), :markers)
52
+ # # test with === to assert we're not doing any copies
53
+ # @test GeometryBasics.faces(mesh).markers === markers
54
+ # @test coordinates(mesh) === points
55
+ # @test metafree(GeometryBasics.faces(mesh)) === facets
56
+
57
+ # end
58
+
59
+ # end
60
60
61
- @testset "polygon with metadata" begin
62
- polys = [Polygon(rand(Point{2, Float32}, 20)) for i in 1:10]
63
- pnames = [randstring(4) for i in 1:10]
64
- numbers = LinRange(0.0, 1.0, 10)
65
- bin = rand(Bool, 10)
66
- # create a polygon
67
- poly = PolygonMeta(polys[1], name = pnames[1], value = numbers[1], category = bin[1])
68
- # create a MultiPolygon with the right type & meta information!
69
- multipoly = MultiPolygonMeta(polys, name = pnames, value = numbers, category = bin)
70
- @test multipoly isa AbstractVector
71
- @test poly isa GeometryBasics.AbstractPolygon
61
+ # @testset "polygon with metadata" begin
62
+ # polys = [Polygon(rand(Point{2, Float32}, 20)) for i in 1:10]
63
+ # pnames = [randstring(4) for i in 1:10]
64
+ # numbers = LinRange(0.0, 1.0, 10)
65
+ # bin = rand(Bool, 10)
66
+ # # create a polygon
67
+ # poly = PolygonMeta(polys[1], name = pnames[1], value = numbers[1], category = bin[1])
68
+ # # create a MultiPolygon with the right type & meta information!
69
+ # multipoly = MultiPolygonMeta(polys, name = pnames, value = numbers, category = bin)
70
+ # @test multipoly isa AbstractVector
71
+ # @test poly isa GeometryBasics.AbstractPolygon
72
72
73
- @test GeometryBasics.getcolumn(poly, :name) == pnames[1]
74
- @test GeometryBasics.MetaFree(PolygonMeta) == Polygon
75
-
76
- @test GeometryBasics.getcolumn(multipoly, :name) == pnames
77
- @test GeometryBasics.MetaFree(MultiPolygonMeta) == MultiPolygon
78
-
79
- meta_p = meta(polys[1], boundingbox=Rect(0, 0, 2, 2))
80
- @test meta_p.boundingbox === Rect(0, 0, 2, 2)
81
- @test metafree(meta_p) === polys[1]
82
- attributes(meta_p) == Dict{Symbol, Any}(:boundingbox => meta_p.boundingbox,
83
- :polygon => polys[1])
84
- end
85
- @testset "point with metadata" begin
86
- p = Point(1.1, 2.2)
87
- @test p isa AbstractVector{Float64}
88
- pm = GeometryBasics.PointMeta(1.1, 2.2; a=1, b=2)
89
- p1 = Point(2.2, 3.6)
90
- p2 = [p, p1]
91
- @test coordinates(p2) == p2
92
- @test meta(pm) === (a=1, b=2)
93
- @test metafree(pm) === p
94
- @test propertynames(pm) == (:position, :a, :b)
95
- end
73
+ # @test GeometryBasics.getcolumn(poly, :name) == pnames[1]
74
+ # @test GeometryBasics.MetaFree(PolygonMeta) == Polygon
75
+
76
+ # @test GeometryBasics.getcolumn(multipoly, :name) == pnames
77
+ # @test GeometryBasics.MetaFree(MultiPolygonMeta) == MultiPolygon
78
+
79
+ # meta_p = meta(polys[1], boundingbox=Rect(0, 0, 2, 2))
80
+ # @test meta_p.boundingbox === Rect(0, 0, 2, 2)
81
+ # @test metafree(meta_p) === polys[1]
82
+ # attributes(meta_p) == Dict{Symbol, Any}(:boundingbox => meta_p.boundingbox,
83
+ # :polygon => polys[1])
84
+ # end
85
+ # @testset "point with metadata" begin
86
+ # p = Point(1.1, 2.2)
87
+ # @test p isa AbstractVector{Float64}
88
+ # pm = GeometryBasics.PointMeta(1.1, 2.2; a=1, b=2)
89
+ # p1 = Point(2.2, 3.6)
90
+ # p2 = [p, p1]
91
+ # @test coordinates(p2) == p2
92
+ # @test meta(pm) === (a=1, b=2)
93
+ # @test metafree(pm) === p
94
+ # @test propertynames(pm) == (:position, :a, :b)
95
+ # end
96
96
97
- @testset "MultiPoint with metadata" begin
98
- p = collect(Point{2, Float64}(x, x+1) for x in 1:5)
99
- @test p isa AbstractVector
100
- mpm = MultiPointMeta(p, a=1, b=2)
101
- @test coordinates(mpm) == mpm
102
- @test meta(mpm) === (a=1, b=2)
103
- @test metafree(mpm) == p
104
- @test propertynames(mpm) == (:points, :a, :b)
105
- end
106
-
107
- @testset "LineString with metadata" begin
108
- linestring = LineStringMeta(Point{2, Int}[(10, 10), (20, 20), (10, 40)], a = 1, b = 2)
109
- @test linestring isa AbstractVector
110
- @test meta(linestring) === (a = 1, b = 2)
111
- @test metafree(linestring) == linestring
112
- @test propertynames(linestring) == (:lines, :a, :b)
113
- end
114
-
115
- @testset "MultiLineString with metadata" begin
116
- linestring1 = LineString(Point{2, Int}[(10, 10), (20, 20), (10, 40)])
117
- linestring2 = LineString(Point{2, Int}[(40, 40), (30, 30), (40, 20), (30, 10)])
118
- multilinestring = MultiLineString([linestring1, linestring2])
119
- multilinestringmeta = MultiLineStringMeta([linestring1, linestring2]; boundingbox = Rect(1.0, 1.0, 2.0, 2.0))
120
- @test multilinestringmeta isa AbstractVector
121
- @test meta(multilinestringmeta) === (boundingbox = Rect(1.0, 1.0, 2.0, 2.0),)
122
- @test metafree(multilinestringmeta) == multilinestring
123
- @test propertynames(multilinestringmeta) == (:linestrings, :boundingbox)
124
- end
97
+ # @testset "MultiPoint with metadata" begin
98
+ # p = collect(Point{2, Float64}(x, x+1) for x in 1:5)
99
+ # @test p isa AbstractVector
100
+ # mpm = MultiPointMeta(p, a=1, b=2)
101
+ # @test coordinates(mpm) == mpm
102
+ # @test meta(mpm) === (a=1, b=2)
103
+ # @test metafree(mpm) == p
104
+ # @test propertynames(mpm) == (:points, :a, :b)
105
+ # end
106
+
107
+ # @testset "LineString with metadata" begin
108
+ # linestring = LineStringMeta(Point{2, Int}[(10, 10), (20, 20), (10, 40)], a = 1, b = 2)
109
+ # @test linestring isa AbstractVector
110
+ # @test meta(linestring) === (a = 1, b = 2)
111
+ # @test metafree(linestring) == linestring
112
+ # @test propertynames(linestring) == (:lines, :a, :b)
113
+ # end
114
+
115
+ # @testset "MultiLineString with metadata" begin
116
+ # linestring1 = LineString(Point{2, Int}[(10, 10), (20, 20), (10, 40)])
117
+ # linestring2 = LineString(Point{2, Int}[(40, 40), (30, 30), (40, 20), (30, 10)])
118
+ # multilinestring = MultiLineString([linestring1, linestring2])
119
+ # multilinestringmeta = MultiLineStringMeta([linestring1, linestring2]; boundingbox = Rect(1.0, 1.0, 2.0, 2.0))
120
+ # @test multilinestringmeta isa AbstractVector
121
+ # @test meta(multilinestringmeta) === (boundingbox = Rect(1.0, 1.0, 2.0, 2.0),)
122
+ # @test metafree(multilinestringmeta) == multilinestring
123
+ # @test propertynames(multilinestringmeta) == (:linestrings, :boundingbox)
124
+ # end
125
125
126
- @testset "Mesh with metadata" begin
127
- m = triangle_mesh(Sphere(Point3f0(0), 1))
128
- m_meta = MeshMeta(m; boundingbox=Rect(1.0, 1.0, 2.0, 2.0))
129
- @test meta(m_meta) === (boundingbox = Rect(1.0, 1.0, 2.0, 2.0),)
130
- @test metafree(m_meta) === m
131
- @test propertynames(m_meta) == (:mesh, :boundingbox)
132
- end
133
- end
126
+ # @testset "Mesh with metadata" begin
127
+ # m = triangle_mesh(Sphere(Point3f0(0), 1))
128
+ # m_meta = MeshMeta(m; boundingbox=Rect(1.0, 1.0, 2.0, 2.0))
129
+ # @test meta(m_meta) === (boundingbox = Rect(1.0, 1.0, 2.0, 2.0),)
130
+ # @test metafree(m_meta) === m
131
+ # @test propertynames(m_meta) == (:mesh, :boundingbox)
132
+ # end
133
+ # end
134
134
=#
135
135
@testset " embedding metadata(new)" begin
136
136
# @testset "Meshes" begin
202
202
203
203
meta_p = GeometryBasics. Feature (polys[1 ], boundingbox= Rect (0 , 0 , 2 , 2 ))
204
204
@test meta_p. boundingbox === Rect (0 , 0 , 2 , 2 )
205
+ @test GeometryBasics. metafree (meta_p) == polys[1 ]
206
+ @test GeometryBasics. metafree (poly) == polys[1 ]
207
+ @test GeometryBasics. metafree (multipoly) == multipol
208
+ @test GeometryBasics. meta (meta_p) == (boundingbox = GeometryBasics. HyperRectangle {2,Int64} ([0 , 0 ], [2 , 2 ]),)
209
+ @test GeometryBasics. meta (poly) == (name = " cMlR" , value = 0.0 , category = true )
210
+ @test GeometryBasics. meta (multipoly) == (name = pnames, value = numbers, category = bin)
205
211
end
212
+
206
213
@testset " point with metadata" begin
207
214
p = Point (1.1 , 2.2 )
208
215
@test p isa AbstractVector{Float64}
@@ -213,23 +220,29 @@ end
213
220
@test pm. rest === (a= 1 , b= 2 )
214
221
@test pm. data === p
215
222
@test propertynames (pm) == (:data , :a , :b )
223
+ @test GeometryBasics. metafree (pm) == p
224
+ @test GeometryBasics. meta (pm) == (a = 1 , b = 2 )
216
225
end
217
226
218
227
@testset " MultiPoint with metadata" begin
219
228
p = collect (Point {2, Float64} (x, x+ 1 ) for x in 1 : 5 )
220
229
@test p isa AbstractVector
221
- mpm = GeometryBasics. Feature (MultiPoint (p), a= 1 , b= 2 )
230
+ mpm = GeometryBasics. Feature (MultiPoint (p); a= 1 , b= 2 )
222
231
@test coordinates (mpm. data) == Point{2 , Float64}[(x, x+ 1 ) for x in 1 : 5 ]
223
232
@test mpm. rest === (a= 1 , b= 2 )
224
233
@test mpm. data == p
225
234
@test propertynames (mpm) == (:data , :a , :b )
235
+ @test GeometryBasics. metafree (mpm) == p
236
+ @test GeometryBasics. meta (mpm) == (a = 1 , b = 2 )
226
237
end
227
238
228
239
@testset " LineString with metadata" begin
229
240
linestring = GeometryBasics. Feature (LineString (Point{2 , Int}[(10 , 10 ), (20 , 20 ), (10 , 40 )]), a = 1 , b = 2 )
230
241
@test linestring isa GeometryBasics. Feature
231
242
@test linestring. rest === (a = 1 , b = 2 )
232
243
@test propertynames (linestring) == (:data , :a , :b )
244
+ @test GeometryBasics. metafree (linestring) == LineString (Point{2 , Int}[(10 , 10 ), (20 , 20 ), (10 , 40 )])
245
+ @test GeometryBasics. meta (linestring) == (a = 1 , b = 2 )
233
246
end
234
247
235
248
@testset " MultiLineString with metadata" begin
241
254
@test multilinestringmeta. rest === (boundingbox = Rect (1.0 , 1.0 , 2.0 , 2.0 ),)
242
255
@test multilinestringmeta. data == multilinestring
243
256
@test propertynames (multilinestringmeta) == (:data , :boundingbox )
257
+ @test GeometryBasics. metafree (multilinestringmeta) == multilinestring
258
+ @test GeometryBasics. meta (multilinestringmeta) == (boundingbox = GeometryBasics. HyperRectangle {2,Float64} ([1.0 , 1.0 ], [2.0 , 2.0 ]),)
244
259
end
245
260
246
261
# @testset "Mesh with metadata" begin
0 commit comments