Skip to content

Commit

Permalink
Test the printing of wrapped geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Jan 20, 2025
1 parent 7754124 commit 3cb9c5f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,30 @@ test_display(fc, "FeatureCollection([Feature(MultiPolygon{false, false}([Polygon
vecfc = GI.FeatureCollection([(geometry=(1,2), a=1, b=2)])
@test GI.getfeature(vecfc, 1) == (geometry=(1,2), a=1, b=2)

@testset "Wrapped geometry printing" begin
struct MyPoint
x::Float64
y::Float64
end
GI.geomtrait(::MyPoint) = GI.PointTrait()
GI.ncoord(::GI.PointTrait, ::MyPoint) = 2
GI.x(::GI.PointTrait, p::MyPoint) = p.x
GI.y(::GI.PointTrait, p::MyPoint) = p.y


test_display(GI.Point(MyPoint(1.0, 2.0)), "Point{false, false}((1.0, 2.0))", "Point((1.0,2.0))")

GI.geomtrait(::Vector{MyPoint}) = GI.LineStringTrait()
GI.npoint(::GI.LineStringTrait, v::Vector{MyPoint}) = length(v)
GI.getpoint(::GI.LineStringTrait, v::Vector{MyPoint}, i::Integer) = v[i]

test_display(
GI.LineString([MyPoint(1.0, 2.0), MyPoint(3.0, 4.0)]),
"LineString{false, false}([MyPoint(1.0, 2.0), MyPoint(3.0, 4.0)])",
"LineString([MyPoint(1.0,2.0),MyPoint(3.0,4.0)])" # FIXME: this should not show the point type!
)
end

# TODO

# # Triangle
Expand Down

0 comments on commit 3cb9c5f

Please sign in to comment.