@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.
- package/.circleci/config.yml +45 -0
- package/.dockerignore +1 -0
- package/.gitmodules +3 -0
- package/CHANGELOG.md +33 -0
- package/LICENSE +201 -0
- package/README.md +147 -0
- package/binding.gyp +170 -0
- package/docker/Dockerfile.node20.test +8 -0
- package/docker/Dockerfile.node22.test +8 -0
- package/docker/Dockerfile.node24.test +8 -0
- package/index.d.ts +117 -0
- package/index.js +6 -0
- package/jest.config.js +184 -0
- package/package.json +43 -0
- package/publish-linux.sh +18 -0
- package/publish-osx.sh +19 -0
- package/src/builder.cc +84 -0
- package/src/builder.h +29 -0
- package/src/cell.cc +71 -0
- package/src/cell.h +26 -0
- package/src/cell_id.cc +210 -0
- package/src/cell_id.h +44 -0
- package/src/cell_union.cc +237 -0
- package/src/cell_union.h +34 -0
- package/src/earth.cc +185 -0
- package/src/earth.h +33 -0
- package/src/latlng.cc +132 -0
- package/src/latlng.h +28 -0
- package/src/loop.cc +51 -0
- package/src/loop.h +21 -0
- package/src/point.cc +69 -0
- package/src/point.h +23 -0
- package/src/polygon.cc +36 -0
- package/src/polygon.h +20 -0
- package/src/polyline.cc +186 -0
- package/src/polyline.h +34 -0
- package/src/region_coverer.cc +450 -0
- package/src/region_coverer.h +56 -0
- package/src/s2.cc +27 -0
- package/test/Cell.test.js +37 -0
- package/test/CellId.test.js +135 -0
- package/test/CellUnion.test.js +150 -0
- package/test/Earth.test.js +62 -0
- package/test/LatLng.test.js +45 -0
- package/test/Point.test.js +14 -0
- package/test/Polyline.test.js +78 -0
- package/test/RegionCoverer.test.js +301 -0
- package/test.sh +16 -0
- package/third_party/s2geometry/.travis.yml +163 -0
- package/third_party/s2geometry/AUTHORS +13 -0
- package/third_party/s2geometry/CONTRIBUTING.md +65 -0
- package/third_party/s2geometry/CONTRIBUTORS +30 -0
- package/third_party/s2geometry/LICENSE +202 -0
- package/third_party/s2geometry/NOTICE +5 -0
- package/third_party/s2geometry/README.md +127 -0
- package/third_party/s2geometry/doc/examples/point_index.cc +44 -0
- package/third_party/s2geometry/doc/examples/term_index.cc +99 -0
- package/third_party/s2geometry/doc/examples/term_index.py +101 -0
- package/third_party/s2geometry/src/python/coder.i +125 -0
- package/third_party/s2geometry/src/python/pywraps2_test.py +786 -0
- package/third_party/s2geometry/src/python/s2.i +37 -0
- package/third_party/s2geometry/src/python/s2_common.i +756 -0
- package/third_party/s2geometry/src/s2/_fp_contract_off.h +60 -0
- package/third_party/s2geometry/src/s2/base/casts.h +318 -0
- package/third_party/s2geometry/src/s2/base/commandlineflags.h +67 -0
- package/third_party/s2geometry/src/s2/base/integral_types.h +31 -0
- package/third_party/s2geometry/src/s2/base/log_severity.h +40 -0
- package/third_party/s2geometry/src/s2/base/logging.h +173 -0
- package/third_party/s2geometry/src/s2/base/mutex.h +61 -0
- package/third_party/s2geometry/src/s2/base/port.h +999 -0
- package/third_party/s2geometry/src/s2/base/spinlock.h +60 -0
- package/third_party/s2geometry/src/s2/base/stringprintf.cc +107 -0
- package/third_party/s2geometry/src/s2/base/stringprintf.h +53 -0
- package/third_party/s2geometry/src/s2/base/strtoint.cc +65 -0
- package/third_party/s2geometry/src/s2/base/strtoint.h +106 -0
- package/third_party/s2geometry/src/s2/base/timer.h +50 -0
- package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.cc +164 -0
- package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.h +110 -0
- package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector_test.cc +232 -0
- package/third_party/s2geometry/src/s2/encoded_s2point_vector.cc +838 -0
- package/third_party/s2geometry/src/s2/encoded_s2point_vector.h +140 -0
- package/third_party/s2geometry/src/s2/encoded_s2point_vector_test.cc +344 -0
- package/third_party/s2geometry/src/s2/encoded_s2shape_index.cc +181 -0
- package/third_party/s2geometry/src/s2/encoded_s2shape_index.h +276 -0
- package/third_party/s2geometry/src/s2/encoded_s2shape_index_test.cc +244 -0
- package/third_party/s2geometry/src/s2/encoded_string_vector.cc +66 -0
- package/third_party/s2geometry/src/s2/encoded_string_vector.h +164 -0
- package/third_party/s2geometry/src/s2/encoded_string_vector_test.cc +69 -0
- package/third_party/s2geometry/src/s2/encoded_uint_vector.h +299 -0
- package/third_party/s2geometry/src/s2/encoded_uint_vector_test.cc +124 -0
- package/third_party/s2geometry/src/s2/id_set_lexicon.cc +81 -0
- package/third_party/s2geometry/src/s2/id_set_lexicon.h +199 -0
- package/third_party/s2geometry/src/s2/id_set_lexicon_test.cc +70 -0
- package/third_party/s2geometry/src/s2/mutable_s2shape_index.cc +1585 -0
- package/third_party/s2geometry/src/s2/mutable_s2shape_index.h +600 -0
- package/third_party/s2geometry/src/s2/mutable_s2shape_index_test.cc +589 -0
- package/third_party/s2geometry/src/s2/r1interval.h +220 -0
- package/third_party/s2geometry/src/s2/r1interval_test.cc +185 -0
- package/third_party/s2geometry/src/s2/r2.h +26 -0
- package/third_party/s2geometry/src/s2/r2rect.cc +93 -0
- package/third_party/s2geometry/src/s2/r2rect.h +234 -0
- package/third_party/s2geometry/src/s2/r2rect_test.cc +228 -0
- package/third_party/s2geometry/src/s2/s1angle.cc +54 -0
- package/third_party/s2geometry/src/s2/s1angle.h +336 -0
- package/third_party/s2geometry/src/s2/s1angle_test.cc +185 -0
- package/third_party/s2geometry/src/s2/s1chord_angle.cc +159 -0
- package/third_party/s2geometry/src/s2/s1chord_angle.h +369 -0
- package/third_party/s2geometry/src/s2/s1chord_angle_test.cc +207 -0
- package/third_party/s2geometry/src/s2/s1interval.cc +296 -0
- package/third_party/s2geometry/src/s2/s1interval.h +266 -0
- package/third_party/s2geometry/src/s2/s1interval_test.cc +469 -0
- package/third_party/s2geometry/src/s2/s2boolean_operation.cc +2391 -0
- package/third_party/s2geometry/src/s2/s2boolean_operation.h +501 -0
- package/third_party/s2geometry/src/s2/s2boolean_operation_test.cc +1400 -0
- package/third_party/s2geometry/src/s2/s2builder.cc +1828 -0
- package/third_party/s2geometry/src/s2/s2builder.h +1057 -0
- package/third_party/s2geometry/src/s2/s2builder_graph.cc +1084 -0
- package/third_party/s2geometry/src/s2/s2builder_graph.h +799 -0
- package/third_party/s2geometry/src/s2/s2builder_graph_test.cc +462 -0
- package/third_party/s2geometry/src/s2/s2builder_layer.h +50 -0
- package/third_party/s2geometry/src/s2/s2builder_test.cc +1329 -0
- package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.cc +313 -0
- package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.h +221 -0
- package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer_test.cc +261 -0
- package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.cc +392 -0
- package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.h +86 -0
- package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies_test.cc +182 -0
- package/third_party/s2geometry/src/s2/s2builderutil_graph_shape.h +57 -0
- package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.cc +212 -0
- package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.h +218 -0
- package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer_test.cc +367 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.cc +74 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.h +122 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer_test.cc +167 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.cc +191 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.h +211 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer_test.cc +312 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.cc +105 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.h +174 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer_test.cc +220 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.cc +98 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.h +292 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer_test.cc +233 -0
- package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.cc +354 -0
- package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.h +239 -0
- package/third_party/s2geometry/src/s2/s2builderutil_snap_functions_test.cc +716 -0
- package/third_party/s2geometry/src/s2/s2builderutil_testing.cc +37 -0
- package/third_party/s2geometry/src/s2/s2builderutil_testing.h +100 -0
- package/third_party/s2geometry/src/s2/s2builderutil_testing_test.cc +85 -0
- package/third_party/s2geometry/src/s2/s2cap.cc +347 -0
- package/third_party/s2geometry/src/s2/s2cap.h +286 -0
- package/third_party/s2geometry/src/s2/s2cap_test.cc +379 -0
- package/third_party/s2geometry/src/s2/s2cell.cc +552 -0
- package/third_party/s2geometry/src/s2/s2cell.h +249 -0
- package/third_party/s2geometry/src/s2/s2cell_id.cc +619 -0
- package/third_party/s2geometry/src/s2/s2cell_id.h +705 -0
- package/third_party/s2geometry/src/s2/s2cell_id_test.cc +633 -0
- package/third_party/s2geometry/src/s2/s2cell_index.cc +149 -0
- package/third_party/s2geometry/src/s2/s2cell_index.h +660 -0
- package/third_party/s2geometry/src/s2/s2cell_index_test.cc +411 -0
- package/third_party/s2geometry/src/s2/s2cell_test.cc +687 -0
- package/third_party/s2geometry/src/s2/s2cell_union.cc +515 -0
- package/third_party/s2geometry/src/s2/s2cell_union.h +399 -0
- package/third_party/s2geometry/src/s2/s2cell_union_test.cc +598 -0
- package/third_party/s2geometry/src/s2/s2centroids.cc +84 -0
- package/third_party/s2geometry/src/s2/s2centroids.h +87 -0
- package/third_party/s2geometry/src/s2/s2centroids_test.cc +82 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query.cc +123 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query.h +385 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query_base.h +841 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query_base_test.cc +63 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query_test.cc +412 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query.cc +106 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query.h +421 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_base.h +946 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_base_test.cc +59 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_test.cc +505 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_testing.h +91 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query.cc +66 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query.h +465 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query_base.h +767 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query_base_test.cc +63 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query_test.cc +312 -0
- package/third_party/s2geometry/src/s2/s2contains_point_query.h +328 -0
- package/third_party/s2geometry/src/s2/s2contains_point_query_test.cc +159 -0
- package/third_party/s2geometry/src/s2/s2contains_vertex_query.cc +39 -0
- package/third_party/s2geometry/src/s2/s2contains_vertex_query.h +66 -0
- package/third_party/s2geometry/src/s2/s2contains_vertex_query_test.cc +67 -0
- package/third_party/s2geometry/src/s2/s2convex_hull_query.cc +198 -0
- package/third_party/s2geometry/src/s2/s2convex_hull_query.h +110 -0
- package/third_party/s2geometry/src/s2/s2convex_hull_query_test.cc +208 -0
- package/third_party/s2geometry/src/s2/s2coords.cc +146 -0
- package/third_party/s2geometry/src/s2/s2coords.h +459 -0
- package/third_party/s2geometry/src/s2/s2coords_internal.h +71 -0
- package/third_party/s2geometry/src/s2/s2coords_test.cc +218 -0
- package/third_party/s2geometry/src/s2/s2crossing_edge_query.cc +380 -0
- package/third_party/s2geometry/src/s2/s2crossing_edge_query.h +220 -0
- package/third_party/s2geometry/src/s2/s2crossing_edge_query_test.cc +382 -0
- package/third_party/s2geometry/src/s2/s2debug.cc +23 -0
- package/third_party/s2geometry/src/s2/s2debug.h +69 -0
- package/third_party/s2geometry/src/s2/s2distance_target.h +165 -0
- package/third_party/s2geometry/src/s2/s2earth.cc +52 -0
- package/third_party/s2geometry/src/s2/s2earth.h +268 -0
- package/third_party/s2geometry/src/s2/s2earth_test.cc +146 -0
- package/third_party/s2geometry/src/s2/s2edge_clipping.cc +462 -0
- package/third_party/s2geometry/src/s2/s2edge_clipping.h +183 -0
- package/third_party/s2geometry/src/s2/s2edge_clipping_test.cc +335 -0
- package/third_party/s2geometry/src/s2/s2edge_crosser.cc +85 -0
- package/third_party/s2geometry/src/s2/s2edge_crosser.h +343 -0
- package/third_party/s2geometry/src/s2/s2edge_crosser_test.cc +264 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings.cc +515 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings.h +138 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings_internal.h +59 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings_test.cc +246 -0
- package/third_party/s2geometry/src/s2/s2edge_distances.cc +419 -0
- package/third_party/s2geometry/src/s2/s2edge_distances.h +192 -0
- package/third_party/s2geometry/src/s2/s2edge_distances_test.cc +539 -0
- package/third_party/s2geometry/src/s2/s2edge_tessellator.cc +276 -0
- package/third_party/s2geometry/src/s2/s2edge_tessellator.h +101 -0
- package/third_party/s2geometry/src/s2/s2edge_tessellator_test.cc +492 -0
- package/third_party/s2geometry/src/s2/s2edge_vector_shape.h +85 -0
- package/third_party/s2geometry/src/s2/s2edge_vector_shape_test.cc +66 -0
- package/third_party/s2geometry/src/s2/s2error.cc +29 -0
- package/third_party/s2geometry/src/s2/s2error.h +147 -0
- package/third_party/s2geometry/src/s2/s2error_test.cc +31 -0
- package/third_party/s2geometry/src/s2/s2furthest_edge_query.cc +117 -0
- package/third_party/s2geometry/src/s2/s2furthest_edge_query.h +439 -0
- package/third_party/s2geometry/src/s2/s2furthest_edge_query_test.cc +487 -0
- package/third_party/s2geometry/src/s2/s2latlng.cc +90 -0
- package/third_party/s2geometry/src/s2/s2latlng.h +234 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect.cc +727 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect.h +434 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.cc +344 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.h +89 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_bounder_test.cc +306 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_test.cc +1030 -0
- package/third_party/s2geometry/src/s2/s2latlng_test.cc +165 -0
- package/third_party/s2geometry/src/s2/s2lax_loop_shape.cc +104 -0
- package/third_party/s2geometry/src/s2/s2lax_loop_shape.h +153 -0
- package/third_party/s2geometry/src/s2/s2lax_loop_shape_test.cc +101 -0
- package/third_party/s2geometry/src/s2/s2lax_polygon_shape.cc +348 -0
- package/third_party/s2geometry/src/s2/s2lax_polygon_shape.h +183 -0
- package/third_party/s2geometry/src/s2/s2lax_polygon_shape_test.cc +234 -0
- package/third_party/s2geometry/src/s2/s2lax_polyline_shape.cc +118 -0
- package/third_party/s2geometry/src/s2/s2lax_polyline_shape.h +124 -0
- package/third_party/s2geometry/src/s2/s2lax_polyline_shape_test.cc +62 -0
- package/third_party/s2geometry/src/s2/s2loop.cc +1509 -0
- package/third_party/s2geometry/src/s2/s2loop.h +711 -0
- package/third_party/s2geometry/src/s2/s2loop_measures.cc +313 -0
- package/third_party/s2geometry/src/s2/s2loop_measures.h +280 -0
- package/third_party/s2geometry/src/s2/s2loop_measures_test.cc +367 -0
- package/third_party/s2geometry/src/s2/s2loop_test.cc +1371 -0
- package/third_party/s2geometry/src/s2/s2max_distance_targets.cc +265 -0
- package/third_party/s2geometry/src/s2/s2max_distance_targets.h +241 -0
- package/third_party/s2geometry/src/s2/s2max_distance_targets_test.cc +367 -0
- package/third_party/s2geometry/src/s2/s2measures.cc +128 -0
- package/third_party/s2geometry/src/s2/s2measures.h +78 -0
- package/third_party/s2geometry/src/s2/s2measures_test.cc +135 -0
- package/third_party/s2geometry/src/s2/s2metrics.cc +122 -0
- package/third_party/s2geometry/src/s2/s2metrics.h +199 -0
- package/third_party/s2geometry/src/s2/s2metrics_test.cc +127 -0
- package/third_party/s2geometry/src/s2/s2min_distance_targets.cc +295 -0
- package/third_party/s2geometry/src/s2/s2min_distance_targets.h +273 -0
- package/third_party/s2geometry/src/s2/s2min_distance_targets_test.cc +239 -0
- package/third_party/s2geometry/src/s2/s2padded_cell.cc +162 -0
- package/third_party/s2geometry/src/s2/s2padded_cell.h +108 -0
- package/third_party/s2geometry/src/s2/s2padded_cell_test.cc +138 -0
- package/third_party/s2geometry/src/s2/s2point.h +38 -0
- package/third_party/s2geometry/src/s2/s2point_compression.cc +388 -0
- package/third_party/s2geometry/src/s2/s2point_compression.h +78 -0
- package/third_party/s2geometry/src/s2/s2point_compression_test.cc +305 -0
- package/third_party/s2geometry/src/s2/s2point_index.h +345 -0
- package/third_party/s2geometry/src/s2/s2point_index_test.cc +147 -0
- package/third_party/s2geometry/src/s2/s2point_region.cc +72 -0
- package/third_party/s2geometry/src/s2/s2point_region.h +76 -0
- package/third_party/s2geometry/src/s2/s2point_region_test.cc +100 -0
- package/third_party/s2geometry/src/s2/s2point_span.h +57 -0
- package/third_party/s2geometry/src/s2/s2point_test.cc +47 -0
- package/third_party/s2geometry/src/s2/s2point_vector_shape.h +127 -0
- package/third_party/s2geometry/src/s2/s2point_vector_shape_test.cc +59 -0
- package/third_party/s2geometry/src/s2/s2pointutil.cc +131 -0
- package/third_party/s2geometry/src/s2/s2pointutil.h +138 -0
- package/third_party/s2geometry/src/s2/s2pointutil_test.cc +157 -0
- package/third_party/s2geometry/src/s2/s2polygon.cc +1569 -0
- package/third_party/s2geometry/src/s2/s2polygon.h +934 -0
- package/third_party/s2geometry/src/s2/s2polygon_test.cc +3025 -0
- package/third_party/s2geometry/src/s2/s2polyline.cc +645 -0
- package/third_party/s2geometry/src/s2/s2polyline.h +379 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment.cc +414 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment.h +245 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment_internal.h +158 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment_test.cc +610 -0
- package/third_party/s2geometry/src/s2/s2polyline_measures.cc +42 -0
- package/third_party/s2geometry/src/s2/s2polyline_measures.h +53 -0
- package/third_party/s2geometry/src/s2/s2polyline_measures_test.cc +57 -0
- package/third_party/s2geometry/src/s2/s2polyline_simplifier.cc +187 -0
- package/third_party/s2geometry/src/s2/s2polyline_simplifier.h +109 -0
- package/third_party/s2geometry/src/s2/s2polyline_simplifier_test.cc +165 -0
- package/third_party/s2geometry/src/s2/s2polyline_test.cc +554 -0
- package/third_party/s2geometry/src/s2/s2predicates.cc +1486 -0
- package/third_party/s2geometry/src/s2/s2predicates.h +282 -0
- package/third_party/s2geometry/src/s2/s2predicates_internal.h +135 -0
- package/third_party/s2geometry/src/s2/s2predicates_test.cc +1427 -0
- package/third_party/s2geometry/src/s2/s2projections.cc +109 -0
- package/third_party/s2geometry/src/s2/s2projections.h +161 -0
- package/third_party/s2geometry/src/s2/s2projections_test.cc +78 -0
- package/third_party/s2geometry/src/s2/s2r2rect.cc +88 -0
- package/third_party/s2geometry/src/s2/s2r2rect.h +292 -0
- package/third_party/s2geometry/src/s2/s2r2rect_test.cc +312 -0
- package/third_party/s2geometry/src/s2/s2region.cc +26 -0
- package/third_party/s2geometry/src/s2/s2region.h +142 -0
- package/third_party/s2geometry/src/s2/s2region_coverer.cc +514 -0
- package/third_party/s2geometry/src/s2/s2region_coverer.h +356 -0
- package/third_party/s2geometry/src/s2/s2region_coverer_test.cc +509 -0
- package/third_party/s2geometry/src/s2/s2region_intersection.cc +84 -0
- package/third_party/s2geometry/src/s2/s2region_intersection.h +79 -0
- package/third_party/s2geometry/src/s2/s2region_term_indexer.cc +270 -0
- package/third_party/s2geometry/src/s2/s2region_term_indexer.h +299 -0
- package/third_party/s2geometry/src/s2/s2region_term_indexer_test.cc +209 -0
- package/third_party/s2geometry/src/s2/s2region_test.cc +370 -0
- package/third_party/s2geometry/src/s2/s2region_union.cc +90 -0
- package/third_party/s2geometry/src/s2/s2region_union.h +83 -0
- package/third_party/s2geometry/src/s2/s2region_union_test.cc +89 -0
- package/third_party/s2geometry/src/s2/s2shape.h +283 -0
- package/third_party/s2geometry/src/s2/s2shape_index.cc +321 -0
- package/third_party/s2geometry/src/s2/s2shape_index.h +781 -0
- package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.cc +113 -0
- package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.h +135 -0
- package/third_party/s2geometry/src/s2/s2shape_index_buffered_region_test.cc +162 -0
- package/third_party/s2geometry/src/s2/s2shape_index_measures.cc +92 -0
- package/third_party/s2geometry/src/s2/s2shape_index_measures.h +100 -0
- package/third_party/s2geometry/src/s2/s2shape_index_measures_test.cc +136 -0
- package/third_party/s2geometry/src/s2/s2shape_index_region.h +350 -0
- package/third_party/s2geometry/src/s2/s2shape_index_region_test.cc +161 -0
- package/third_party/s2geometry/src/s2/s2shape_index_test.cc +24 -0
- package/third_party/s2geometry/src/s2/s2shape_measures.cc +138 -0
- package/third_party/s2geometry/src/s2/s2shape_measures.h +95 -0
- package/third_party/s2geometry/src/s2/s2shape_measures_test.cc +139 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.cc +120 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.h +66 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries_test.cc +170 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_coding.cc +253 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_coding.h +283 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_coding_test.cc +54 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.cc +40 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.h +41 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force_test.cc +55 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_count_edges.h +57 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_count_edges_test.cc +43 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.cc +45 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.h +72 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator_test.cc +116 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.cc +107 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.h +48 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point_test.cc +104 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.cc +58 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.h +65 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator_test.cc +61 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge.h +58 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge_id.h +97 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_testing.cc +104 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_testing.h +36 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.cc +440 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.h +72 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs_test.cc +184 -0
- package/third_party/s2geometry/src/s2/s2testing.cc +464 -0
- package/third_party/s2geometry/src/s2/s2testing.h +385 -0
- package/third_party/s2geometry/src/s2/s2testing_test.cc +166 -0
- package/third_party/s2geometry/src/s2/s2text_format.cc +506 -0
- package/third_party/s2geometry/src/s2/s2text_format.h +289 -0
- package/third_party/s2geometry/src/s2/s2text_format_test.cc +417 -0
- package/third_party/s2geometry/src/s2/s2wedge_relations.cc +80 -0
- package/third_party/s2geometry/src/s2/s2wedge_relations.h +64 -0
- package/third_party/s2geometry/src/s2/s2wedge_relations_test.cc +89 -0
- package/third_party/s2geometry/src/s2/sequence_lexicon.h +296 -0
- package/third_party/s2geometry/src/s2/sequence_lexicon_test.cc +113 -0
- package/third_party/s2geometry/src/s2/strings/ostringstream.cc +35 -0
- package/third_party/s2geometry/src/s2/strings/ostringstream.h +105 -0
- package/third_party/s2geometry/src/s2/strings/serialize.cc +46 -0
- package/third_party/s2geometry/src/s2/strings/serialize.h +40 -0
- package/third_party/s2geometry/src/s2/third_party/absl/algorithm/algorithm.h +187 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/attributes.h +666 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/casts.h +189 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/config.h +462 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.cc +129 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.h +394 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/atomic_hook.h +168 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/identity.h +33 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/inline_variable.h +117 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/invoke.h +188 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.cc +254 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.h +205 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.cc +106 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.h +71 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/unaligned_access.h +322 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/log_severity.h +77 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/macros.h +236 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/optimization.h +177 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/policy_checks.h +124 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/port.h +97 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/thread_annotations.h +277 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/fixed_array.h +523 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/inlined_vector.h +1453 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/internal/compressed_tuple.h +191 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/internal/container_memory.h +424 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/internal/layout.h +739 -0
- package/third_party/s2geometry/src/s2/third_party/absl/memory/memory.h +755 -0
- package/third_party/s2geometry/src/s2/third_party/absl/meta/type_traits.h +436 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.cc +232 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.h +656 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_have_intrinsic.inc +3 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_no_intrinsic.inc +3 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.cc +198 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.h +239 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii_ctype.h +66 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/bits.h +53 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.cc +110 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.h +146 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/resize_uninitialized.h +72 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/match.cc +38 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/match.h +89 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.cc +909 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.h +187 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.cc +240 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.h +398 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_join.h +22 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.cc +47 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.h +43 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.cc +245 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.h +602 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.cc +42 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.h +130 -0
- package/third_party/s2geometry/src/s2/third_party/absl/types/span.h +793 -0
- package/third_party/s2geometry/src/s2/third_party/absl/utility/utility.h +299 -0
- package/third_party/s2geometry/src/s2/util/bits/bit-interleave.cc +274 -0
- package/third_party/s2geometry/src/s2/util/bits/bit-interleave.h +53 -0
- package/third_party/s2geometry/src/s2/util/bits/bits.cc +155 -0
- package/third_party/s2geometry/src/s2/util/bits/bits.h +745 -0
- package/third_party/s2geometry/src/s2/util/coding/coder.cc +83 -0
- package/third_party/s2geometry/src/s2/util/coding/coder.h +553 -0
- package/third_party/s2geometry/src/s2/util/coding/nth-derivative.h +134 -0
- package/third_party/s2geometry/src/s2/util/coding/transforms.h +62 -0
- package/third_party/s2geometry/src/s2/util/coding/varint.cc +289 -0
- package/third_party/s2geometry/src/s2/util/coding/varint.h +476 -0
- package/third_party/s2geometry/src/s2/util/endian/endian.h +859 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree.h +2471 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree_container.h +411 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree_map.h +79 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree_set.h +73 -0
- package/third_party/s2geometry/src/s2/util/gtl/compact_array.h +653 -0
- package/third_party/s2geometry/src/s2/util/gtl/container_logging.h +291 -0
- package/third_party/s2geometry/src/s2/util/gtl/dense_hash_set.h +358 -0
- package/third_party/s2geometry/src/s2/util/gtl/densehashtable.h +1493 -0
- package/third_party/s2geometry/src/s2/util/gtl/hashtable_common.h +253 -0
- package/third_party/s2geometry/src/s2/util/gtl/layout.h +28 -0
- package/third_party/s2geometry/src/s2/util/gtl/legacy_random_shuffle.h +77 -0
- package/third_party/s2geometry/src/s2/util/hash/mix.h +76 -0
- package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.cc +832 -0
- package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.h +646 -0
- package/third_party/s2geometry/src/s2/util/math/mathutil.cc +75 -0
- package/third_party/s2geometry/src/s2/util/math/mathutil.h +189 -0
- package/third_party/s2geometry/src/s2/util/math/matrix3x3.h +574 -0
- package/third_party/s2geometry/src/s2/util/math/vector.h +569 -0
- package/third_party/s2geometry/src/s2/util/math/vector3_hash.h +54 -0
- package/third_party/s2geometry/src/s2/util/units/length-units.cc +21 -0
- package/third_party/s2geometry/src/s2/util/units/length-units.h +135 -0
- package/third_party/s2geometry/src/s2/util/units/physical-units.h +313 -0
- package/third_party/s2geometry/src/s2/value_lexicon.h +234 -0
- package/third_party/s2geometry/src/s2/value_lexicon_test.cc +121 -0
- package/third_party/s2geometry/third_party/cmake/FindGFlags.cmake +48 -0
- 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
|