Skip to content

Commit 6f4ba64

Browse files
yeesianvisr
authored andcommitted
add support for plot recipes
1 parent fcb43d4 commit 6f4ba64

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@ CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
88
Extents = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
99
GEOS_jll = "d604d12d-fa86-5845-992e-78dc15976526"
1010
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
11+
GeoInterfaceRecipes = "0329782f-3d07-4b52-b9f6-d3137cf03c7a"
1112

1213
[compat]
1314
CEnum = "0.2, 0.3, 0.4"
1415
Extents = "0.1.1"
1516
GEOS_jll = "3.11"
1617
GeoInterface = "1"
18+
GeoInterfaceRecipes = "1"
1719
julia = "1.6"
1820

1921
[extras]
2022
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
23+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2124
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2225

2326
[targets]
24-
test = ["Aqua", "Test"]
27+
test = ["Aqua", "Plots", "Test"]

src/LibGEOS.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module LibGEOS
22

33
using GEOS_jll
44
using GeoInterface
5+
using GeoInterfaceRecipes
56
using Extents
67
using CEnum
78

src/geo_interface.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,5 @@ GeoInterface.union(
181181
a::AbstractGeometry,
182182
b::AbstractGeometry,
183183
) = union(a, b)
184+
185+
GeoInterfaceRecipes.@enable_geo_plots AbstractGeometry

test/test_geo_interface.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Plots
2+
13
@testset "Geo interface" begin
24
pt = LibGEOS.Point(1.0, 2.0)
35
@test GeoInterface.coordinates(pt) [1, 2] atol = 1e-5
@@ -6,6 +8,7 @@
68
@test GeoInterface.getcoord(pt, 1) 1.0
79
@test GeoInterface.testgeometry(pt)
810
@test GeoInterface.extent(pt) == Extent(X = (1.0, 1.0), Y = (2.0, 2.0))
11+
plot(pt)
912

1013
pt = LibGEOS.Point(1, 2)
1114
@test GeoInterface.coordinates(pt) [1, 2] atol = 1e-5
@@ -27,6 +30,7 @@
2730
@test p isa LibGEOS.Point
2831
@test GeoInterface.coordinates(p) == [10, 0]
2932
@test GeoInterface.testgeometry(mpt)
33+
plot(mpt)
3034

3135
coords = Vector{Float64}[[8, 1], [9, 1], [9, 2], [8, 2]]
3236
ls = LibGEOS.LineString(coords)
@@ -37,6 +41,7 @@
3741
@test p isa LibGEOS.Point
3842
@test GeoInterface.coordinates(p) == [9, 2]
3943
@test GeoInterface.testgeometry(ls)
44+
plot(ls)
4045

4146
ls = LibGEOS.readgeom("LINESTRING EMPTY")
4247
@test GeoInterface.coordinates(ls) == []
@@ -48,6 +53,7 @@
4853
@test GeoInterface.geomtrait(mls) == MultiLineStringTrait()
4954
@test GeoInterface.ngeom(mls) == 2
5055
@test GeoInterface.testgeometry(mls)
56+
plot(mls)
5157

5258
coords = Vector{Float64}[[8, 1], [9, 1], [9, 2], [8, 2], [8, 1]]
5359
lr = LibGEOS.LinearRing(coords)
@@ -58,6 +64,8 @@
5864
@test p isa LibGEOS.Point
5965
@test GeoInterface.coordinates(p) == [9, 2]
6066
@test GeoInterface.testgeometry(lr)
67+
# Cannot convert LinearRingTrait to series data for plotting
68+
# plot(lr)
6169

6270
coords = Vector{Vector{Float64}}[
6371
Vector{Float64}[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]],
@@ -72,6 +80,7 @@
7280
@test ls isa LibGEOS.LinearRing
7381
@test GeoInterface.coordinates(ls) == coords[2]
7482
@test GeoInterface.testgeometry(polygon)
83+
plot(polygon)
7584

7685
polygon = LibGEOS.readgeom("POLYGON EMPTY")
7786
@test GeoInterface.coordinates(polygon) == [[]]
@@ -90,6 +99,7 @@
9099
@test GeoInterface.geomtrait(multipolygon) == MultiPolygonTrait()
91100
@test GeoInterface.testgeometry(multipolygon)
92101
@test GeoInterface.extent(multipolygon) == Extent(X = (0.0, 10.0), Y = (0.0, 10.0))
102+
plot(multipolygon)
93103

94104
pmultipolygon = LibGEOS.prepareGeom(multipolygon)
95105
@test GeoInterface.geomtrait(pmultipolygon) == MultiPolygonTrait()
@@ -167,6 +177,7 @@
167177
end
168178
@test GeoInterface.geomtrait(geomcollection) == GeometryCollectionTrait()
169179
@test GeoInterface.testgeometry(geomcollection)
180+
plot(geomcollection)
170181

171182
geomcollection = LibGEOS.readgeom(
172183
"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)))",

0 commit comments

Comments
 (0)