Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions GeoInterfaceMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ version = "0.1.9"
[deps]
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[compat]
GeoInterface = "1"
GeometryBasics = "0.4.4, 0.5"
MakieCore = "0.5.1, 0.6, 0.7.1, 0.8, 0.9, 0.10"
Makie = "0.22, 0.23, 0.24"
julia = "1.6"

[extras]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
LibGEOS = "a90b1aa1-3769-5649-ba7e-abc5a9d163eb"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "CairoMakie", "Makie", "LibGEOS"]
test = ["Test", "CairoMakie", "LibGEOS"]
18 changes: 9 additions & 9 deletions GeoInterfaceMakie/src/GeoInterfaceMakie.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module GeoInterfaceMakie

using GeoInterface
import MakieCore as MC
import Makie as MC
import GeometryBasics as GB
import GeoInterface as GI

Expand Down Expand Up @@ -51,13 +51,13 @@ function _convert_array_arguments(plottrait, geoms::AbstractArray{T})::Tuple whe
end
if Missing <: T
return MC.convert_arguments(
plottrait,
plottrait,
map(
operator_nangeom_if_missing_or_func(
func_to_apply,
trait,
func_to_apply,
trait,
GI.ncoord(first(geoms_without_missings))
),
),
geoms
)
)
Expand Down Expand Up @@ -121,12 +121,12 @@ end

GeoInterfaceMakie.@enable(GeometryType)

Enable Makie based plotting for a type `Geom` that implements the geometry interface
Enable Makie based plotting for a type `Geom` that implements the geometry interface
defined in `GeoInterface`.

# Usage
```julia
struct MyGeometry
struct MyGeometry
...
end
# overload GeoInterface for MyGeometry
Expand Down Expand Up @@ -190,7 +190,7 @@ function _needs_multification_trait(geoms)
elseif GI.MultiPointTrait() ∈ traits || GI.PointTrait() ∈ traits
return true, GI.MultiPointTrait()
end
else
else
# A robust solution is to:
# - Traverse the array to find the first non-geometrycollection element
# If that fails, then introspect the first element as was done earlier, to
Expand Down Expand Up @@ -250,7 +250,7 @@ to_multipoint(::GeoInterface.PointTrait, geom) = GB.MultiPoint([GeoInterface.con
to_multipoint(::GeoInterface.MultiPointTrait, geom) = GeoInterface.convert(GB, geom)


# TODO
# TODO
# Features and Feature collections
# https://github.com/JuliaGeo/GeoInterface.jl/pull/72#issue-1406325596

Expand Down
13 changes: 6 additions & 7 deletions GeoInterfaceMakie/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import GeoInterfaceMakie
using Test
import LibGEOS
using LibGEOS
import GeoInterface as GI
using Makie, CairoMakie
Expand All @@ -10,8 +9,8 @@ GeoInterfaceMakie.@enable(LibGEOS.AbstractGeometry)

@testset "Makie plotting LibGEOS MultiLineString shows additional lines #83" begin
mls = readgeom("MULTILINESTRING ((0 0,3 0,3 3,0 3,0 0),(1 1,2 1,2 2,1 2,1 1))")
expected = [[0.0, 0.0], [3.0, 0.0], [3.0, 3.0], [0.0, 3.0], [0.0, 0.0],
[NaN, NaN],
expected = [[0.0, 0.0], [3.0, 0.0], [3.0, 3.0], [0.0, 3.0], [0.0, 0.0],
[NaN, NaN],
[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0], [1.0, 1.0]]

@test isequal(Makie.convert_arguments(Makie.Lines, mls), (expected,))
Expand All @@ -28,8 +27,8 @@ end
unitsquare,
GI.difference(bigsquare, smallsquare),
LibGEOS.boundary(unitsquare),
multipolygon,
point,
multipolygon,
point,
multipoint,
]
fig = Figure()
Expand All @@ -51,7 +50,7 @@ end

@test_nowarn Makie.update_state_before_display!(fig)
@test_nowarn Makie.colorbuffer(fig.scene)

fig
end

Expand Down Expand Up @@ -87,7 +86,7 @@ end
@test_nowarn Makie.plot(lines)
polys = [GI.Polygon([GI.LinearRing(Point2d[(1, 2), (3, 4), (5, 5), (1, 2)])]), GI.Polygon([GI.LinearRing(Point2d[(7, 8), (9, 10), (11, 11), (7, 8)])]), missing]
@test_nowarn Makie.plot(polys)
# Now we test that appropriate "missing" (i.e., NaN) polygons
# Now we test that appropriate "missing" (i.e., NaN) polygons
# are inserted in the correct place, so that we have the same
# number of elements post conversion as pre conversion. This
# allows colors to be propagated correctly through the array.
Expand Down
Loading