You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
are inconsistent with the documentation for Base.in. Since it is a shame to be inconsistent (because generic programs may break since they may rely on a consistency of iterate and in, and since it is a shame to lose the notation of point ∈ polygon, I propose ensuring that either
a type represents an infinite set of points and does not implement iterate
a type represents a finite set of points and implements iterate
The text was updated successfully, but these errors were encountered:
julia> Base.IteratorSize(::Type{<:GeometryBasics.Polygon}) = Base.SizeUnknown() # or define `length(::Polygon)` This is required by the [iterator interface](https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-iteration)
julia> p =Polygon([Point(0,0), Point(0, 1), Point(1, 0)])
Polygon{2,Int64,Point{2,Int64},LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}},2,1,Array{Point{2,Int64},1}}}},Array{LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}},2,1,Array{Point{2,Int64},1}}}},1}}(GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}}[Line([0, 0] => [0, 1]), Line([0, 1] => [1, 0])], LineString{2,Int64,Point{2,Int64},Base.ReinterpretArray{GeometryBasics.Ngon{2,Int64,2,Point{2,Int64}},1,Tuple{Point{2,Int64},Point{2,Int64}},TupleView{Tuple{Point{2,Int64},Point{2,Int64}},2,1,Array{Point{2,Int64},1}}}}[])
julia>Point(.2,.2) in p
false
julia>Point(0,0) in p
true
julia> (0,0) in p
false
julia> [0,0] in p
true
The definitions at
GeometryBasics.jl/src/basic_types.jl
Lines 47 to 49 in 234699e
are convenient, but they induce a non-geometric definition of
Base.in
, due to the fallback definition https://github.com/JuliaLang/julia/blob/4b739e711a7241f48ec0525e97c44cc870a9af99/base/operators.jl#L1109-L1120 and furthermore a geometric definition like the followinghttps://github.com/JuliaGeometry/GeometryTypes.jl/blob/4f1ba71d7df1341087f84974f869ea7a421eafa8/src/polygon.jl#L21-L28
are inconsistent with the documentation for
Base.in
. Since it is a shame to be inconsistent (because generic programs may break since they may rely on a consistency ofiterate
andin
, and since it is a shame to lose the notation ofpoint ∈ polygon
, I propose ensuring that eitheriterate
iterate
The text was updated successfully, but these errors were encountered: