@sentryware/s2-node 0.0.6

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 (471) hide show
  1. package/.circleci/config.yml +45 -0
  2. package/.dockerignore +1 -0
  3. package/.gitmodules +3 -0
  4. package/CHANGELOG.md +33 -0
  5. package/LICENSE +201 -0
  6. package/README.md +147 -0
  7. package/binding.gyp +170 -0
  8. package/docker/Dockerfile.node20.test +8 -0
  9. package/docker/Dockerfile.node22.test +8 -0
  10. package/docker/Dockerfile.node24.test +8 -0
  11. package/index.d.ts +117 -0
  12. package/index.js +6 -0
  13. package/jest.config.js +184 -0
  14. package/package.json +43 -0
  15. package/publish-linux.sh +18 -0
  16. package/publish-osx.sh +19 -0
  17. package/src/builder.cc +84 -0
  18. package/src/builder.h +29 -0
  19. package/src/cell.cc +71 -0
  20. package/src/cell.h +26 -0
  21. package/src/cell_id.cc +210 -0
  22. package/src/cell_id.h +44 -0
  23. package/src/cell_union.cc +237 -0
  24. package/src/cell_union.h +34 -0
  25. package/src/earth.cc +185 -0
  26. package/src/earth.h +33 -0
  27. package/src/latlng.cc +132 -0
  28. package/src/latlng.h +28 -0
  29. package/src/loop.cc +51 -0
  30. package/src/loop.h +21 -0
  31. package/src/point.cc +69 -0
  32. package/src/point.h +23 -0
  33. package/src/polygon.cc +36 -0
  34. package/src/polygon.h +20 -0
  35. package/src/polyline.cc +186 -0
  36. package/src/polyline.h +34 -0
  37. package/src/region_coverer.cc +450 -0
  38. package/src/region_coverer.h +56 -0
  39. package/src/s2.cc +27 -0
  40. package/test/Cell.test.js +37 -0
  41. package/test/CellId.test.js +135 -0
  42. package/test/CellUnion.test.js +150 -0
  43. package/test/Earth.test.js +62 -0
  44. package/test/LatLng.test.js +45 -0
  45. package/test/Point.test.js +14 -0
  46. package/test/Polyline.test.js +78 -0
  47. package/test/RegionCoverer.test.js +301 -0
  48. package/test.sh +16 -0
  49. package/third_party/s2geometry/.travis.yml +163 -0
  50. package/third_party/s2geometry/AUTHORS +13 -0
  51. package/third_party/s2geometry/CONTRIBUTING.md +65 -0
  52. package/third_party/s2geometry/CONTRIBUTORS +30 -0
  53. package/third_party/s2geometry/LICENSE +202 -0
  54. package/third_party/s2geometry/NOTICE +5 -0
  55. package/third_party/s2geometry/README.md +127 -0
  56. package/third_party/s2geometry/doc/examples/point_index.cc +44 -0
  57. package/third_party/s2geometry/doc/examples/term_index.cc +99 -0
  58. package/third_party/s2geometry/doc/examples/term_index.py +101 -0
  59. package/third_party/s2geometry/src/python/coder.i +125 -0
  60. package/third_party/s2geometry/src/python/pywraps2_test.py +786 -0
  61. package/third_party/s2geometry/src/python/s2.i +37 -0
  62. package/third_party/s2geometry/src/python/s2_common.i +756 -0
  63. package/third_party/s2geometry/src/s2/_fp_contract_off.h +60 -0
  64. package/third_party/s2geometry/src/s2/base/casts.h +318 -0
  65. package/third_party/s2geometry/src/s2/base/commandlineflags.h +67 -0
  66. package/third_party/s2geometry/src/s2/base/integral_types.h +31 -0
  67. package/third_party/s2geometry/src/s2/base/log_severity.h +40 -0
  68. package/third_party/s2geometry/src/s2/base/logging.h +173 -0
  69. package/third_party/s2geometry/src/s2/base/mutex.h +61 -0
  70. package/third_party/s2geometry/src/s2/base/port.h +999 -0
  71. package/third_party/s2geometry/src/s2/base/spinlock.h +60 -0
  72. package/third_party/s2geometry/src/s2/base/stringprintf.cc +107 -0
  73. package/third_party/s2geometry/src/s2/base/stringprintf.h +53 -0
  74. package/third_party/s2geometry/src/s2/base/strtoint.cc +65 -0
  75. package/third_party/s2geometry/src/s2/base/strtoint.h +106 -0
  76. package/third_party/s2geometry/src/s2/base/timer.h +50 -0
  77. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.cc +164 -0
  78. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.h +110 -0
  79. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector_test.cc +232 -0
  80. package/third_party/s2geometry/src/s2/encoded_s2point_vector.cc +838 -0
  81. package/third_party/s2geometry/src/s2/encoded_s2point_vector.h +140 -0
  82. package/third_party/s2geometry/src/s2/encoded_s2point_vector_test.cc +344 -0
  83. package/third_party/s2geometry/src/s2/encoded_s2shape_index.cc +181 -0
  84. package/third_party/s2geometry/src/s2/encoded_s2shape_index.h +276 -0
  85. package/third_party/s2geometry/src/s2/encoded_s2shape_index_test.cc +244 -0
  86. package/third_party/s2geometry/src/s2/encoded_string_vector.cc +66 -0
  87. package/third_party/s2geometry/src/s2/encoded_string_vector.h +164 -0
  88. package/third_party/s2geometry/src/s2/encoded_string_vector_test.cc +69 -0
  89. package/third_party/s2geometry/src/s2/encoded_uint_vector.h +299 -0
  90. package/third_party/s2geometry/src/s2/encoded_uint_vector_test.cc +124 -0
  91. package/third_party/s2geometry/src/s2/id_set_lexicon.cc +81 -0
  92. package/third_party/s2geometry/src/s2/id_set_lexicon.h +199 -0
  93. package/third_party/s2geometry/src/s2/id_set_lexicon_test.cc +70 -0
  94. package/third_party/s2geometry/src/s2/mutable_s2shape_index.cc +1585 -0
  95. package/third_party/s2geometry/src/s2/mutable_s2shape_index.h +600 -0
  96. package/third_party/s2geometry/src/s2/mutable_s2shape_index_test.cc +589 -0
  97. package/third_party/s2geometry/src/s2/r1interval.h +220 -0
  98. package/third_party/s2geometry/src/s2/r1interval_test.cc +185 -0
  99. package/third_party/s2geometry/src/s2/r2.h +26 -0
  100. package/third_party/s2geometry/src/s2/r2rect.cc +93 -0
  101. package/third_party/s2geometry/src/s2/r2rect.h +234 -0
  102. package/third_party/s2geometry/src/s2/r2rect_test.cc +228 -0
  103. package/third_party/s2geometry/src/s2/s1angle.cc +54 -0
  104. package/third_party/s2geometry/src/s2/s1angle.h +336 -0
  105. package/third_party/s2geometry/src/s2/s1angle_test.cc +185 -0
  106. package/third_party/s2geometry/src/s2/s1chord_angle.cc +159 -0
  107. package/third_party/s2geometry/src/s2/s1chord_angle.h +369 -0
  108. package/third_party/s2geometry/src/s2/s1chord_angle_test.cc +207 -0
  109. package/third_party/s2geometry/src/s2/s1interval.cc +296 -0
  110. package/third_party/s2geometry/src/s2/s1interval.h +266 -0
  111. package/third_party/s2geometry/src/s2/s1interval_test.cc +469 -0
  112. package/third_party/s2geometry/src/s2/s2boolean_operation.cc +2391 -0
  113. package/third_party/s2geometry/src/s2/s2boolean_operation.h +501 -0
  114. package/third_party/s2geometry/src/s2/s2boolean_operation_test.cc +1400 -0
  115. package/third_party/s2geometry/src/s2/s2builder.cc +1828 -0
  116. package/third_party/s2geometry/src/s2/s2builder.h +1057 -0
  117. package/third_party/s2geometry/src/s2/s2builder_graph.cc +1084 -0
  118. package/third_party/s2geometry/src/s2/s2builder_graph.h +799 -0
  119. package/third_party/s2geometry/src/s2/s2builder_graph_test.cc +462 -0
  120. package/third_party/s2geometry/src/s2/s2builder_layer.h +50 -0
  121. package/third_party/s2geometry/src/s2/s2builder_test.cc +1329 -0
  122. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.cc +313 -0
  123. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.h +221 -0
  124. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer_test.cc +261 -0
  125. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.cc +392 -0
  126. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.h +86 -0
  127. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies_test.cc +182 -0
  128. package/third_party/s2geometry/src/s2/s2builderutil_graph_shape.h +57 -0
  129. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.cc +212 -0
  130. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.h +218 -0
  131. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer_test.cc +367 -0
  132. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.cc +74 -0
  133. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.h +122 -0
  134. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer_test.cc +167 -0
  135. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.cc +191 -0
  136. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.h +211 -0
  137. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer_test.cc +312 -0
  138. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.cc +105 -0
  139. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.h +174 -0
  140. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer_test.cc +220 -0
  141. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.cc +98 -0
  142. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.h +292 -0
  143. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer_test.cc +233 -0
  144. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.cc +354 -0
  145. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.h +239 -0
  146. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions_test.cc +716 -0
  147. package/third_party/s2geometry/src/s2/s2builderutil_testing.cc +37 -0
  148. package/third_party/s2geometry/src/s2/s2builderutil_testing.h +100 -0
  149. package/third_party/s2geometry/src/s2/s2builderutil_testing_test.cc +85 -0
  150. package/third_party/s2geometry/src/s2/s2cap.cc +347 -0
  151. package/third_party/s2geometry/src/s2/s2cap.h +286 -0
  152. package/third_party/s2geometry/src/s2/s2cap_test.cc +379 -0
  153. package/third_party/s2geometry/src/s2/s2cell.cc +552 -0
  154. package/third_party/s2geometry/src/s2/s2cell.h +249 -0
  155. package/third_party/s2geometry/src/s2/s2cell_id.cc +619 -0
  156. package/third_party/s2geometry/src/s2/s2cell_id.h +705 -0
  157. package/third_party/s2geometry/src/s2/s2cell_id_test.cc +633 -0
  158. package/third_party/s2geometry/src/s2/s2cell_index.cc +149 -0
  159. package/third_party/s2geometry/src/s2/s2cell_index.h +660 -0
  160. package/third_party/s2geometry/src/s2/s2cell_index_test.cc +411 -0
  161. package/third_party/s2geometry/src/s2/s2cell_test.cc +687 -0
  162. package/third_party/s2geometry/src/s2/s2cell_union.cc +515 -0
  163. package/third_party/s2geometry/src/s2/s2cell_union.h +399 -0
  164. package/third_party/s2geometry/src/s2/s2cell_union_test.cc +598 -0
  165. package/third_party/s2geometry/src/s2/s2centroids.cc +84 -0
  166. package/third_party/s2geometry/src/s2/s2centroids.h +87 -0
  167. package/third_party/s2geometry/src/s2/s2centroids_test.cc +82 -0
  168. package/third_party/s2geometry/src/s2/s2closest_cell_query.cc +123 -0
  169. package/third_party/s2geometry/src/s2/s2closest_cell_query.h +385 -0
  170. package/third_party/s2geometry/src/s2/s2closest_cell_query_base.h +841 -0
  171. package/third_party/s2geometry/src/s2/s2closest_cell_query_base_test.cc +63 -0
  172. package/third_party/s2geometry/src/s2/s2closest_cell_query_test.cc +412 -0
  173. package/third_party/s2geometry/src/s2/s2closest_edge_query.cc +106 -0
  174. package/third_party/s2geometry/src/s2/s2closest_edge_query.h +421 -0
  175. package/third_party/s2geometry/src/s2/s2closest_edge_query_base.h +946 -0
  176. package/third_party/s2geometry/src/s2/s2closest_edge_query_base_test.cc +59 -0
  177. package/third_party/s2geometry/src/s2/s2closest_edge_query_test.cc +505 -0
  178. package/third_party/s2geometry/src/s2/s2closest_edge_query_testing.h +91 -0
  179. package/third_party/s2geometry/src/s2/s2closest_point_query.cc +66 -0
  180. package/third_party/s2geometry/src/s2/s2closest_point_query.h +465 -0
  181. package/third_party/s2geometry/src/s2/s2closest_point_query_base.h +767 -0
  182. package/third_party/s2geometry/src/s2/s2closest_point_query_base_test.cc +63 -0
  183. package/third_party/s2geometry/src/s2/s2closest_point_query_test.cc +312 -0
  184. package/third_party/s2geometry/src/s2/s2contains_point_query.h +328 -0
  185. package/third_party/s2geometry/src/s2/s2contains_point_query_test.cc +159 -0
  186. package/third_party/s2geometry/src/s2/s2contains_vertex_query.cc +39 -0
  187. package/third_party/s2geometry/src/s2/s2contains_vertex_query.h +66 -0
  188. package/third_party/s2geometry/src/s2/s2contains_vertex_query_test.cc +67 -0
  189. package/third_party/s2geometry/src/s2/s2convex_hull_query.cc +198 -0
  190. package/third_party/s2geometry/src/s2/s2convex_hull_query.h +110 -0
  191. package/third_party/s2geometry/src/s2/s2convex_hull_query_test.cc +208 -0
  192. package/third_party/s2geometry/src/s2/s2coords.cc +146 -0
  193. package/third_party/s2geometry/src/s2/s2coords.h +459 -0
  194. package/third_party/s2geometry/src/s2/s2coords_internal.h +71 -0
  195. package/third_party/s2geometry/src/s2/s2coords_test.cc +218 -0
  196. package/third_party/s2geometry/src/s2/s2crossing_edge_query.cc +380 -0
  197. package/third_party/s2geometry/src/s2/s2crossing_edge_query.h +220 -0
  198. package/third_party/s2geometry/src/s2/s2crossing_edge_query_test.cc +382 -0
  199. package/third_party/s2geometry/src/s2/s2debug.cc +23 -0
  200. package/third_party/s2geometry/src/s2/s2debug.h +69 -0
  201. package/third_party/s2geometry/src/s2/s2distance_target.h +165 -0
  202. package/third_party/s2geometry/src/s2/s2earth.cc +52 -0
  203. package/third_party/s2geometry/src/s2/s2earth.h +268 -0
  204. package/third_party/s2geometry/src/s2/s2earth_test.cc +146 -0
  205. package/third_party/s2geometry/src/s2/s2edge_clipping.cc +462 -0
  206. package/third_party/s2geometry/src/s2/s2edge_clipping.h +183 -0
  207. package/third_party/s2geometry/src/s2/s2edge_clipping_test.cc +335 -0
  208. package/third_party/s2geometry/src/s2/s2edge_crosser.cc +85 -0
  209. package/third_party/s2geometry/src/s2/s2edge_crosser.h +343 -0
  210. package/third_party/s2geometry/src/s2/s2edge_crosser_test.cc +264 -0
  211. package/third_party/s2geometry/src/s2/s2edge_crossings.cc +515 -0
  212. package/third_party/s2geometry/src/s2/s2edge_crossings.h +138 -0
  213. package/third_party/s2geometry/src/s2/s2edge_crossings_internal.h +59 -0
  214. package/third_party/s2geometry/src/s2/s2edge_crossings_test.cc +246 -0
  215. package/third_party/s2geometry/src/s2/s2edge_distances.cc +419 -0
  216. package/third_party/s2geometry/src/s2/s2edge_distances.h +192 -0
  217. package/third_party/s2geometry/src/s2/s2edge_distances_test.cc +539 -0
  218. package/third_party/s2geometry/src/s2/s2edge_tessellator.cc +276 -0
  219. package/third_party/s2geometry/src/s2/s2edge_tessellator.h +101 -0
  220. package/third_party/s2geometry/src/s2/s2edge_tessellator_test.cc +492 -0
  221. package/third_party/s2geometry/src/s2/s2edge_vector_shape.h +85 -0
  222. package/third_party/s2geometry/src/s2/s2edge_vector_shape_test.cc +66 -0
  223. package/third_party/s2geometry/src/s2/s2error.cc +29 -0
  224. package/third_party/s2geometry/src/s2/s2error.h +147 -0
  225. package/third_party/s2geometry/src/s2/s2error_test.cc +31 -0
  226. package/third_party/s2geometry/src/s2/s2furthest_edge_query.cc +117 -0
  227. package/third_party/s2geometry/src/s2/s2furthest_edge_query.h +439 -0
  228. package/third_party/s2geometry/src/s2/s2furthest_edge_query_test.cc +487 -0
  229. package/third_party/s2geometry/src/s2/s2latlng.cc +90 -0
  230. package/third_party/s2geometry/src/s2/s2latlng.h +234 -0
  231. package/third_party/s2geometry/src/s2/s2latlng_rect.cc +727 -0
  232. package/third_party/s2geometry/src/s2/s2latlng_rect.h +434 -0
  233. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.cc +344 -0
  234. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.h +89 -0
  235. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder_test.cc +306 -0
  236. package/third_party/s2geometry/src/s2/s2latlng_rect_test.cc +1030 -0
  237. package/third_party/s2geometry/src/s2/s2latlng_test.cc +165 -0
  238. package/third_party/s2geometry/src/s2/s2lax_loop_shape.cc +104 -0
  239. package/third_party/s2geometry/src/s2/s2lax_loop_shape.h +153 -0
  240. package/third_party/s2geometry/src/s2/s2lax_loop_shape_test.cc +101 -0
  241. package/third_party/s2geometry/src/s2/s2lax_polygon_shape.cc +348 -0
  242. package/third_party/s2geometry/src/s2/s2lax_polygon_shape.h +183 -0
  243. package/third_party/s2geometry/src/s2/s2lax_polygon_shape_test.cc +234 -0
  244. package/third_party/s2geometry/src/s2/s2lax_polyline_shape.cc +118 -0
  245. package/third_party/s2geometry/src/s2/s2lax_polyline_shape.h +124 -0
  246. package/third_party/s2geometry/src/s2/s2lax_polyline_shape_test.cc +62 -0
  247. package/third_party/s2geometry/src/s2/s2loop.cc +1509 -0
  248. package/third_party/s2geometry/src/s2/s2loop.h +711 -0
  249. package/third_party/s2geometry/src/s2/s2loop_measures.cc +313 -0
  250. package/third_party/s2geometry/src/s2/s2loop_measures.h +280 -0
  251. package/third_party/s2geometry/src/s2/s2loop_measures_test.cc +367 -0
  252. package/third_party/s2geometry/src/s2/s2loop_test.cc +1371 -0
  253. package/third_party/s2geometry/src/s2/s2max_distance_targets.cc +265 -0
  254. package/third_party/s2geometry/src/s2/s2max_distance_targets.h +241 -0
  255. package/third_party/s2geometry/src/s2/s2max_distance_targets_test.cc +367 -0
  256. package/third_party/s2geometry/src/s2/s2measures.cc +128 -0
  257. package/third_party/s2geometry/src/s2/s2measures.h +78 -0
  258. package/third_party/s2geometry/src/s2/s2measures_test.cc +135 -0
  259. package/third_party/s2geometry/src/s2/s2metrics.cc +122 -0
  260. package/third_party/s2geometry/src/s2/s2metrics.h +199 -0
  261. package/third_party/s2geometry/src/s2/s2metrics_test.cc +127 -0
  262. package/third_party/s2geometry/src/s2/s2min_distance_targets.cc +295 -0
  263. package/third_party/s2geometry/src/s2/s2min_distance_targets.h +273 -0
  264. package/third_party/s2geometry/src/s2/s2min_distance_targets_test.cc +239 -0
  265. package/third_party/s2geometry/src/s2/s2padded_cell.cc +162 -0
  266. package/third_party/s2geometry/src/s2/s2padded_cell.h +108 -0
  267. package/third_party/s2geometry/src/s2/s2padded_cell_test.cc +138 -0
  268. package/third_party/s2geometry/src/s2/s2point.h +38 -0
  269. package/third_party/s2geometry/src/s2/s2point_compression.cc +388 -0
  270. package/third_party/s2geometry/src/s2/s2point_compression.h +78 -0
  271. package/third_party/s2geometry/src/s2/s2point_compression_test.cc +305 -0
  272. package/third_party/s2geometry/src/s2/s2point_index.h +345 -0
  273. package/third_party/s2geometry/src/s2/s2point_index_test.cc +147 -0
  274. package/third_party/s2geometry/src/s2/s2point_region.cc +72 -0
  275. package/third_party/s2geometry/src/s2/s2point_region.h +76 -0
  276. package/third_party/s2geometry/src/s2/s2point_region_test.cc +100 -0
  277. package/third_party/s2geometry/src/s2/s2point_span.h +57 -0
  278. package/third_party/s2geometry/src/s2/s2point_test.cc +47 -0
  279. package/third_party/s2geometry/src/s2/s2point_vector_shape.h +127 -0
  280. package/third_party/s2geometry/src/s2/s2point_vector_shape_test.cc +59 -0
  281. package/third_party/s2geometry/src/s2/s2pointutil.cc +131 -0
  282. package/third_party/s2geometry/src/s2/s2pointutil.h +138 -0
  283. package/third_party/s2geometry/src/s2/s2pointutil_test.cc +157 -0
  284. package/third_party/s2geometry/src/s2/s2polygon.cc +1569 -0
  285. package/third_party/s2geometry/src/s2/s2polygon.h +934 -0
  286. package/third_party/s2geometry/src/s2/s2polygon_test.cc +3025 -0
  287. package/third_party/s2geometry/src/s2/s2polyline.cc +645 -0
  288. package/third_party/s2geometry/src/s2/s2polyline.h +379 -0
  289. package/third_party/s2geometry/src/s2/s2polyline_alignment.cc +414 -0
  290. package/third_party/s2geometry/src/s2/s2polyline_alignment.h +245 -0
  291. package/third_party/s2geometry/src/s2/s2polyline_alignment_internal.h +158 -0
  292. package/third_party/s2geometry/src/s2/s2polyline_alignment_test.cc +610 -0
  293. package/third_party/s2geometry/src/s2/s2polyline_measures.cc +42 -0
  294. package/third_party/s2geometry/src/s2/s2polyline_measures.h +53 -0
  295. package/third_party/s2geometry/src/s2/s2polyline_measures_test.cc +57 -0
  296. package/third_party/s2geometry/src/s2/s2polyline_simplifier.cc +187 -0
  297. package/third_party/s2geometry/src/s2/s2polyline_simplifier.h +109 -0
  298. package/third_party/s2geometry/src/s2/s2polyline_simplifier_test.cc +165 -0
  299. package/third_party/s2geometry/src/s2/s2polyline_test.cc +554 -0
  300. package/third_party/s2geometry/src/s2/s2predicates.cc +1486 -0
  301. package/third_party/s2geometry/src/s2/s2predicates.h +282 -0
  302. package/third_party/s2geometry/src/s2/s2predicates_internal.h +135 -0
  303. package/third_party/s2geometry/src/s2/s2predicates_test.cc +1427 -0
  304. package/third_party/s2geometry/src/s2/s2projections.cc +109 -0
  305. package/third_party/s2geometry/src/s2/s2projections.h +161 -0
  306. package/third_party/s2geometry/src/s2/s2projections_test.cc +78 -0
  307. package/third_party/s2geometry/src/s2/s2r2rect.cc +88 -0
  308. package/third_party/s2geometry/src/s2/s2r2rect.h +292 -0
  309. package/third_party/s2geometry/src/s2/s2r2rect_test.cc +312 -0
  310. package/third_party/s2geometry/src/s2/s2region.cc +26 -0
  311. package/third_party/s2geometry/src/s2/s2region.h +142 -0
  312. package/third_party/s2geometry/src/s2/s2region_coverer.cc +514 -0
  313. package/third_party/s2geometry/src/s2/s2region_coverer.h +356 -0
  314. package/third_party/s2geometry/src/s2/s2region_coverer_test.cc +509 -0
  315. package/third_party/s2geometry/src/s2/s2region_intersection.cc +84 -0
  316. package/third_party/s2geometry/src/s2/s2region_intersection.h +79 -0
  317. package/third_party/s2geometry/src/s2/s2region_term_indexer.cc +270 -0
  318. package/third_party/s2geometry/src/s2/s2region_term_indexer.h +299 -0
  319. package/third_party/s2geometry/src/s2/s2region_term_indexer_test.cc +209 -0
  320. package/third_party/s2geometry/src/s2/s2region_test.cc +370 -0
  321. package/third_party/s2geometry/src/s2/s2region_union.cc +90 -0
  322. package/third_party/s2geometry/src/s2/s2region_union.h +83 -0
  323. package/third_party/s2geometry/src/s2/s2region_union_test.cc +89 -0
  324. package/third_party/s2geometry/src/s2/s2shape.h +283 -0
  325. package/third_party/s2geometry/src/s2/s2shape_index.cc +321 -0
  326. package/third_party/s2geometry/src/s2/s2shape_index.h +781 -0
  327. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.cc +113 -0
  328. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.h +135 -0
  329. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region_test.cc +162 -0
  330. package/third_party/s2geometry/src/s2/s2shape_index_measures.cc +92 -0
  331. package/third_party/s2geometry/src/s2/s2shape_index_measures.h +100 -0
  332. package/third_party/s2geometry/src/s2/s2shape_index_measures_test.cc +136 -0
  333. package/third_party/s2geometry/src/s2/s2shape_index_region.h +350 -0
  334. package/third_party/s2geometry/src/s2/s2shape_index_region_test.cc +161 -0
  335. package/third_party/s2geometry/src/s2/s2shape_index_test.cc +24 -0
  336. package/third_party/s2geometry/src/s2/s2shape_measures.cc +138 -0
  337. package/third_party/s2geometry/src/s2/s2shape_measures.h +95 -0
  338. package/third_party/s2geometry/src/s2/s2shape_measures_test.cc +139 -0
  339. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.cc +120 -0
  340. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.h +66 -0
  341. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries_test.cc +170 -0
  342. package/third_party/s2geometry/src/s2/s2shapeutil_coding.cc +253 -0
  343. package/third_party/s2geometry/src/s2/s2shapeutil_coding.h +283 -0
  344. package/third_party/s2geometry/src/s2/s2shapeutil_coding_test.cc +54 -0
  345. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.cc +40 -0
  346. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.h +41 -0
  347. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force_test.cc +55 -0
  348. package/third_party/s2geometry/src/s2/s2shapeutil_count_edges.h +57 -0
  349. package/third_party/s2geometry/src/s2/s2shapeutil_count_edges_test.cc +43 -0
  350. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.cc +45 -0
  351. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.h +72 -0
  352. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator_test.cc +116 -0
  353. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.cc +107 -0
  354. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.h +48 -0
  355. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point_test.cc +104 -0
  356. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.cc +58 -0
  357. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.h +65 -0
  358. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator_test.cc +61 -0
  359. package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge.h +58 -0
  360. package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge_id.h +97 -0
  361. package/third_party/s2geometry/src/s2/s2shapeutil_testing.cc +104 -0
  362. package/third_party/s2geometry/src/s2/s2shapeutil_testing.h +36 -0
  363. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.cc +440 -0
  364. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.h +72 -0
  365. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs_test.cc +184 -0
  366. package/third_party/s2geometry/src/s2/s2testing.cc +464 -0
  367. package/third_party/s2geometry/src/s2/s2testing.h +385 -0
  368. package/third_party/s2geometry/src/s2/s2testing_test.cc +166 -0
  369. package/third_party/s2geometry/src/s2/s2text_format.cc +506 -0
  370. package/third_party/s2geometry/src/s2/s2text_format.h +289 -0
  371. package/third_party/s2geometry/src/s2/s2text_format_test.cc +417 -0
  372. package/third_party/s2geometry/src/s2/s2wedge_relations.cc +80 -0
  373. package/third_party/s2geometry/src/s2/s2wedge_relations.h +64 -0
  374. package/third_party/s2geometry/src/s2/s2wedge_relations_test.cc +89 -0
  375. package/third_party/s2geometry/src/s2/sequence_lexicon.h +296 -0
  376. package/third_party/s2geometry/src/s2/sequence_lexicon_test.cc +113 -0
  377. package/third_party/s2geometry/src/s2/strings/ostringstream.cc +35 -0
  378. package/third_party/s2geometry/src/s2/strings/ostringstream.h +105 -0
  379. package/third_party/s2geometry/src/s2/strings/serialize.cc +46 -0
  380. package/third_party/s2geometry/src/s2/strings/serialize.h +40 -0
  381. package/third_party/s2geometry/src/s2/third_party/absl/algorithm/algorithm.h +187 -0
  382. package/third_party/s2geometry/src/s2/third_party/absl/base/attributes.h +666 -0
  383. package/third_party/s2geometry/src/s2/third_party/absl/base/casts.h +189 -0
  384. package/third_party/s2geometry/src/s2/third_party/absl/base/config.h +462 -0
  385. package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.cc +129 -0
  386. package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.h +394 -0
  387. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/atomic_hook.h +168 -0
  388. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/identity.h +33 -0
  389. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/inline_variable.h +117 -0
  390. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/invoke.h +188 -0
  391. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.cc +254 -0
  392. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.h +205 -0
  393. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.cc +106 -0
  394. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.h +71 -0
  395. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/unaligned_access.h +322 -0
  396. package/third_party/s2geometry/src/s2/third_party/absl/base/log_severity.h +77 -0
  397. package/third_party/s2geometry/src/s2/third_party/absl/base/macros.h +236 -0
  398. package/third_party/s2geometry/src/s2/third_party/absl/base/optimization.h +177 -0
  399. package/third_party/s2geometry/src/s2/third_party/absl/base/policy_checks.h +124 -0
  400. package/third_party/s2geometry/src/s2/third_party/absl/base/port.h +97 -0
  401. package/third_party/s2geometry/src/s2/third_party/absl/base/thread_annotations.h +277 -0
  402. package/third_party/s2geometry/src/s2/third_party/absl/container/fixed_array.h +523 -0
  403. package/third_party/s2geometry/src/s2/third_party/absl/container/inlined_vector.h +1453 -0
  404. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/compressed_tuple.h +191 -0
  405. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/container_memory.h +424 -0
  406. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/layout.h +739 -0
  407. package/third_party/s2geometry/src/s2/third_party/absl/memory/memory.h +755 -0
  408. package/third_party/s2geometry/src/s2/third_party/absl/meta/type_traits.h +436 -0
  409. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.cc +232 -0
  410. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.h +656 -0
  411. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_have_intrinsic.inc +3 -0
  412. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_no_intrinsic.inc +3 -0
  413. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.cc +198 -0
  414. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.h +239 -0
  415. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii_ctype.h +66 -0
  416. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/bits.h +53 -0
  417. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.cc +110 -0
  418. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.h +146 -0
  419. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/resize_uninitialized.h +72 -0
  420. package/third_party/s2geometry/src/s2/third_party/absl/strings/match.cc +38 -0
  421. package/third_party/s2geometry/src/s2/third_party/absl/strings/match.h +89 -0
  422. package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.cc +909 -0
  423. package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.h +187 -0
  424. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.cc +240 -0
  425. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.h +398 -0
  426. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_join.h +22 -0
  427. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.cc +47 -0
  428. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.h +43 -0
  429. package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.cc +245 -0
  430. package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.h +602 -0
  431. package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.cc +42 -0
  432. package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.h +130 -0
  433. package/third_party/s2geometry/src/s2/third_party/absl/types/span.h +793 -0
  434. package/third_party/s2geometry/src/s2/third_party/absl/utility/utility.h +299 -0
  435. package/third_party/s2geometry/src/s2/util/bits/bit-interleave.cc +274 -0
  436. package/third_party/s2geometry/src/s2/util/bits/bit-interleave.h +53 -0
  437. package/third_party/s2geometry/src/s2/util/bits/bits.cc +155 -0
  438. package/third_party/s2geometry/src/s2/util/bits/bits.h +745 -0
  439. package/third_party/s2geometry/src/s2/util/coding/coder.cc +83 -0
  440. package/third_party/s2geometry/src/s2/util/coding/coder.h +553 -0
  441. package/third_party/s2geometry/src/s2/util/coding/nth-derivative.h +134 -0
  442. package/third_party/s2geometry/src/s2/util/coding/transforms.h +62 -0
  443. package/third_party/s2geometry/src/s2/util/coding/varint.cc +289 -0
  444. package/third_party/s2geometry/src/s2/util/coding/varint.h +476 -0
  445. package/third_party/s2geometry/src/s2/util/endian/endian.h +859 -0
  446. package/third_party/s2geometry/src/s2/util/gtl/btree.h +2471 -0
  447. package/third_party/s2geometry/src/s2/util/gtl/btree_container.h +411 -0
  448. package/third_party/s2geometry/src/s2/util/gtl/btree_map.h +79 -0
  449. package/third_party/s2geometry/src/s2/util/gtl/btree_set.h +73 -0
  450. package/third_party/s2geometry/src/s2/util/gtl/compact_array.h +653 -0
  451. package/third_party/s2geometry/src/s2/util/gtl/container_logging.h +291 -0
  452. package/third_party/s2geometry/src/s2/util/gtl/dense_hash_set.h +358 -0
  453. package/third_party/s2geometry/src/s2/util/gtl/densehashtable.h +1493 -0
  454. package/third_party/s2geometry/src/s2/util/gtl/hashtable_common.h +253 -0
  455. package/third_party/s2geometry/src/s2/util/gtl/layout.h +28 -0
  456. package/third_party/s2geometry/src/s2/util/gtl/legacy_random_shuffle.h +77 -0
  457. package/third_party/s2geometry/src/s2/util/hash/mix.h +76 -0
  458. package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.cc +832 -0
  459. package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.h +646 -0
  460. package/third_party/s2geometry/src/s2/util/math/mathutil.cc +75 -0
  461. package/third_party/s2geometry/src/s2/util/math/mathutil.h +189 -0
  462. package/third_party/s2geometry/src/s2/util/math/matrix3x3.h +574 -0
  463. package/third_party/s2geometry/src/s2/util/math/vector.h +569 -0
  464. package/third_party/s2geometry/src/s2/util/math/vector3_hash.h +54 -0
  465. package/third_party/s2geometry/src/s2/util/units/length-units.cc +21 -0
  466. package/third_party/s2geometry/src/s2/util/units/length-units.h +135 -0
  467. package/third_party/s2geometry/src/s2/util/units/physical-units.h +313 -0
  468. package/third_party/s2geometry/src/s2/value_lexicon.h +234 -0
  469. package/third_party/s2geometry/src/s2/value_lexicon_test.cc +121 -0
  470. package/third_party/s2geometry/third_party/cmake/FindGFlags.cmake +48 -0
  471. package/third_party/s2geometry/third_party/cmake/FindGlog.cmake +48 -0
