turf-ruby 0.8.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -0
  3. data/README.md +159 -139
  4. data/lib/turf/along.rb +10 -3
  5. data/lib/turf/angle.rb +8 -0
  6. data/lib/turf/area.rb +4 -1
  7. data/lib/turf/bbox.rb +36 -0
  8. data/lib/turf/bbox_clip.rb +74 -0
  9. data/lib/turf/bbox_polygon.rb +41 -0
  10. data/lib/turf/bearing.rb +5 -2
  11. data/lib/turf/bezier_spline.rb +8 -0
  12. data/lib/turf/boolean_clockwise.rb +8 -0
  13. data/lib/turf/boolean_concave.rb +8 -0
  14. data/lib/turf/boolean_contains.rb +52 -0
  15. data/lib/turf/boolean_crosses.rb +8 -0
  16. data/lib/turf/boolean_disjoint.rb +8 -0
  17. data/lib/turf/boolean_equal.rb +8 -0
  18. data/lib/turf/boolean_intersects.rb +8 -0
  19. data/lib/turf/boolean_overlap.rb +8 -0
  20. data/lib/turf/boolean_parallel.rb +8 -0
  21. data/lib/turf/boolean_point_in_polygon.rb +5 -3
  22. data/lib/turf/boolean_point_on_line.rb +8 -0
  23. data/lib/turf/boolean_touches.rb +8 -0
  24. data/lib/turf/boolean_valid.rb +8 -0
  25. data/lib/turf/boolean_within.rb +8 -0
  26. data/lib/turf/buffer.rb +8 -0
  27. data/lib/turf/center.rb +32 -0
  28. data/lib/turf/center_mean.rb +8 -0
  29. data/lib/turf/center_median.rb +8 -0
  30. data/lib/turf/center_of_mass.rb +8 -0
  31. data/lib/turf/centroid.rb +5 -2
  32. data/lib/turf/circle.rb +5 -2
  33. data/lib/turf/clean_coords.rb +8 -0
  34. data/lib/turf/clone.rb +8 -0
  35. data/lib/turf/clusters.rb +32 -0
  36. data/lib/turf/clusters_dbscan.rb +8 -0
  37. data/lib/turf/clusters_kmeans.rb +8 -0
  38. data/lib/turf/collect.rb +8 -0
  39. data/lib/turf/combine.rb +8 -0
  40. data/lib/turf/concave.rb +8 -0
  41. data/lib/turf/convex.rb +8 -0
  42. data/lib/turf/destination.rb +6 -3
  43. data/lib/turf/difference.rb +8 -0
  44. data/lib/turf/directional_mean.rb +8 -0
  45. data/lib/turf/dissolve.rb +8 -0
  46. data/lib/turf/distance.rb +5 -2
  47. data/lib/turf/distance_weight.rb +12 -0
  48. data/lib/turf/ellipse.rb +8 -0
  49. data/lib/turf/envelope.rb +8 -0
  50. data/lib/turf/explode.rb +29 -0
  51. data/lib/turf/flatten.rb +8 -0
  52. data/lib/turf/flip.rb +8 -0
  53. data/lib/turf/geojson_rbush.rb +8 -0
  54. data/lib/turf/great_circle.rb +8 -0
  55. data/lib/turf/helpers.rb +166 -26
  56. data/lib/turf/hex_grid.rb +8 -0
  57. data/lib/turf/interpolate.rb +8 -0
  58. data/lib/turf/intersect.rb +8 -0
  59. data/lib/turf/invariant.rb +127 -1
  60. data/lib/turf/isobands.rb +8 -0
  61. data/lib/turf/isolines.rb +8 -0
  62. data/lib/turf/kinks.rb +8 -0
  63. data/lib/turf/length.rb +6 -3
  64. data/lib/turf/lib/lineclip.rb +118 -0
  65. data/lib/turf/line_arc.rb +8 -0
  66. data/lib/turf/line_chunk.rb +8 -0
  67. data/lib/turf/line_intersect.rb +8 -0
  68. data/lib/turf/line_offset.rb +8 -0
  69. data/lib/turf/line_overlap.rb +8 -0
  70. data/lib/turf/line_segment.rb +8 -0
  71. data/lib/turf/line_slice.rb +8 -0
  72. data/lib/turf/line_slice_along.rb +8 -0
  73. data/lib/turf/line_split.rb +8 -0
  74. data/lib/turf/line_to_polygon.rb +8 -0
  75. data/lib/turf/mask.rb +8 -0
  76. data/lib/turf/meta.rb +445 -79
  77. data/lib/turf/midpoint.rb +8 -0
  78. data/lib/turf/moran_index.rb +8 -0
  79. data/lib/turf/nearest_neighbor_analysis.rb +8 -0
  80. data/lib/turf/nearest_point.rb +8 -0
  81. data/lib/turf/nearest_point_on_line.rb +8 -0
  82. data/lib/turf/nearest_point_to_line.rb +8 -0
  83. data/lib/turf/planepoint.rb +8 -0
  84. data/lib/turf/point_grid.rb +8 -0
  85. data/lib/turf/point_on_feature.rb +8 -0
  86. data/lib/turf/point_to_line_distance.rb +8 -0
  87. data/lib/turf/point_to_polygon_distance.rb +8 -0
  88. data/lib/turf/points_within_polygon.rb +8 -0
  89. data/lib/turf/polygon_smooth.rb +8 -0
  90. data/lib/turf/polygon_tangents.rb +8 -0
  91. data/lib/turf/polygon_to_line.rb +20 -0
  92. data/lib/turf/polygonize.rb +8 -0
  93. data/lib/turf/projection.rb +12 -0
  94. data/lib/turf/quadrat_analysis.rb +8 -0
  95. data/lib/turf/random.rb +20 -0
  96. data/lib/turf/rectangle_grid.rb +8 -0
  97. data/lib/turf/rewind.rb +8 -0
  98. data/lib/turf/rhumb_bearing.rb +8 -0
  99. data/lib/turf/rhumb_destination.rb +8 -0
  100. data/lib/turf/rhumb_distance.rb +8 -0
  101. data/lib/turf/sample.rb +8 -0
  102. data/lib/turf/sector.rb +8 -0
  103. data/lib/turf/shortest_path.rb +8 -0
  104. data/lib/turf/simplify.rb +8 -0
  105. data/lib/turf/square.rb +42 -0
  106. data/lib/turf/square_grid.rb +8 -0
  107. data/lib/turf/standard_deviational_ellipse.rb +8 -0
  108. data/lib/turf/tag.rb +8 -0
  109. data/lib/turf/tesselate.rb +8 -0
  110. data/lib/turf/tin.rb +8 -0
  111. data/lib/turf/transform_rotate.rb +8 -0
  112. data/lib/turf/transform_scale.rb +8 -0
  113. data/lib/turf/transform_translate.rb +8 -0
  114. data/lib/turf/triangle_grid.rb +8 -0
  115. data/lib/turf/truncate.rb +3 -0
  116. data/lib/turf/union.rb +8 -0
  117. data/lib/turf/unkink_polygon.rb +8 -0
  118. data/lib/turf/version.rb +2 -1
  119. data/lib/turf/voronoi.rb +8 -0
  120. data/lib/turf.rb +2 -0
  121. data/lib/turf_ruby.rb +107 -3
  122. metadata +105 -2
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def nearest_point(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def nearest_point_on_line(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def nearest_point_to_line(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def planepoint(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def point_grid(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def point_on_feature(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def point_to_line_distance(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def point_to_polygon_distance(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def points_within_polygon(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def polygon_smooth(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def polygon_tangents(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def polygon_to_line(*args)
6
+ raise NotImplementedError
7
+ end
8
+
9
+ def coords_to_line(*args)
10
+ raise NotImplementedError
11
+ end
12
+
13
+ def multi_polygon_to_line(*args)
14
+ raise NotImplementedError
15
+ end
16
+
17
+ def single_polygon_to_line(*args)
18
+ raise NotImplementedError
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def polygonize(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def to_mercator(*args)
6
+ raise NotImplementedError
7
+ end
8
+
9
+ def to_wgs84(*args)
10
+ raise NotImplementedError
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def quadrat_analysis(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def random_position(*args)
6
+ raise NotImplementedError
7
+ end
8
+
9
+ def random_point(*args)
10
+ raise NotImplementedError
11
+ end
12
+
13
+ def random_polygon(*args)
14
+ raise NotImplementedError
15
+ end
16
+
17
+ def random_line_string(*args)
18
+ raise NotImplementedError
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def rectangle_grid(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def rewind(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def rhumb_bearing(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def rhumb_destination(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def rhumb_distance(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def sample(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def sector(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def shortest_path(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def simplify(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ # frozen_string_literal: true
6
+
7
+ # Takes a bounding box and calculates the minimum square bounding box that
8
+ # would contain the input.
9
+ #
10
+ # @param [Array<Float>] bbox extent in [west, south, east, north] order
11
+ # @return [Array<Float>] a square surrounding `bbox`
12
+ # @example
13
+ # bbox = [-20, -20, -15, 0]
14
+ # squared = square(bbox)
15
+ #
16
+ # #addToMap
17
+ # # add_to_map = [bbox_polygon(bbox), bbox_polygon(squared)]
18
+ def square(bbox)
19
+ west, south, east, north = bbox
20
+
21
+ horizontal_distance = distance([west, south], [east, south])
22
+ vertical_distance = distance([west, south], [west, north])
23
+
24
+ if horizontal_distance >= vertical_distance
25
+ vertical_midpoint = (south + north) / 2.0
26
+ [
27
+ west,
28
+ vertical_midpoint - ((east - west) / 2.0),
29
+ east,
30
+ vertical_midpoint + ((east - west) / 2.0),
31
+ ]
32
+ else
33
+ horizontal_midpoint = (west + east) / 2.0
34
+ [
35
+ horizontal_midpoint - ((north - south) / 2.0),
36
+ south,
37
+ horizontal_midpoint + ((north - south) / 2.0),
38
+ north,
39
+ ]
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def square_grid(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def standard_deviational_ellipse(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
data/lib/turf/tag.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def tag(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def tesselate(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
data/lib/turf/tin.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def tin(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def transform_rotate(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def transform_scale(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def transform_translate(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def triangle_grid(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
data/lib/turf/truncate.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "meta"
4
+ require_relative "helpers"
5
+
3
6
  # :nodoc:
4
7
  module Turf
5
8
  # Takes a GeoJSON Feature or FeatureCollection and truncates the precision of the geometry.
data/lib/turf/union.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def union(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def unkink_polygon(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
data/lib/turf/version.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nodoc:
3
4
  module Turf
4
5
  # Version of turf-ruby
5
- VERSION = "0.8.1"
6
+ VERSION = "1.0.0"
6
7
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Turf
5
+ def voronoi(*args)
6
+ raise NotImplementedError
7
+ end
8
+ end
data/lib/turf.rb CHANGED
@@ -8,6 +8,8 @@ module Turf
8
8
  # Error thrown by turf-ruby
9
9
  class Error < StandardError; end
10
10
 
11
+ class NotImplementedError < Error; end
12
+
11
13
  extend self
12
14
 
13
15
  private
data/lib/turf_ruby.rb CHANGED
@@ -1,21 +1,125 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "turf"
4
+
3
5
  # Functions should be put into module with same package name in Turf.js
4
6
  #
5
7
  # https://github.com/Turfjs/turf/tree/master/packages
6
8
  #
9
+
10
+ require "turf/lib/lineclip"
11
+
7
12
  require "turf/along"
13
+ require "turf/angle"
8
14
  require "turf/area"
15
+ require "turf/bbox_clip"
16
+ require "turf/bbox_polygon"
17
+ require "turf/bbox"
9
18
  require "turf/bearing"
19
+ require "turf/bezier_spline"
20
+ require "turf/boolean_clockwise"
21
+ require "turf/boolean_concave"
22
+ require "turf/boolean_contains"
23
+ require "turf/boolean_crosses"
24
+ require "turf/boolean_disjoint"
25
+ require "turf/boolean_equal"
26
+ require "turf/boolean_intersects"
27
+ require "turf/boolean_overlap"
28
+ require "turf/boolean_parallel"
10
29
  require "turf/boolean_point_in_polygon"
30
+ require "turf/boolean_point_on_line"
31
+ require "turf/boolean_touches"
32
+ require "turf/boolean_valid"
33
+ require "turf/boolean_within"
34
+ require "turf/buffer"
35
+ require "turf/center_mean"
36
+ require "turf/center_median"
37
+ require "turf/center_of_mass"
38
+ require "turf/center"
11
39
  require "turf/centroid"
12
40
  require "turf/circle"
41
+ require "turf/clean_coords"
42
+ require "turf/clone"
43
+ require "turf/clusters_dbscan"
44
+ require "turf/clusters_kmeans"
45
+ require "turf/clusters"
46
+ require "turf/collect"
47
+ require "turf/combine"
48
+ require "turf/concave"
49
+ require "turf/convex"
13
50
  require "turf/destination"
51
+ require "turf/difference"
52
+ require "turf/directional_mean"
53
+ require "turf/dissolve"
54
+ require "turf/distance_weight"
14
55
  require "turf/distance"
56
+ require "turf/ellipse"
57
+ require "turf/envelope"
58
+ require "turf/explode"
59
+ require "turf/flatten"
60
+ require "turf/flip"
61
+ require "turf/geojson_rbush"
62
+ require "turf/great_circle"
15
63
  require "turf/helpers"
64
+ require "turf/hex_grid"
65
+ require "turf/interpolate"
66
+ require "turf/intersect"
16
67
  require "turf/invariant"
68
+ require "turf/isobands"
69
+ require "turf/isolines"
70
+ require "turf/kinks"
17
71
  require "turf/length"
18
- require "turf/truncate"
72
+ require "turf/line_arc"
73
+ require "turf/line_chunk"
74
+ require "turf/line_intersect"
75
+ require "turf/line_offset"
76
+ require "turf/line_overlap"
77
+ require "turf/line_segment"
78
+ require "turf/line_slice_along"
79
+ require "turf/line_slice"
80
+ require "turf/line_split"
81
+ require "turf/line_to_polygon"
82
+ require "turf/mask"
19
83
  require "turf/meta"
20
-
21
- require "turf"
84
+ require "turf/midpoint"
85
+ require "turf/moran_index"
86
+ require "turf/nearest_neighbor_analysis"
87
+ require "turf/nearest_point_on_line"
88
+ require "turf/nearest_point_to_line"
89
+ require "turf/nearest_point"
90
+ require "turf/planepoint"
91
+ require "turf/point_grid"
92
+ require "turf/point_on_feature"
93
+ require "turf/point_to_line_distance"
94
+ require "turf/point_to_polygon_distance"
95
+ require "turf/points_within_polygon"
96
+ require "turf/polygon_smooth"
97
+ require "turf/polygon_tangents"
98
+ require "turf/polygon_to_line"
99
+ require "turf/polygonize"
100
+ require "turf/projection"
101
+ require "turf/quadrat_analysis"
102
+ require "turf/random"
103
+ require "turf/rectangle_grid"
104
+ require "turf/rewind"
105
+ require "turf/rhumb_bearing"
106
+ require "turf/rhumb_destination"
107
+ require "turf/rhumb_distance"
108
+ require "turf/sample"
109
+ require "turf/sector"
110
+ require "turf/shortest_path"
111
+ require "turf/simplify"
112
+ require "turf/square_grid"
113
+ require "turf/square"
114
+ require "turf/standard_deviational_ellipse"
115
+ require "turf/tag"
116
+ require "turf/tesselate"
117
+ require "turf/tin"
118
+ require "turf/transform_rotate"
119
+ require "turf/transform_scale"
120
+ require "turf/transform_translate"
121
+ require "turf/triangle_grid"
122
+ require "turf/truncate"
123
+ require "turf/union"
124
+ require "turf/unkink_polygon"
125
+ require "turf/voronoi"