Skip to content

Commit a56ee76

Browse files
repro-codeevetion
andauthored
Restore GeoInterfaceRecipes as empty stub package (#213)
* Add GeoInterfaceRecipes/Project.toml * Add GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl * Add GeoInterfaceRecipes/test/runtests.jl * Add GeoInterfaceRecipes/LICENSE * Add GeoInterfaceRecipes/README.md * Redirect macros to extensions. --------- Co-authored-by: Maarten Pronk <[email protected]>
1 parent 5a85ddc commit a56ee76

File tree

5 files changed

+185
-0
lines changed

5 files changed

+185
-0
lines changed

GeoInterfaceRecipes/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Julia Computing
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

GeoInterfaceRecipes/Project.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name = "GeoInterfaceRecipes"
2+
uuid = "0329782f-3d07-4b52-b9f6-d3137cf03c7a"
3+
version = "1.0.3"
4+
authors = ["JuliaGeo and contributors"]
5+
6+
[deps]
7+
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
8+
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
9+
10+
[compat]
11+
GeoInterface = "1.5"
12+
RecipesBase = "1"
13+
julia = "1.9"
14+
15+
[extras]
16+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
17+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
18+
19+
[targets]
20+
test = ["Plots", "Test"]

GeoInterfaceRecipes/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# GeoInterfaceRecipes.jl
2+
3+
**This package is deprecated.**
4+
5+
Plotting recipes for GeoInterface geometries are now built directly into [GeoInterface.jl](https://github.com/JuliaGeo/GeoInterface.jl) as package extensions:
6+
7+
- **Plots.jl support**: Load `GeoInterface` with `Plots` and recipes work automatically
8+
- **Makie.jl support**: Load `GeoInterface` with `Makie` and `GeometryBasics` for Makie plotting
9+
10+
## Migration
11+
12+
No action is needed. Simply remove `GeoInterfaceRecipes` from your dependencies and use `GeoInterface` directly with your preferred plotting package.
13+
14+
```julia
15+
using GeoInterface
16+
using Plots # or using Makie
17+
18+
# Plotting just works
19+
plot(my_geometry)
20+
```
21+
22+
This empty package exists only to provide a smooth upgrade path for users who had GeoInterfaceRecipes.jl in their dependencies.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module GeoInterfaceRecipes
2+
using RecipesBase
3+
using GeoInterface
4+
5+
export @enable_geo_plots
6+
7+
# This package is deprecated. Plotting recipes are now built into GeoInterface.jl
8+
# as package extensions. See:
9+
# - GeoInterfaceRecipesBaseExt for Plots.jl support
10+
# - GeoInterfaceMakieExt for Makie.jl support
11+
12+
# This stub package exists only to allow smooth upgrades for users who had
13+
# GeoInterfaceRecipes.jl installed. No action is needed - simply load
14+
# GeoInterface with Plots or Makie and the recipes will work automatically.
15+
16+
macro enable(typ)
17+
:(GeoInterface.@enable_plots RecipesBase $(esc(typ)))
18+
end
19+
20+
# Compat
21+
macro enable_geo_plots(typ)
22+
:(GeoInterface.@enable_plots RecipesBase $(esc(typ)))
23+
end
24+
25+
end
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using GeoInterfaceRecipes
2+
using GeoInterface
3+
using Plots
4+
using Test
5+
6+
7+
abstract type MyAbstractGeom{N} end
8+
# Implement interface
9+
struct MyPoint{N} <: MyAbstractGeom{N} end
10+
struct MyCurve{N} <: MyAbstractGeom{N} end
11+
struct MyLinearRing{N} <: MyAbstractGeom{N} end
12+
struct MyLineString{N} <: MyAbstractGeom{N} end
13+
struct MyPolygon{N} <: MyAbstractGeom{N} end
14+
struct MyMultiPoint{N} <: MyAbstractGeom{N} end
15+
struct MyMultiCurve{N} <: MyAbstractGeom{N} end
16+
struct MyMultiPolygon{N} <: MyAbstractGeom{N} end
17+
struct MyCollection{N} <: MyAbstractGeom{N} end
18+
struct MyFeature end
19+
struct MyFeatureCollection end
20+
21+
GeoInterfaceRecipes.@enable MyAbstractGeom
22+
GeoInterfaceRecipes.@enable MyFeature
23+
# Test legacy interface
24+
GeoInterfaceRecipes.@enable_geo_plots MyFeatureCollection
25+
26+
GeoInterface.isgeometry(::MyAbstractGeom) = true
27+
GeoInterface.is3d(::GeoInterface.AbstractGeometryTrait, ::MyAbstractGeom{N}) where {N} = N == 3
28+
GeoInterface.ncoord(::GeoInterface.AbstractGeometryTrait, geom::MyAbstractGeom{N}) where {N} = N
29+
GeoInterface.coordnames(::GeoInterface.AbstractGeometryTrait, ::MyAbstractGeom{2}) = (:X, :Y)
30+
GeoInterface.coordnames(::GeoInterface.AbstractGeometryTrait, ::MyAbstractGeom{3}) = (:X, :Y, :Z)
31+
32+
GeoInterface.geomtrait(::MyPoint) = GeoInterface.PointTrait()
33+
GeoInterface.getcoord(::GeoInterface.PointTrait, geom::MyPoint{2}, i::Integer) = (rand(1:10), rand(11:20))[i]
34+
GeoInterface.getcoord(::GeoInterface.PointTrait, geom::MyPoint{3}, i::Integer) = (rand(1:10), rand(11:20), rand(21:30))[i]
35+
36+
GeoInterface.geomtrait(::MyCurve) = GeoInterface.LineStringTrait()
37+
GeoInterface.ngeom(::GeoInterface.LineStringTrait, geom::MyCurve) = 3
38+
GeoInterface.getgeom(::GeoInterface.LineStringTrait, geom::MyCurve{N}, i) where {N} = MyPoint{N}()
39+
GeoInterface.convert(::Type{MyCurve}, ::GeoInterface.LineStringTrait, geom) = geom
40+
41+
GeoInterface.geomtrait(::MyLinearRing) = GeoInterface.LinearRingTrait()
42+
GeoInterface.ngeom(::GeoInterface.LinearRingTrait, geom::MyLinearRing) = 3
43+
GeoInterface.getgeom(::GeoInterface.LinearRingTrait, geom::MyLinearRing{N}, i) where {N} = MyPoint{N}()
44+
GeoInterface.convert(::Type{MyLinearRing}, ::GeoInterface.LinearRingTrait, geom) = geom
45+
46+
GeoInterface.geomtrait(::MyLineString) = GeoInterface.LineStringTrait()
47+
GeoInterface.ngeom(::GeoInterface.LineStringTrait, geom::MyLineString) = 3
48+
GeoInterface.getgeom(::GeoInterface.LineStringTrait, geom::MyLineString{N}, i) where {N} = MyPoint{N}()
49+
GeoInterface.convert(::Type{MyLineString}, ::GeoInterface.LineStringTrait, geom) = geom
50+
51+
GeoInterface.geomtrait(::MyPolygon) = GeoInterface.PolygonTrait()
52+
GeoInterface.ngeom(::GeoInterface.PolygonTrait, geom::MyPolygon) = 2
53+
GeoInterface.getgeom(::GeoInterface.PolygonTrait, geom::MyPolygon{N}, i) where {N} = MyCurve{N}()
54+
55+
GeoInterface.geomtrait(::MyMultiPolygon) = GeoInterface.MultiPolygonTrait()
56+
GeoInterface.ngeom(::GeoInterface.MultiPolygonTrait, geom::MyMultiPolygon) = 2
57+
GeoInterface.getgeom(::GeoInterface.MultiPolygonTrait, geom::MyMultiPolygon{N}, i) where {N} = MyPolygon{N}()
58+
59+
GeoInterface.geomtrait(::MyMultiPoint) = GeoInterface.MultiPointTrait()
60+
GeoInterface.ngeom(::GeoInterface.MultiPointTrait, geom::MyMultiPoint) = 10
61+
GeoInterface.getgeom(::GeoInterface.MultiPointTrait, geom::MyMultiPoint{N}, i) where {N} = MyPoint{N}()
62+
63+
GeoInterface.geomtrait(geom::MyCollection) = GeoInterface.GeometryCollectionTrait()
64+
GeoInterface.ncoord(::GeoInterface.GeometryCollectionTrait, geom::MyCollection{N}) where {N} = N
65+
GeoInterface.ngeom(::GeoInterface.GeometryCollectionTrait, geom::MyCollection) = 4
66+
GeoInterface.getgeom(::GeoInterface.GeometryCollectionTrait, geom::MyCollection{N}, i) where {N} = MyMultiPolygon{N}()
67+
68+
GeoInterface.trait(::MyFeature) = FeatureTrait()
69+
GeoInterface.trait(::MyFeatureCollection) = FeatureCollectionTrait()
70+
GeoInterface.getfeature(::GeoInterface.FeatureCollectionTrait, geom::MyFeatureCollection, i) = MyFeature()
71+
GeoInterface.getfeature(::GeoInterface.FeatureCollectionTrait, geom::MyFeatureCollection) = [MyFeature(), MyFeature()]
72+
GeoInterface.geometry(geom::MyFeature) = rand((MyPolygon{2}(), MyMultiPolygon{2}()))
73+
GeoInterface.nfeature(::GeoInterface.FeatureTrait, geom::MyFeature) = 1
74+
75+
@testset "plot" begin
76+
# We just check if they actually run
77+
# 2d
78+
plot(MyPoint{2}())
79+
plot(MyCurve{2}())
80+
plot(MyLinearRing{2}())
81+
plot(MyLineString{2}())
82+
plot(MyMultiPoint{2}())
83+
plot(MyPolygon{2}())
84+
plot(MyMultiPolygon{2}())
85+
plot(MyCollection{2}())
86+
# 3d
87+
plot(MyPoint{3}())
88+
plot(MyCurve{3}())
89+
plot(MyLinearRing{3}())
90+
plot(MyLineString{3}())
91+
plot(MyMultiPoint{3}())
92+
plot(MyPolygon{3}())
93+
plot(MyMultiPolygon{3}())
94+
plot(MyCollection{3}())
95+
plot(MyFeature())
96+
plot(MyFeatureCollection())
97+
end

0 commit comments

Comments
 (0)