Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into as/dataapi
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Aug 10, 2024
2 parents 060843f + 7bc5cad commit c6e7d73
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Shapefile"
uuid = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
license = "MIT"
version = "0.13.0"
version = "0.13.1"

[deps]
DBFTables = "75c7ada1-017a-5fb6-b8c7-2125ff2d6c93"
Expand Down Expand Up @@ -40,6 +40,7 @@ julia = "1.9"

[extras]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand All @@ -48,4 +49,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[targets]
test = ["ArchGDAL", "DataFrames", "Makie", "Plots", "RemoteFiles", "ZipFile", "Test"]
test = ["ArchGDAL", "Aqua", "DataFrames", "Makie", "Plots", "RemoteFiles", "ZipFile", "Test"]
2 changes: 1 addition & 1 deletion ext/ShapefileMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GeoInterfaceMakie.@enable Shapefile.LinearRing
Makie.plottype(tbl::Shapefile.Table) = Makie.plottype(Shapefile.shapes(tbl))
Makie.plottype(shp::Shapefile.Handle) = Makie.plottype(Shapefile.shapes(shp))

for T in (Any, Union{Type{Any}, Type{<:Makie.AbstractPlot}}, Type{<:Makie.Poly}, Type{<:Makie.Lines}, Makie.PointBased)
for T in (Makie.ConversionTrait, Type{<:Makie.AbstractPlot}, Type{<:Makie.Poly}, Type{<:Makie.Lines}, Makie.PointBased)
@eval begin
Makie.convert_arguments(t::$T, tbl::Shapefile.Table) =
Makie.convert_arguments(t, Shapefile.shapes(tbl))
Expand Down
3 changes: 1 addition & 2 deletions src/polygons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ struct SubPolygon{L<:LinearRing} <: AbstractVector{L}
end
GI.isgeometry(::Type{<:SubPolygon}) = true
GI.geomtrait(::SubPolygon) = GI.PolygonTrait()
GI.is3d(::GI.PolygonTrait, p::SubPolygon) = GI.is3d(first(p))
GI.ismeasured(::GI.PolygonTrait, p::SubPolygon) = GI.measures(first(p))
GI.ncoord(::GI.PolygonTrait, ::SubPolygon{<:LinearRing{P}}) where {P} = _ncoord(P)
GI.ngeom(::GI.PolygonTrait, sp::SubPolygon) = length(sp)
# `is3d` and `ismeasured` are defined in `extents.jl`
Base.@propagate_inbounds GI.getgeom(::GI.PolygonTrait, sp::SubPolygon, i::Integer) =
getindex(sp, i)

Expand Down
22 changes: 22 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ using Shapefile
using GeoFormatTypes
using Test

import Aqua

const GI = GeoInterface

import GeoInterfaceRecipes # for ambiguity ignore list only

using Shapefile: Point, PointM, PointZ, Polygon, PolygonM, PolygonZ, Polyline,
PolylineM, PolylineZ, MultiPoint, MultiPointM, MultiPointZ,
Expand Down Expand Up @@ -133,6 +136,8 @@ test_shapes = Dict(
SubPolygon => SubPolygon([LinearRing{Point}(view(points, 1:4))]),
)

@testset "Shapefile.jl" begin

@testset "GeoInterface compatibility" begin
foreach(test_shapes) do (k, s)
@test GeoInterface.testgeometry(s)
Expand Down Expand Up @@ -255,3 +260,20 @@ include("table.jl")
include("writer.jl")

cleanup()

@testset "Aqua.jl" begin
Aqua.test_all(
Shapefile;
# Exclude ambiguities from imported packages as well as GeoInterfaceRecipes,
# since the ambiguities there are not the kind that would actually cause problems.
ambiguities = (; recursive = false, exclude = [GeoInterfaceRecipes.RecipesBase.apply_recipe,]),
# GeoInterfaceRecipes and GeoInterfaceMakie are considered stale dependencies
# but are actually used in extensions on Plots and Makie respectively, so we need them!
stale_deps = (; ignore = [:GeoInterfaceRecipes, :GeoInterfaceMakie]),
# too much headache for now - will go through this again if I'm sure
# CompatHelper is working, but the tests are good flags for new versions with
# suspicious behaviour.
deps_compat = false,
)
end
end
2 changes: 1 addition & 1 deletion test/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ne_cities = Shapefile.Table(path(natural_earth, "ne_cities_shp"))
if eltype(a) <: Union{Missing, String}
# ne_cities has non-ascii characters
@test all(isequal.(
replace.(skipmissing(a), !isascii => x -> '_' ^ textwidth(x)),
skipmissing(a),#replace.(skipmissing(a), !isascii => x -> '_' ^ textwidth(x)),
skipmissing(b)
))
else
Expand Down

0 comments on commit c6e7d73

Please sign in to comment.