Module: RGeo::Cartesian::LineStringMethods

Included in:
LineImpl, LineStringImpl, LinearRingImpl
Defined in:
lib/rgeo/cartesian/feature_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#crosses?(rhs) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
92
93
94
95
96
# File 'lib/rgeo/cartesian/feature_methods.rb', line 89

def crosses?(rhs)
  case rhs
  when Feature::LineString
    crosses_line_string?(rhs)
  else
    super
  end
end

#lengthObject



85
86
87
# File 'lib/rgeo/cartesian/feature_methods.rb', line 85

def length
  segments.inject(0.0) { |sum, seg| sum + seg.length }
end

#segmentsObject



68
69
70
71
72
# File 'lib/rgeo/cartesian/feature_methods.rb', line 68

def segments
  @segments ||= (0..num_points - 2).map do |i|
    Segment.new(point_n(i), point_n(i + 1))
  end
end

#simple?Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
80
81
82
83
# File 'lib/rgeo/cartesian/feature_methods.rb', line 74

def simple?
  # Use a SweeplineIntersector to determine if there are any self-intersections
  # in the ring. The GeometryGraph of the ring could be used by comparing the
  # edges to number of segments (graph.incident_edges.length == segments.length),
  # but this adds computational and memory overhead if graph isn't already memoized.
  # Since graph is not used elsewhere in LineStringMethods, we will just use the
  # SweeplineIntersector for now.
  li = SweeplineIntersector.new(segments)
  li.proper_intersections.empty?
end