Open
Description
I am trying to do some benchmarks to improve the performance of sideof
(see #988), and I found method errors very early with the following example, probably caused by missing methods for sideof
:
using Meshes, GeoArtifacts
dmn = NaturalEarth.get("admin_0_countries", 110).geometry
point_nemo = Point(LatLon(−48.8767,−123.3933))
point_nemo in dmn
This throws a first error
ERROR: TypeError: in typeassert, expected Integer, got a value of type Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}
Stacktrace:
[1] _similar_shape(itr::Base.Generator{Point{🌐, GeodeticLatLon{…}}, Meshes.var"#309#310"{Box{…}}}, ::Base.HasLength)
@ Base ./array.jl:652
[2] collect(itr::Base.Generator{Point{🌐, GeodeticLatLon{…}}, Meshes.var"#309#310"{Box{…}}})
@ Base ./array.jl:779
[3] sideof(points::Point{🌐, GeodeticLatLon{…}}, object::MultiRing{🌐, GeodeticLatLon{…}, Ring{…}})
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/sideof.jl:163
[4] in
@ ~/.julia/packages/Meshes/FJ9DT/src/predicates/in.jl:10 [inlined]
[5] (::Meshes.var"#280#281"{Point{…}})(e::PolyArea{🌐, GeodeticLatLon{…}, Ring{…}, Vector{…}})
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/predicates/in.jl:160
[6] _any(f::Meshes.var"#280#281"{Point{…}}, itr::GeometrySet{🌐, GeodeticLatLon{…}, Geometry{…}}, ::Colon)
@ Base ./reduce.jl:1237
[7] any
@ ./reduce.jl:1228 [inlined]
[8] in(p::Point{🌐, GeodeticLatLon{…}}, d::GeometrySet{🌐, GeodeticLatLon{…}, Geometry{…}})
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/predicates/in.jl:160
[9] top-level scope
@ REPL[26]:1
Some type information was truncated. Use `show(err)` to see complete types.
which is caused by this fallback method not working when a single Point
is provided:
Lines 161 to 168 in c0c9c2d
This can be easily fixed by creating a method for the single point that just wraps it in an iterable (here in the REPL for simplicity)
julia> @eval Meshes sideof(p::Point, obj::GeometryOrDomain) = sideof((p,), obj)
After fixing that method, another error appears though
julia> point_nemo in dmn
ERROR: MethodError: no method matching sidewithinbox(::Vector{Point{…}}, ::MultiRing{🌐, GeodeticLatLon{…}, Ring{…}}) The function `sidewithinbox` exists, but no method is defined for this combination of argument types.
Closest candidates are:
sidewithinbox(::Any, ::Mesh)
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/sideof.jl:172
sidewithinbox(::Any, ::Ring)
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/sideof.jl:170
Stacktrace:
[1] sideof(points::Tuple{Point{…}}, object::MultiRing{🌐, GeodeticLatLon{…}, Ring{…}})
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/sideof.jl:166
[2] sideof(p::Point{🌐, GeodeticLatLon{…}}, obj::MultiRing{🌐, GeodeticLatLon{…}, Ring{…}})
@ Meshes ./REPL[27]:1
[3] in
@ ~/.julia/packages/Meshes/FJ9DT/src/predicates/in.jl:10 [inlined]
[4] (::Meshes.var"#280#281"{Point{…}})(e::PolyArea{🌐, GeodeticLatLon{…}, Ring{…}, Vector{…}})
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/predicates/in.jl:160
[5] _any(f::Meshes.var"#280#281"{Point{…}}, itr::GeometrySet{🌐, GeodeticLatLon{…}, Geometry{…}}, ::Colon)
@ Base ./reduce.jl:1237
[6] any
@ ./reduce.jl:1228 [inlined]
[7] in(p::Point{🌐, GeodeticLatLon{…}}, d::GeometrySet{🌐, GeodeticLatLon{…}, Geometry{…}})
@ Meshes ~/.julia/packages/Meshes/FJ9DT/src/predicates/in.jl:160
[8] top-level scope
@ REPL[28]:1
Some type information was truncated. Use `show(err)` to see complete types.
which again seems to be caused by some missing method implemented