53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/rgeo/cartesian/feature_methods.rb', line 53
def is_simple?
segs_ = _segments
len_ = segs_.length
return false if segs_.any?(&:degenerate?)
return true if len_ == 1
return segs_[0].s != segs_[1].e if len_ == 2
segs_.each_with_index do |seg_, index_|
nindex_ = index_ + 1
nindex_ = nil if nindex_ == len_
return false if nindex_ && seg_.contains_point?(segs_[nindex_].e)
pindex_ = index_ - 1
pindex_ = nil if pindex_ < 0
return false if pindex_ && seg_.contains_point?(segs_[pindex_].s)
next unless nindex_
oindex_ = nindex_ + 1
while oindex_ < len_
oseg_ = segs_[oindex_]
return false if !(index_ == 0 && oindex_ == len_ - 1 && seg_.s == oseg_.e) && seg_.intersects_segment?(oseg_)
oindex_ += 1
end
end
true
end
|