Skip to content

Commit

Permalink
we be rappin now
Browse files Browse the repository at this point in the history
this is probably the best example of a 9pm commit I've had so far...

in all seriousness we could change the name
  • Loading branch information
asinghvi17 committed Jan 20, 2025
1 parent 3cb9c5f commit c0c7558
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions test/test_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,27 +365,31 @@ 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)



struct MaPointRappa
x::Float64
y::Float64
end

@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

GI.geomtrait(::MaPointRappa) = GI.PointTrait()
GI.ncoord(::GI.PointTrait, ::MaPointRappa) = 2
GI.x(::GI.PointTrait, p::MaPointRappa) = p.x
GI.y(::GI.PointTrait, p::MaPointRappa) = p.y


test_display(GI.Point(MyPoint(1.0, 2.0)), "Point{false, false}((1.0, 2.0))", "Point((1.0,2.0))")
test_display(GI.Point(MaPointRappa(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]
GI.geomtrait(::Vector{MaPointRappa}) = GI.LineStringTrait()
GI.npoint(::GI.LineStringTrait, v::Vector{MaPointRappa}) = length(v)
GI.getpoint(::GI.LineStringTrait, v::Vector{MaPointRappa}, 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!
GI.LineString([MaPointRappa(1.0, 2.0), MaPointRappa(3.0, 4.0)]),
"LineString{false, false}([MaPointRappa(1.0, 2.0), MaPointRappa(3.0, 4.0)])",
"LineString([MaPointRappa(1.0, 2.0),MaPointRappa(3.0, 4.0)])" # FIXME: this should not show the point type!
)
end

Expand Down

0 comments on commit c0c7558

Please sign in to comment.