Class: NSWTopo::GeoJSON::MultiLineString
- Inherits:
-
Object
- Object
- NSWTopo::GeoJSON::MultiLineString
show all
- Includes:
- StraightSkeleton
- Defined in:
- lib/nswtopo/gis/geojson/multi_line_string.rb
Constant Summary
StraightSkeleton::DEFAULT_ROUNDING_ANGLE
Instance Method Summary
collapse
Instance Method Details
#buffer(*margins, **options) ⇒ Object
17
18
19
|
# File 'lib/nswtopo/gis/geojson/multi_line_string.rb', line 17
def buffer(*margins, **options)
MultiLineString.new(@coordinates + @coordinates.map(&:reverse), @properties).offset(*margins, **options)
end
|
#length ⇒ Object
6
7
8
|
# File 'lib/nswtopo/gis/geojson/multi_line_string.rb', line 6
def length
@coordinates.sum(&:path_length)
end
|
#offset(*margins, **options) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/nswtopo/gis/geojson/multi_line_string.rb', line 10
def offset(*margins, **options)
linestrings = margins.inject Nodes.new(@coordinates) do |nodes, margin|
nodes.progress limit: margin, **options.slice(:rounding_angle, :cutoff_angle)
end.readout
MultiLineString.new linestrings, @properties
end
|
#samples(interval) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/nswtopo/gis/geojson/multi_line_string.rb', line 30
def samples(interval)
points = @coordinates.flat_map do |linestring|
distance = linestring.path_length
linestring.sample_at(interval, along: true).map do |point, along|
[point, (2 * along - distance).abs - distance]
end
end.sort_by(&:last).map(&:first)
MultiPoint.new points, @properties
end
|
#smooth(margin, **options) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/nswtopo/gis/geojson/multi_line_string.rb', line 21
def smooth(margin, **options)
linestrings = Nodes.new(@coordinates).tap do |nodes|
nodes.progress **options.slice(:rounding_angle).merge(limit: margin)
nodes.progress **options.slice(:rounding_angle, :cutoff_angle).merge(limit: -2 * margin)
nodes.progress **options.slice(:rounding_angle, :cutoff_angle).merge(limit: margin)
end.readout
MultiLineString.new linestrings, @properties
end
|