Skip to content

Commit

Permalink
Implement GeoInterface astext and asbinary. (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion authored Oct 3, 2024
1 parent a9322fa commit a34201e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wkb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,5 @@ function typesize(T::GI.GeometryCollectionTrait, geom, n::Integer)
end
return size
end

GI.asbinary(::GI.AbstractGeometryTrait, geom) = WellKnownGeometry.getwkb(geom)
2 changes: 2 additions & 0 deletions src/wkt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,5 @@ function GI.getgeom(
end
return WKTtype(gftgeom, data)
end

GI.astext(::GI.AbstractGeometryTrait, geom) = getwkt(geom)
26 changes: 26 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,30 @@ import LibGEOS
wkt = GFT.WellKnownText(GFT.Geom(), "POINT(30 10)")
@test GI.testgeometry(wkt)
end

@testset "GeoInterface piracy" begin
@test GI.astext((1.0, 2.0)) == GFT.WellKnownText(GFT.Geom(), "POINT (1.0 2.0)")
@test GI.asbinary((1.0, 2.0)).val == UInt8[
0x01,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0xf0,
0x3f,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x40]
end
end

3 comments on commit a34201e

@rafaqz
Copy link
Collaborator

@rafaqz rafaqz commented on a34201e Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a patch bump for this?

@evetion
Copy link
Owner Author

@evetion evetion commented on a34201e Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, but maybe after we merge the other PR?

@rafaqz
Copy link
Collaborator

@rafaqz rafaqz commented on a34201e Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I asked this before I tested it 😅

Please sign in to comment.