-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
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 dmnThis 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
| function sideof(points, object::GeometryOrDomain) | |
| bbox = boundingbox(object) | |
| isin = [point β bbox for point in points] | |
| inds = findall(isin) | |
| side = fill(OUT, length(isin)) | |
| side[inds] .= sidewithinbox(collectat(points, inds), object) | |
| side | |
| end |
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
Reactions are currently unavailable