@@ -0,0 +1,150 @@
1
+ // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme
2
+ const binary = require('@mapbox/node-pre-gyp');
3
+ const path = require('path');
4
+ var binding_path = binary.find(path.resolve('./package.json'));
5
+ const s2 = require(binding_path);
6
+
7
+ // https://s2.sidewalklabs.com/regioncoverer/?center=40.719527%2C-73.960561&zoom=13&cells=89c25915%2C89c25917%2C89c25919%2C89c2593%2C89c2595%2C89c25967f%2C89c2596c%2C89c25eb4%2C89c25ecc%2C89c25ed4
8
+ const tokens = [
9
+ '89c25915', '89c25917', '89c25919', '89c2593',
10
+ '89c2595', '89c25967f', '89c2596c', '89c25eb4',
11
+ '89c25ecc', '89c25ed4'
12
+ ];
13
+
14
+ const ids = [
15
+ 9926594475407179776n,
16
+ 9926594483997114368n,
17
+ 9926594492587048960n,
18
+ 9926594591371296768n,
19
+ 9926594728810250240n,
20
+ 9926594831621029888n,
21
+ 9926594849069334528n,
22
+ 9926600655865118720n,
23
+ 9926600758944333824n,
24
+ 9926600793304072192n,
25
+ ];
26
+
27
+ test("CellUnion#constructor works", () => {
28
+ const cellIds = tokens.map(t => s2.CellId.fromToken(t));
29
+
30
+ const cu1 = new s2.CellUnion(tokens);
31
+ const cu2 = new s2.CellUnion(cellIds);
32
+
33
+ expect(new Set(cu1.tokens())).toEqual(new Set(tokens)) ;
34
+ expect(new Set(cu2.tokens())).toEqual(new Set(tokens)) ;
35
+ expect(new Set(cu1.cellIds().map(id => id.token()))).toEqual(new Set(tokens)) ;
36
+ expect(new Set(cu2.cellIds().map(id => id.token()))).toEqual(new Set(tokens)) ;
37
+ expect(new Set(cu1.ids())).toEqual(new Set(ids)) ;
38
+ expect(new Set(cu2.ids())).toEqual(new Set(ids)) ;
39
+ });
40
+
41
+ test("CellUnion#contains works", () => {
42
+ const cu = new s2.CellUnion(tokens);
43
+
44
+ const pointInside = s2.CellId.fromToken('89c259475f3');
45
+ const pointOutside = s2.CellId.fromToken('89c25db57c1');
46
+
47
+ const unionInside = new s2.CellUnion([
48
+ '89c259380c', '89c259387', '89c25938c', '89c2593f54', '89c25940c',
49
+ '89c259413', '89c259465', '89c25946c', '89c259474', '89c25947c'
50
+ ]);
51
+
52
+ const unionOutside = new s2.CellUnion([
53
+ '89c2595', '89c25bf', '89c25c1', '89c25c3',
54
+ '89c25c404', '89c25c6c', '89c25dd', '89c25e5c',
55
+ '89c25e7', '89c25ec'
56
+ ]);
57
+
58
+ expect(cu.contains(pointInside)).toBe(true) ;
59
+ expect(cu.contains(pointOutside)).toBe(false) ;
60
+ expect(cu.contains(unionInside)).toBe(true) ;
61
+ expect(cu.contains(unionOutside)).toBe(false) ;
62
+ });
63
+
64
+ test("CellUnion#intersects works", () => {
65
+ const cu = new s2.CellUnion(tokens);
66
+
67
+ const pointInside = s2.CellId.fromToken('89c25915');
68
+
69
+ const unionInside = new s2.CellUnion([
70
+ '89c259380c', '89c259387', '89c25938c', '89c2593f54',
71
+ '89c25940c', '89c259413', '89c259465', '89c25946c',
72
+ '89c259474', '89c25947c'
73
+ ]);
74
+
75
+ const unionIntersects = new s2.CellUnion([
76
+ '89c25935','89c25937','89c25939','89c2593f','89c25944',
77
+ '89c2594c','89c25eb34','89c25eb5','89c25ecc'
78
+ ]);
79
+
80
+ const unionOutside = new s2.CellUnion([
81
+ '89c25d8c', '89c25df', '89c25e1', '89c25e3',
82
+ '89c2604', '89c260c', '89c2614', '89c261b',
83
+ '89c266c', '89c2674'
84
+ ]);
85
+
86
+ expect(cu.contains(pointInside)).toBe(true) ;
87
+ expect(cu.contains(unionInside)).toBe(true) ;
88
+ expect(cu.contains(unionIntersects)).toBe(true) ;
89
+ expect(cu.contains(unionOutside)).toBe(false) ;
90
+ });
91
+
92
+ test("CellUnion#union works", () => {
93
+ const area1 = new s2.CellUnion([
94
+ '89c25be5','89c25be64','89c25be684','89c25bec','89c25bf4',
95
+ '89c25bfc','89c25c01','89c25c07','89c25c09','89c25c0b'
96
+ ]);
97
+
98
+ const area2 = new s2.CellUnion([
99
+ '89c25c2b','89c25c2d','89c25c34','89c25dd','89c25de4',
100
+ '89c25dec','89c25e0c','89c25e74','89c25e7c','89c25e81'
101
+ ]);
102
+
103
+ const unioned = area1.union(area2);
104
+ expect(new Set(unioned.tokens())).toEqual(new Set([
105
+ '89c25be5','89c25be64','89c25be684','89c25bec',
106
+ '89c25bf4','89c25bfc', '89c25c01','89c25c07',
107
+ '89c25c09','89c25c0b','89c25c2b','89c25c2d',
108
+ '89c25c34','89c25dd','89c25de4','89c25dec',
109
+ '89c25e0c','89c25e74','89c25e7c','89c25e81'
110
+ ]));
111
+ });
112
+
113
+ test("CellUnion#intersection works", () => {
114
+ const area1 = new s2.CellUnion([
115
+ '89c25be5','89c25be64','89c25be684','89c25bec','89c25bf4',
116
+ '89c25bfc','89c25c01','89c25c07','89c25c09','89c25c0b'
117
+ ]);
118
+
119
+ const area2 = new s2.CellUnion([
120
+ '89c25c2b','89c25c2d','89c25c34','89c25dd','89c25de4',
121
+ '89c25dec','89c25e0c','89c25e74','89c25e7c','89c25e81'
122
+ ]);
123
+
124
+ // area 1 and area2 don't intersect
125
+ const intersection1 = area1.intersection(area2);
126
+ expect(new Set(intersection1.tokens())).toEqual(new Set());
127
+
128
+ // area 1 should intersect after union
129
+ const unioned = area1.union(area2);
130
+ const intersection2 = unioned.intersection(area1);
131
+ expect(new Set(intersection2.tokens())).toEqual(new Set(area1.tokens()));
132
+
133
+ // area3 is inside area1
134
+ const area3 = new s2.CellUnion([
135
+ '89c25be5','89c25be64','89c25be684','89c25bec','89c25bf4',
136
+ ]);
137
+ const intersection3 = area1.intersection(area3);
138
+ expect(new Set(intersection3.tokens())).toEqual(new Set(area3.tokens()));
139
+ });
140
+
141
+ test("CellUnion#difference works", () => {
142
+ const area1 = new s2.CellUnion(['89c25be5','89c25be64','89c25be684','89c25bec','89c25bf4']);
143
+ const area2 = new s2.CellUnion(['89c25be5','89c25be64','89c25be684','89c25bec','89c25bf5']);
144
+
145
+ const difference = area1.difference(area2);
146
+
147
+ // diff should get the 3 cells in the rest of the quadrant
148
+ expect(new Set(difference.tokens()))
149
+ .toEqual(new Set(['89c25bf1','89c25bf3','89c25bf7']));
150
+ });
@@ -0,0 +1,62 @@
1
+ // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme
2
+ const binary = require('@mapbox/node-pre-gyp');
3
+ const path = require('path');
4
+ var binding_path = binary.find(path.resolve('./package.json'));
5
+ const s2 = require(binding_path);
6
+
7
+ const westLakeUniversity = [30.135703, 120.075485];
8
+ const apsaraPark = [30.135770, 120.074877];
9
+
10
+ test("Earth#constructor", () => {
11
+ const earth = new s2.Earth();
12
+ expect(earth.constructor).toBe(s2.Earth);
13
+ });
14
+
15
+
16
+ test("Earth#toMeters Earth#getDistanceMeters Earth#toKm Earth#getDistanceKm Earth#getRadians Earth#getDegrees", () => {
17
+ const latlng1 = new s2.LatLng(westLakeUniversity[0], westLakeUniversity[1]);
18
+ const latlng2 = new s2.LatLng(apsaraPark[0], apsaraPark[1]);
19
+
20
+ const distanceToMeters = s2.Earth.toMeters(latlng1, latlng2);
21
+ const distanceMeters = s2.Earth.getDistanceMeters(latlng1, latlng2);
22
+
23
+ const distanceToKm = s2.Earth.toKm(latlng1, latlng2);
24
+ const distanceKm = s2.Earth.getDistanceKm(latlng1, latlng2);
25
+
26
+ const radians = s2.Earth.getRadians(latlng1, latlng2);
27
+ const degrees = s2.Earth.getDegrees(latlng1, latlng2);
28
+
29
+ expect(distanceToMeters).toBe(58.941537292477996);
30
+ expect(distanceMeters).toBe(58.941537292477996);
31
+ expect(distanceToKm).toBe(0.058941537292477996);
32
+ expect(distanceKm).toBe(0.058941537292477996);
33
+
34
+ expect(radians).toBe(0.00000925152170416904);
35
+ expect(degrees).toBe(0.0005300731477225649);
36
+ });
37
+
38
+ test("Earth#getInitalBearingDegrees", () => {
39
+ const centerLatLng = [30.135703, 120.075485];
40
+ const eastLatLng = [30.135717, 120.076004];
41
+ const southLatLng = [30.135510, 120.075515];
42
+ const westLatLng = [30.135749, 120.075085];
43
+ const northLatLng = [30.136150, 120.075611];
44
+
45
+ const center = new s2.LatLng(centerLatLng[0], centerLatLng[1]);
46
+ const east = new s2.LatLng(eastLatLng[0], eastLatLng[1]);
47
+ const south = new s2.LatLng(southLatLng[0], southLatLng[1]);
48
+ const west = new s2.LatLng(westLatLng[0], westLatLng[1]);
49
+ const north = new s2.LatLng(northLatLng[0], northLatLng[1]);
50
+
51
+ const degreeEast = s2.Earth.getInitalBearingDegrees(center, east);
52
+ expect(degreeEast).toBe(88.21335159225947);
53
+
54
+ const degreeSouth = s2.Earth.getInitalBearingDegrees(center, south);
55
+ expect(degreeSouth).toBe(172.34356352357213);
56
+
57
+ const degreeWest = s2.Earth.getInitalBearingDegrees(center, west);
58
+ expect(degreeWest).toBe(-82.42555355986279);
59
+
60
+ const degreeNorth = s2.Earth.getInitalBearingDegrees(center, north);
61
+ expect(degreeNorth).toBe(13.70028061338925);
62
+ });
@@ -0,0 +1,45 @@
1
+ // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme
2
+ const binary = require('@mapbox/node-pre-gyp');
3
+ const path = require('path');
4
+ var binding_path = binary.find(path.resolve('./package.json'));
5
+ const s2 = require(binding_path);
6
+
7
+ const tokyoTower = [35.6586, 139.7454];
8
+
9
+ test("LatLng#constructor accepts Point", () => {
10
+ const point = new s2.Point(-0.6193073896908822, 0.5249960533039503, 0.5838128990434704);
11
+ const ll = new s2.LatLng(point);
12
+ expect(ll.toString()).toEqual('35.719171,139.711561');
13
+ });
14
+
15
+ test("LatLng#latitude works", () => {
16
+ const ll = new s2.LatLng(...tokyoTower);
17
+ expect(ll.latitude()).toBe(35.6586);
18
+ });
19
+
20
+ test("LatLng#longitude works", () => {
21
+ const ll = new s2.LatLng(...tokyoTower);
22
+ expect(ll.longitude()).toBe(139.7454);
23
+ });
24
+
25
+ test("LatLng#toString works", () => {
26
+ const ll = new s2.LatLng(...tokyoTower);
27
+ expect(ll.toString()).toBe('35.658600,139.745400');
28
+ });
29
+
30
+ test("LatLng#normalize works", () => {
31
+ const denormalized = [215.6586, 319.7454];
32
+ const ll = new s2.LatLng(...denormalized);
33
+ const normalized = ll.normalized();
34
+ expect(normalized.toString()).toBe('90.000000,-40.254600');
35
+ });
36
+
37
+ test("LatLng#approxEquals works", () => {
38
+ const midLakePavilion = [30.248566, 120.139686];
39
+ const midLakePavilion2 = [30.248569, 120.139686];
40
+
41
+ const ll1 = new s2.LatLng(...midLakePavilion);
42
+ const ll2 = new s2.LatLng(...midLakePavilion2);
43
+
44
+ expect(ll1.approxEquals(ll2, 1e-7)).toBe(true);
45
+ });
@@ -0,0 +1,14 @@
1
+ // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme
2
+ const binary = require('@mapbox/node-pre-gyp');
3
+ const path = require('path');
4
+ var binding_path = binary.find(path.resolve('./package.json'));
5
+ const s2 = require(binding_path);
6
+
7
+ test("Point#constructor accepts x,y,z values", () => {
8
+ const [x, y, z] = [-0.6193073896908822, 0.5249960533039503, 0.5838128990434704];
9
+ const point = new s2.Point(x,y,z);
10
+
11
+ expect(point.x()).toEqual(x);
12
+ expect(point.y()).toEqual(y);
13
+ expect(point.z()).toEqual(z);
14
+ });
@@ -0,0 +1,78 @@
1
+ // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme
2
+ const binary = require('@mapbox/node-pre-gyp');
3
+ const path = require('path');
4
+ var binding_path = binary.find(path.resolve('./package.json'));
5
+ const s2 = require(binding_path);
6
+
7
+ const PRECISION = 6;
8
+
9
+ const baiCauseway = [[30.261254, 120.147342],[30.260202, 120.146395],[30.258967, 120.145267],[30.257545, 120.144089], [30.256662, 120.143349],[30.256027, 120.142843],[30.255445, 120.142336]]; // 白堤。 WGS84
10
+ const polyline = new s2.Polyline(baiCauseway.map((latlng) => {
11
+ const [lat, lng] = latlng;
12
+ return new s2.LatLng(lat, lng);
13
+ }));
14
+
15
+ test("Polyline#contains", () => {
16
+ const [lat, lng] = baiCauseway[1];
17
+ const cellId = new s2.CellId(new s2.LatLng(lat, lng));
18
+ const cell = new s2.Cell(cellId);
19
+ expect(polyline.contains(cell)).toBe(false);
20
+ });
21
+
22
+ test("Polyline#nearlyCovers true", () => {
23
+ const newBaiCauseway = [[30.261254, 120.147342],[30.260202, 120.146395],[30.258967, 120.145267],[30.257545, 120.144089], [30.256662, 120.143349],[30.256027, 120.142843],[30.255445, 120.142336],[30.254703, 120.141366]];
24
+ const newLLs = newBaiCauseway.map((latlng) => {
25
+ const [lat, lng] = latlng;
26
+ return new s2.LatLng(lat, lng);
27
+ });
28
+ const newPolyline = new s2.Polyline(newLLs);
29
+
30
+ expect(polyline.nearlyCovers(newPolyline, 1e-5)).toBe(false);
31
+ expect(newPolyline.nearlyCovers(polyline, 1e-5)).toBe(true);
32
+ });
33
+
34
+ test("Polyline#nearlyCovers false", () => {
35
+ const tempPoints = [[30.261076, 120.153102],[30.259816, 120.154280], [30.258923, 120.152020],[30.258824, 120.151923 ],[30.258739, 120.151840],[30.258642, 120.151754]];
36
+ const newBaiCauseway = tempPoints.concat([]);
37
+ const newLLs = newBaiCauseway.map((latlng) => {
38
+ const [lat, lng] = latlng;
39
+ return new s2.LatLng(lat, lng);
40
+ });
41
+ const newPolyline = new s2.Polyline(newLLs);
42
+
43
+ expect(polyline.nearlyCovers(newPolyline, 1e-5)).toBe(false);
44
+ });
45
+
46
+ test("Polyline#getLength", () => {
47
+ expect(polyline.getLength().toFixed(PRECISION)).toBe("805.441648");
48
+ });
49
+
50
+ test("Polyline#getCentroid", () => {
51
+ const centroid = polyline.getCentroid();
52
+ expect(centroid.latitude().toFixed(PRECISION)).toBe("30.258369");
53
+ expect(centroid.longitude().toFixed(PRECISION)).toBe("120.144809");
54
+ });
55
+
56
+ test("Polyline#interpolate", () => {
57
+ const interpolated = polyline.interpolate(0.75);
58
+ expect(interpolated.latitude().toFixed(PRECISION)).toBe("30.256914");
59
+ expect(interpolated.longitude().toFixed(PRECISION)).toBe("120.143561");
60
+ });
61
+
62
+ test("Polyline#project", () => {
63
+ const westLakeMuseum = [30.259710, 120.140802];// 西湖博览会博物馆
64
+ const westLakeMuseumLatLng = new s2.LatLng(westLakeMuseum[0], westLakeMuseum[1]);
65
+
66
+ const westLakeMuseumNearPoint = polyline.project(westLakeMuseumLatLng);
67
+ expect(westLakeMuseumNearPoint.point.latitude().toFixed(PRECISION)).toBe("30.257633");
68
+ expect(westLakeMuseumNearPoint.point.longitude().toFixed(PRECISION)).toBe("120.144162");
69
+ expect(westLakeMuseumNearPoint.index).toBe(3);
70
+
71
+ const midLakePavilion = [30.248636, 120.139723]; // 西湖湖心亭
72
+ const midLakePavilionLatLng = new s2.LatLng(midLakePavilion[0], midLakePavilion[1]);
73
+
74
+ const midLakePavilionPoint = polyline.project(midLakePavilionLatLng);
75
+ expect(midLakePavilionPoint.point.latitude().toFixed(PRECISION)).toBe("30.255445");
76
+ expect(midLakePavilionPoint.point.longitude().toFixed(PRECISION)).toBe("120.142336");
77
+ expect(midLakePavilionPoint.index).toBe(7);
78
+ })
@@ -0,0 +1,301 @@
1
+ // magic incantation from step 3 @ https://github.com/mapbox/node-pre-gyp#readme
2
+ const binary = require('@mapbox/node-pre-gyp');
3
+ const path = require('path');
4
+ var binding_path = binary.find(path.resolve('./package.json'));
5
+ const s2 = require(binding_path);
6
+
7
+ // long, lat pairs of 11201 postal code
8
+ const postalCode11201 = [[-73.995069,40.703102],[-73.995138,40.70298],[-73.996698,40.700877],[-73.9975,40.699653],[-73.998032,40.698762],[-73.998376,40.698048],[-73.998847,40.697141],[-73.998763,40.69711],[-73.998857,40.69692],[-73.99894,40.696941],[-73.998991,40.696812],[-73.999182,40.696885],[-73.999295,40.696795],[-73.999474,40.696704],[-73.999535,40.696578],[-73.999478,40.696466],[-73.999428,40.69641],[-73.99942,40.696361],[-73.999461,40.69628],[-73.999604,40.696069],[-73.999882,40.695605],[-74.000277,40.694959],[-74.000701,40.694388],[-74.000959,40.694069],[-74.001194,40.693484],[-74.001277,40.693298],[-74.001317,40.693208],[-74.001542,40.692786],[-74.001744,40.692407],[-74.001818,40.692222],[-74.001969,40.691843],[-74.001332,40.691225],[-74.000699,40.690612],[-74.00096,40.690132],[-74.001853,40.690388],[-74.001963,40.690136],[-74.002178,40.690206],[-74.002427,40.690273],[-74.002616,40.690324],[-74.002763,40.690364],[-74.002993,40.690427],[-74.003024,40.690349],[-74.003409,40.689613],[-74.00382,40.68893],[-74.003919,40.68886],[-74.004593,40.688215],[-74.005038,40.687561],[-74.00563,40.686784],[-74.005874,40.686207],[-74.00635,40.686285],[-74.006406,40.686289],[-74.006444,40.686296],[-74.006506,40.686314],[-74.006594,40.686347],[-74.006755,40.686413],[-74.006875,40.686464],[-74.006989,40.686509],[-74.00702,40.686526],[-74.007064,40.686504],[-74.00715,40.686475],[-74.007243,40.686449],[-74.007411,40.686388],[-74.007497,40.686344],[-74.007536,40.686315],[-74.007623,40.686285],[-74.00767,40.686269],[-74.00773,40.686254],[-74.007778,40.686245],[-74.007843,40.686238],[-74.007899,40.686251],[-74.007929,40.686276],[-74.00795,40.686293],[-74.008164,40.686175],[-74.008425,40.686016],[-74.008386,40.685969],[-74.008135,40.685615],[-74.005497,40.685847],[-74.004853,40.685668],[-74.004504,40.686301],[-74.002364,40.685737],[-74.002039,40.686404],[-74.001718,40.687069],[-74.001389,40.687751],[-74.001278,40.687715],[-74.000539,40.687481],[-74.000054,40.687318],[-73.999962,40.687286],[-73.999863,40.687251],[-73.999696,40.687198],[-73.998932,40.686948],[-73.998276,40.686729],[-73.998189,40.6867],[-73.997278,40.686398],[-73.996488,40.686138],[-73.996358,40.686096],[-73.99618,40.686037],[-73.995386,40.685775],[-73.994538,40.685495],[-73.994408,40.685453],[-73.994578,40.6851],[-73.992192,40.684178],[-73.991952,40.684084],[-73.989992,40.683319],[-73.989556,40.683956],[-73.989129,40.68459],[-73.988712,40.685224],[-73.988289,40.685869],[-73.987859,40.686504],[-73.987429,40.687138],[-73.987,40.687773],[-73.986568,40.688408],[-73.9844,40.687564],[-73.983988,40.688175],[-73.983572,40.688786],[-73.982715,40.688459],[-73.982416,40.688896],[-73.982098,40.689358],[-73.981068,40.688945],[-73.98087,40.688866],[-73.980258,40.688638],[-73.980429,40.689901],[-73.97951,40.689863],[-73.978624,40.689831],[-73.977939,40.689806],[-73.977098,40.689773],[-73.976102,40.689737],[-73.975106,40.689698],[-73.974109,40.689663],[-73.973264,40.689627],[-73.973126,40.689622],[-73.97354,40.691707],[-73.973855,40.693287],[-73.97422,40.693301],[-73.974985,40.693329],[-73.975848,40.693361],[-73.977827,40.693438],[-73.979168,40.693489],[-73.979195,40.693695],[-73.979218,40.693765],[-73.979259,40.69382],[-73.97933,40.693891],[-73.979481,40.694013],[-73.979805,40.694241],[-73.979883,40.694308],[-73.979944,40.694385],[-73.980139,40.694683],[-73.980243,40.695457],[-73.980263,40.695634],[-73.980356,40.696178],[-73.979537,40.696172],[-73.979529,40.696298],[-73.979524,40.696381],[-73.979529,40.696529],[-73.980388,40.696507],[-73.980447,40.69667],[-73.980515,40.697437],[-73.980544,40.698246],[-73.980462,40.699703],[-73.980455,40.700852],[-73.980729,40.701268],[-73.980649,40.701561],[-73.980455,40.702248],[-73.980224,40.703063],[-73.979988,40.703541],[-73.979603,40.704177],[-73.979466,40.704462],[-73.979328,40.704746],[-73.979168,40.705279],[-73.979171,40.705301],[-73.979372,40.705443],[-73.979233,40.705769],[-73.979479,40.705825],[-73.980332,40.705846],[-73.980907,40.705907],[-73.980987,40.705374],[-73.981856,40.70549],[-73.982033,40.705515],[-73.98221,40.70554],[-73.982329,40.705552],[-73.982449,40.705547],[-73.982455,40.705509],[-73.982572,40.705518],[-73.982748,40.705532],[-73.982741,40.705576],[-73.982825,40.705558],[-73.98308,40.705519],[-73.98308,40.70548],[-73.983227,40.705482],[-73.983351,40.705451],[-73.983398,40.705467],[-73.983426,40.705577],[-73.983442,40.705645],[-73.984189,40.705582],[-73.985852,40.705415],[-73.986434,40.705349],[-73.986429,40.705083],[-73.98653,40.704979],[-73.986623,40.704979],[-73.986641,40.705018],[-73.98669,40.705075],[-73.986762,40.705118],[-73.986866,40.705161],[-73.987271,40.705181],[-73.987449,40.705166],[-73.987577,40.705158],[-73.987957,40.705134],[-73.989224,40.705137],[-73.989424,40.705137],[-73.989495,40.705145],[-73.989608,40.705158],[-73.989861,40.705175],[-73.990549,40.705144],[-73.990696,40.705131],[-73.990882,40.705124],[-73.99148,40.705625],[-73.992722,40.705544],[-73.993853,40.704829],[-73.993713,40.70452],[-73.993693,40.704476],[-73.993775,40.704449],[-73.993807,40.70454],[-73.993861,40.704556],[-73.994341,40.704429],[-73.994498,40.704318],[-73.994565,40.704265],[-73.994618,40.704226],[-73.994797,40.704096],[-73.994714,40.703997],[-73.994816,40.703906],[-73.994881,40.703813],[-73.994882,40.703788],[-73.994992,40.703654],[-73.994858,40.703566],[-73.994663,40.703431],[-73.994806,40.703296],[-73.995069,40.703102]];
9
+ const unnormalized = [
10
+ [-119.74242645808715,39.57982985652839],
11
+ [-119.74457144737244,39.579904675483704],
12
+ [-119.7435238,39.5835421],
13
+ [-119.7378725,39.5808519],
14
+ [-119.7393411397934,39.57999050617218],
15
+ [-119.74242645808715,39.57982985652839]
16
+ ];
17
+
18
+ test("RegionCoverer#getCoveringTokens works", () => {
19
+ const lls = postalCode11201.map((latlng) => {
20
+ const [lng, lat] = latlng;
21
+ return new s2.LatLng(lat, lng);
22
+ });
23
+
24
+ // Invalid loop with duplicate points (first and last are the same)
25
+ expect(() => new s2.RegionCoverer.getCoveringTokens(null, {})).toThrow('s2.LatLng[]');
26
+ expect(() => new s2.RegionCoverer.getCoveringTokens([], {})).toThrow('was empty');
27
+ expect(() => new s2.RegionCoverer.getCoveringTokens(lls, {})).toThrow('duplicate vertex');
28
+
29
+ // level-14 s2 cells
30
+ let covering = s2.RegionCoverer.getCoveringTokens(lls.slice(1), { min: 14, max: 14 });
31
+ let coveringTokens = new Set(covering);
32
+ let expectedTokens = new Set([
33
+ '89c25a31',
34
+ '89c25a33',
35
+ '89c25a35',
36
+ '89c25a37',
37
+ '89c25a39',
38
+ '89c25a3b',
39
+ '89c25a41',
40
+ '89c25a43',
41
+ '89c25a45',
42
+ '89c25a47',
43
+ '89c25a49',
44
+ '89c25a4b',
45
+ '89c25a4d',
46
+ '89c25a4f',
47
+ '89c25a51',
48
+ '89c25a53',
49
+ '89c25a5b',
50
+ '89c25a5d',
51
+ '89c25a67',
52
+ '89c25bb1',
53
+ '89c25bb3',
54
+ '89c25bb5',
55
+ '89c25bb7',
56
+ '89c25bcb',
57
+ '89c25bcd',
58
+ '89c25bd3'
59
+ ]);
60
+
61
+ expect(coveringTokens).toEqual(expectedTokens);
62
+
63
+ // levels 12-20
64
+ covering = s2.RegionCoverer.getCoveringTokens(lls.slice(1), { min: 12, max: 20 });
65
+ coveringTokens = new Set(covering);
66
+
67
+ expect(coveringTokens).toEqual(new Set([
68
+ '89c25a34',
69
+ '89c25a3c',
70
+ '89c25a5',
71
+ '89c25a674',
72
+ '89c25bb4',
73
+ '89c25bcb',
74
+ '89c25bcd',
75
+ '89c25bd3'
76
+ ]));
77
+ });
78
+
79
+ test("RegionCoverer can cover unnormalized loops", () => {
80
+ const lls = unnormalized.map((latlng) => {
81
+ const [lng, lat] = latlng;
82
+ return new s2.LatLng(lat, lng);
83
+ });
84
+
85
+ // generate s2 cells
86
+ let covering = s2.RegionCoverer.getCoveringTokens(lls.slice(1), { min: 14, max: 20 });
87
+ let coveringTokens = new Set(covering);
88
+ let expectedTokens = new Set([
89
+ '809938fe4',
90
+ '809938ffc',
91
+ '809939004',
92
+ '809939014',
93
+ '80993901c',
94
+ '809939021f',
95
+ '809939023',
96
+ '80993903c',
97
+ ]);
98
+
99
+ expect(coveringTokens).toEqual(expectedTokens);
100
+
101
+ });
102
+
103
+ test("RegionCoverer#getCovering works", () => {
104
+ const lls = postalCode11201.map((latlng) => {
105
+ const [lng, lat] = latlng;
106
+ return new s2.LatLng(lat, lng);
107
+ });
108
+
109
+ // Invalid loop with duplicate points (first and last are the same)
110
+ expect(() => new s2.RegionCoverer.getCovering(null, {})).toThrow('s2.LatLng[]');
111
+ expect(() => new s2.RegionCoverer.getCovering([], {})).toThrow('was empty');
112
+ expect(() => new s2.RegionCoverer.getCovering(lls, {})).toThrow('duplicate vertex');
113
+
114
+ // level-14 s2 cells
115
+ let covering = s2.RegionCoverer.getCovering(lls.slice(1), { min: 14, max: 14 });
116
+ let coveringCellIds = covering.cellIds();
117
+ let coveringTokens = new Set(covering.tokens());
118
+ let expectedTokens = new Set([
119
+ '89c25a31',
120
+ '89c25a33',
121
+ '89c25a35',
122
+ '89c25a37',
123
+ '89c25a39',
124
+ '89c25a3b',
125
+ '89c25a41',
126
+ '89c25a43',
127
+ '89c25a45',
128
+ '89c25a47',
129
+ '89c25a49',
130
+ '89c25a4b',
131
+ '89c25a4d',
132
+ '89c25a4f',
133
+ '89c25a51',
134
+ '89c25a53',
135
+ '89c25a5b',
136
+ '89c25a5d',
137
+ '89c25a67',
138
+ '89c25bb1',
139
+ '89c25bb3',
140
+ '89c25bb5',
141
+ '89c25bb7',
142
+ '89c25bcb',
143
+ '89c25bcd',
144
+ '89c25bd3'
145
+ ]);
146
+
147
+ expect(coveringTokens).toEqual(expectedTokens);
148
+ expect(new Set(coveringCellIds.map(id => id.token()))).toEqual(expectedTokens);
149
+
150
+ // levels 12-20
151
+ covering = s2.RegionCoverer.getCovering(lls.slice(1), { min: 12, max: 20 });
152
+ coveringCellIds = covering.cellIds();
153
+ coveringTokens = new Set(covering.tokens());
154
+
155
+ expectedTokens = new Set([
156
+ '89c25a34',
157
+ '89c25a3c',
158
+ '89c25a5',
159
+ '89c25a674',
160
+ '89c25bb4',
161
+ '89c25bcb',
162
+ '89c25bcd',
163
+ '89c25bd3'
164
+ ]);
165
+
166
+ expect(coveringTokens).toEqual(expectedTokens);
167
+ expect(new Set(coveringCellIds.map(id => id.token()))).toEqual(expectedTokens);
168
+ });
169
+
170
+ test("RegionCoverer#getCoveringIds works", () => {
171
+ const lls = postalCode11201.map((latlng) => {
172
+ const [lng, lat] = latlng;
173
+ return new s2.LatLng(lat, lng);
174
+ });
175
+
176
+ // Invalid loop with duplicate points (first and last are the same)
177
+ expect(() => new s2.RegionCoverer.getCoveringIds(null, {})).toThrow('s2.LatLng[]');
178
+ expect(() => new s2.RegionCoverer.getCoveringIds([], {})).toThrow('was empty');
179
+ expect(() => new s2.RegionCoverer.getCoveringIds(lls, {})).toThrow('duplicate vertex');
180
+
181
+ // level-14 s2 cells
182
+ let covering =
183
+ s2.RegionCoverer
184
+ .getCoveringIds(lls.slice(1), { min: 14, max: 14 })
185
+ .sort();
186
+
187
+ let expectedIds = BigUint64Array.of(
188
+ 9926595695177891840n,
189
+ 9926595703767826432n,
190
+ 9926595798257106944n,
191
+ 9926595806847041536n,
192
+ 9926595815436976128n,
193
+ 9926595824026910720n,
194
+ 9926595832616845312n,
195
+ 9926595841206779904n,
196
+ 9926595875566518272n,
197
+ 9926595884156452864n,
198
+ 9926595927106125824n,
199
+ 9926597344445333504n,
200
+ 9926595712357761024n,
201
+ 9926597353035268096n,
202
+ 9926597361625202688n,
203
+ 9926597370215137280n,
204
+ 9926597456114483200n,
205
+ 9926597464704417792n,
206
+ 9926597490474221568n,
207
+ 9926595720947695616n,
208
+ 9926595729537630208n,
209
+ 9926595738127564800n,
210
+ 9926595763897368576n,
211
+ 9926595772487303168n,
212
+ 9926595781077237760n,
213
+ 9926595789667172352n
214
+ ).sort();
215
+
216
+ for (let i = 0; i < expectedIds.length; i++) {
217
+ expect(covering[i]).toEqual(expectedIds[i]);
218
+ }
219
+
220
+ // levels 12-20
221
+ covering =
222
+ s2.RegionCoverer
223
+ .getCoveringIds(lls.slice(1), { min: 12, max: 20 })
224
+ .sort();
225
+
226
+ expectedIds = BigUint64Array.of(
227
+ 9926595708062793728n,
228
+ 9926595742422532096n,
229
+ 9926595828321878016n,
230
+ 9926595928179867648n,
231
+ 9926597357330235392n,
232
+ 9926597456114483200n,
233
+ 9926597464704417792n,
234
+ 9926597490474221568n,
235
+ ).sort();
236
+
237
+ for (let i = 0; i < expectedIds.length; i++) {
238
+ expect(covering[i]).toEqual(expectedIds[i]);
239
+ }
240
+
241
+ });
242
+
243
+ test("RegionCoverer#getRadiusCovering works", () => {
244
+ const dumbo = [40.7033, -73.9881];
245
+ const ll = new s2.LatLng(...dumbo);
246
+
247
+ const cellUnion = s2.RegionCoverer.getRadiusCovering(ll, 3000, { min: 5, max: 20 });
248
+ const ids = cellUnion.ids().sort();
249
+ const expected = [
250
+ 9926594780349857792n,
251
+ 9926594866249203712n,
252
+ 9926595003688157184n,
253
+ 9926595433184886784n,
254
+ 9926595759602401280n,
255
+ 9926596532696514560n,
256
+ 9926596567056252928n,
257
+ 9926597408869842944n,
258
+ ].sort();
259
+
260
+ for (let i = 0; i < expected.length; i++) {
261
+ expect(ids[i]).toEqual(expected[i]);
262
+ }
263
+ });
264
+
265
+ test("RegionCoverer#getRadiusCoveringIds works", () => {
266
+ const dumbo = [40.7033, -73.9881];
267
+ const ll = new s2.LatLng(...dumbo);
268
+
269
+ const ids = s2.RegionCoverer.getRadiusCoveringIds(ll, 3000, { min: 5, max: 20 }).sort();
270
+ const expected = [
271
+ 9926594780349857792n,
272
+ 9926594866249203712n,
273
+ 9926595003688157184n,
274
+ 9926595433184886784n,
275
+ 9926595759602401280n,
276
+ 9926596532696514560n,
277
+ 9926596567056252928n,
278
+ 9926597408869842944n,
279
+ ].sort();
280
+
281
+ for (let i = 0; i < expected.length; i++) {
282
+ expect(ids[i]).toEqual(expected[i]);
283
+ }
284
+ });
285
+
286
+ test("RegionCoverer#getRadiusCoveringTokens works", () => {
287
+ const dumbo = [40.7033, -73.9881];
288
+ const ll = new s2.LatLng(...dumbo);
289
+
290
+ const tokens = s2.RegionCoverer.getRadiusCoveringTokens(ll, 1000, { min: 12, max: 12 }).sort();
291
+ const expected = [
292
+ '89c25a3',
293
+ '89c25a5',
294
+ '89c25bb',
295
+ '89c25bd',
296
+ ].sort();
297
+
298
+ for (let i = 0; i < expected.length; i++) {
299
+ expect(tokens[i]).toEqual(expected[i]);
300
+ }
301
+ });
package/test.sh ADDED
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ set -ex
4
+
5
+ git submodule init
6
+ git submodule sync
7
+ git submodule update
8
+
9
+ for node in 20 22 24
10
+ do
11
+ # build image
12
+ docker build -t test$node -f ./docker/Dockerfile.node$node.test .
13
+
14
+ # run image
15
+ docker run test$node:latest
16
+ done