@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,218 @@
|
|
|
1
|
+
// Copyright 2005 Google Inc. All Rights Reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS-IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
// Author: ericv@google.com (Eric Veach)
|
|
17
|
+
|
|
18
|
+
#include "s2/s2coords.h"
|
|
19
|
+
|
|
20
|
+
#include <cmath>
|
|
21
|
+
|
|
22
|
+
#include <gtest/gtest.h>
|
|
23
|
+
#include "s2/s2cell_id.h"
|
|
24
|
+
#include "s2/s2coords_internal.h"
|
|
25
|
+
#include "s2/s2testing.h"
|
|
26
|
+
|
|
27
|
+
using std::fabs;
|
|
28
|
+
using S2::internal::kSwapMask;
|
|
29
|
+
using S2::internal::kInvertMask;
|
|
30
|
+
using S2::internal::kIJtoPos;
|
|
31
|
+
using S2::internal::kPosToIJ;
|
|
32
|
+
|
|
33
|
+
inline static int SwapAxes(int ij) {
|
|
34
|
+
return ((ij >> 1) & 1) + ((ij & 1) << 1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
inline static int InvertBits(int ij) {
|
|
38
|
+
return ij ^ 3;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
TEST(S2, TraversalOrder) {
|
|
42
|
+
for (int r = 0; r < 4; ++r) {
|
|
43
|
+
for (int i = 0; i < 4; ++i) {
|
|
44
|
+
// Check consistency with respect to swapping axes.
|
|
45
|
+
EXPECT_EQ(kIJtoPos[r][i],
|
|
46
|
+
kIJtoPos[r ^ kSwapMask][SwapAxes(i)]);
|
|
47
|
+
EXPECT_EQ(kPosToIJ[r][i],
|
|
48
|
+
SwapAxes(kPosToIJ[r ^ kSwapMask][i]));
|
|
49
|
+
|
|
50
|
+
// Check consistency with respect to reversing axis directions.
|
|
51
|
+
EXPECT_EQ(kIJtoPos[r][i],
|
|
52
|
+
kIJtoPos[r ^ kInvertMask][InvertBits(i)]);
|
|
53
|
+
EXPECT_EQ(kPosToIJ[r][i],
|
|
54
|
+
InvertBits(kPosToIJ[r ^ kInvertMask][i]));
|
|
55
|
+
|
|
56
|
+
// Check that the two tables are inverses of each other.
|
|
57
|
+
EXPECT_EQ(kIJtoPos[r][kPosToIJ[r][i]], i);
|
|
58
|
+
EXPECT_EQ(kPosToIJ[r][kIJtoPos[r][i]], i);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
TEST(S2, ST_UV_Conversions) {
|
|
64
|
+
// Check boundary conditions.
|
|
65
|
+
for (double s = 0; s <= 1; s += 0.5) {
|
|
66
|
+
volatile double u = S2::STtoUV(s);
|
|
67
|
+
EXPECT_EQ(u, 2 * s - 1);
|
|
68
|
+
}
|
|
69
|
+
for (double u = -1; u <= 1; ++u) {
|
|
70
|
+
volatile double s = S2::UVtoST(u);
|
|
71
|
+
EXPECT_EQ(s, 0.5 * (u + 1));
|
|
72
|
+
}
|
|
73
|
+
// Check that UVtoST and STtoUV are inverses.
|
|
74
|
+
for (double x = 0; x <= 1; x += 0.0001) {
|
|
75
|
+
EXPECT_NEAR(S2::UVtoST(S2::STtoUV(x)), x, 1e-15);
|
|
76
|
+
EXPECT_NEAR(S2::STtoUV(S2::UVtoST(2*x-1)), 2*x-1, 1e-15);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
TEST(S2, FaceUVtoXYZ) {
|
|
81
|
+
// Check that each face appears exactly once.
|
|
82
|
+
S2Point sum;
|
|
83
|
+
for (int face = 0; face < 6; ++face) {
|
|
84
|
+
S2Point center = S2::FaceUVtoXYZ(face, 0, 0);
|
|
85
|
+
EXPECT_EQ(S2::GetNorm(face), center);
|
|
86
|
+
EXPECT_EQ(fabs(center[center.LargestAbsComponent()]), 1);
|
|
87
|
+
sum += center.Fabs();
|
|
88
|
+
}
|
|
89
|
+
EXPECT_EQ(sum, S2Point(2, 2, 2));
|
|
90
|
+
|
|
91
|
+
// Check that each face has a right-handed coordinate system.
|
|
92
|
+
for (int face = 0; face < 6; ++face) {
|
|
93
|
+
EXPECT_EQ(S2::GetUAxis(face).CrossProd(S2::GetVAxis(face))
|
|
94
|
+
.DotProd(S2::FaceUVtoXYZ(face, 0, 0)), 1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check that the Hilbert curves on each face combine to form a
|
|
98
|
+
// continuous curve over the entire cube.
|
|
99
|
+
for (int face = 0; face < 6; ++face) {
|
|
100
|
+
// The Hilbert curve on each face starts at (-1,-1) and terminates
|
|
101
|
+
// at either (1,-1) (if axes not swapped) or (-1,1) (if swapped).
|
|
102
|
+
int sign = (face & kSwapMask) ? -1 : 1;
|
|
103
|
+
EXPECT_EQ(S2::FaceUVtoXYZ(face, sign, -sign),
|
|
104
|
+
S2::FaceUVtoXYZ((face + 1) % 6, -1, -1));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
TEST(S2, FaceXYZtoUVW) {
|
|
109
|
+
for (int face = 0; face < 6; ++face) {
|
|
110
|
+
EXPECT_EQ(S2Point( 0, 0, 0), S2::FaceXYZtoUVW(face, S2Point(0, 0, 0)));
|
|
111
|
+
EXPECT_EQ(S2Point( 1, 0, 0), S2::FaceXYZtoUVW(face, S2::GetUAxis(face)));
|
|
112
|
+
EXPECT_EQ(S2Point(-1, 0, 0), S2::FaceXYZtoUVW(face, -S2::GetUAxis(face)));
|
|
113
|
+
EXPECT_EQ(S2Point( 0, 1, 0), S2::FaceXYZtoUVW(face, S2::GetVAxis(face)));
|
|
114
|
+
EXPECT_EQ(S2Point( 0, -1, 0), S2::FaceXYZtoUVW(face, -S2::GetVAxis(face)));
|
|
115
|
+
EXPECT_EQ(S2Point( 0, 0, 1), S2::FaceXYZtoUVW(face, S2::GetNorm(face)));
|
|
116
|
+
EXPECT_EQ(S2Point( 0, 0, -1), S2::FaceXYZtoUVW(face, -S2::GetNorm(face)));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
TEST(S2, XYZToFaceSiTi) {
|
|
121
|
+
// Check the conversion of random cells to center points and back.
|
|
122
|
+
for (int level = 0; level <= S2CellId::kMaxLevel; ++level) {
|
|
123
|
+
for (int i = 0; i < 1000; ++i) {
|
|
124
|
+
S2CellId id = S2Testing::GetRandomCellId(level);
|
|
125
|
+
int face;
|
|
126
|
+
unsigned int si, ti;
|
|
127
|
+
int actual_level = S2::XYZtoFaceSiTi(id.ToPoint(), &face, &si, &ti);
|
|
128
|
+
EXPECT_EQ(level, actual_level);
|
|
129
|
+
S2CellId actual_id =
|
|
130
|
+
S2CellId::FromFaceIJ(face, si / 2, ti / 2).parent(level);
|
|
131
|
+
EXPECT_EQ(id, actual_id);
|
|
132
|
+
|
|
133
|
+
// Now test a point near the cell center but not equal to it.
|
|
134
|
+
S2Point p_moved = id.ToPoint() + S2Point(1e-13, 1e-13, 1e-13);
|
|
135
|
+
int face_moved;
|
|
136
|
+
unsigned int si_moved, ti_moved;
|
|
137
|
+
actual_level = S2::XYZtoFaceSiTi(p_moved, &face_moved, &si_moved,
|
|
138
|
+
&ti_moved);
|
|
139
|
+
EXPECT_EQ(-1, actual_level);
|
|
140
|
+
EXPECT_EQ(face, face_moved);
|
|
141
|
+
EXPECT_EQ(si, si_moved);
|
|
142
|
+
EXPECT_EQ(ti, ti_moved);
|
|
143
|
+
|
|
144
|
+
// Finally, test some random (si,ti) values that may be at different
|
|
145
|
+
// levels, or not at a valid level at all (for example, si == 0).
|
|
146
|
+
int face_random = S2Testing::rnd.Uniform(S2CellId::kNumFaces);
|
|
147
|
+
unsigned int si_random, ti_random;
|
|
148
|
+
unsigned int mask = -1 << (S2CellId::kMaxLevel - level);
|
|
149
|
+
do {
|
|
150
|
+
si_random = S2Testing::rnd.Rand32() & mask;
|
|
151
|
+
ti_random = S2Testing::rnd.Rand32() & mask;
|
|
152
|
+
} while (si_random > S2::kMaxSiTi || ti_random > S2::kMaxSiTi);
|
|
153
|
+
S2Point p_random = S2::FaceSiTitoXYZ(face_random, si_random, ti_random);
|
|
154
|
+
actual_level = S2::XYZtoFaceSiTi(p_random, &face, &si, &ti);
|
|
155
|
+
if (face != face_random) {
|
|
156
|
+
// The chosen point is on the edge of a top-level face cell.
|
|
157
|
+
EXPECT_EQ(-1, actual_level);
|
|
158
|
+
EXPECT_TRUE(si == 0 || si == S2::kMaxSiTi ||
|
|
159
|
+
ti == 0 || ti == S2::kMaxSiTi);
|
|
160
|
+
} else {
|
|
161
|
+
EXPECT_EQ(si_random, si);
|
|
162
|
+
EXPECT_EQ(ti_random, ti);
|
|
163
|
+
if (actual_level >= 0) {
|
|
164
|
+
EXPECT_EQ(p_random,
|
|
165
|
+
S2CellId::FromFaceIJ(face, si / 2, ti / 2).
|
|
166
|
+
parent(actual_level).ToPoint());
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
TEST(S2, UVNorms) {
|
|
174
|
+
// Check that GetUNorm and GetVNorm compute right-handed normals for
|
|
175
|
+
// an edge in the increasing U or V direction.
|
|
176
|
+
for (int face = 0; face < 6; ++face) {
|
|
177
|
+
for (double x = -1; x <= 1; x += 1/1024.) {
|
|
178
|
+
EXPECT_DOUBLE_EQ(S2::FaceUVtoXYZ(face, x, -1)
|
|
179
|
+
.CrossProd(S2::FaceUVtoXYZ(face, x, 1))
|
|
180
|
+
.Angle(S2::GetUNorm(face, x)), 0);
|
|
181
|
+
EXPECT_DOUBLE_EQ(S2::FaceUVtoXYZ(face, -1, x)
|
|
182
|
+
.CrossProd(S2::FaceUVtoXYZ(face, 1, x))
|
|
183
|
+
.Angle(S2::GetVNorm(face, x)), 0);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
TEST(S2, UVWAxis) {
|
|
189
|
+
for (int face = 0; face < 6; ++face) {
|
|
190
|
+
// Check that axes are consistent with FaceUVtoXYZ.
|
|
191
|
+
EXPECT_EQ(S2::FaceUVtoXYZ(face, 1, 0) - S2::FaceUVtoXYZ(face, 0, 0),
|
|
192
|
+
S2::GetUAxis(face));
|
|
193
|
+
EXPECT_EQ(S2::FaceUVtoXYZ(face, 0, 1) - S2::FaceUVtoXYZ(face, 0, 0),
|
|
194
|
+
S2::GetVAxis(face));
|
|
195
|
+
EXPECT_EQ(S2::FaceUVtoXYZ(face, 0, 0), S2::GetNorm(face));
|
|
196
|
+
|
|
197
|
+
// Check that every face coordinate frame is right-handed.
|
|
198
|
+
EXPECT_EQ(1, S2::GetUAxis(face).CrossProd(S2::GetVAxis(face))
|
|
199
|
+
.DotProd(S2::GetNorm(face)));
|
|
200
|
+
|
|
201
|
+
// Check that GetUVWAxis is consistent with GetUAxis, GetVAxis, GetNorm.
|
|
202
|
+
EXPECT_EQ(S2::GetUAxis(face), S2::GetUVWAxis(face, 0));
|
|
203
|
+
EXPECT_EQ(S2::GetVAxis(face), S2::GetUVWAxis(face, 1));
|
|
204
|
+
EXPECT_EQ(S2::GetNorm(face), S2::GetUVWAxis(face, 2));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
TEST(S2, UVWFace) {
|
|
209
|
+
// Check that GetUVWFace is consistent with GetUVWAxis.
|
|
210
|
+
for (int face = 0; face < 6; ++face) {
|
|
211
|
+
for (int axis = 0; axis < 3; ++axis) {
|
|
212
|
+
EXPECT_EQ(S2::GetFace(-S2::GetUVWAxis(face, axis)),
|
|
213
|
+
S2::GetUVWFace(face, axis, 0));
|
|
214
|
+
EXPECT_EQ(S2::GetFace(S2::GetUVWAxis(face, axis)),
|
|
215
|
+
S2::GetUVWFace(face, axis, 1));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS-IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
// Author: ericv@google.com (Eric Veach)
|
|
17
|
+
|
|
18
|
+
#include "s2/s2crossing_edge_query.h"
|
|
19
|
+
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <vector>
|
|
22
|
+
|
|
23
|
+
#include "s2/base/logging.h"
|
|
24
|
+
#include "s2/r1interval.h"
|
|
25
|
+
#include "s2/s2cell_id.h"
|
|
26
|
+
#include "s2/s2edge_clipping.h"
|
|
27
|
+
#include "s2/s2edge_crosser.h"
|
|
28
|
+
#include "s2/s2shapeutil_count_edges.h"
|
|
29
|
+
|
|
30
|
+
using s2shapeutil::ShapeEdge;
|
|
31
|
+
using s2shapeutil::ShapeEdgeId;
|
|
32
|
+
using std::vector;
|
|
33
|
+
|
|
34
|
+
// For small loops it is faster to use brute force. The threshold below was
|
|
35
|
+
// determined using the benchmarks in the unit test.
|
|
36
|
+
static const int kMaxBruteForceEdges = 27;
|
|
37
|
+
|
|
38
|
+
S2CrossingEdgeQuery::S2CrossingEdgeQuery() {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
S2CrossingEdgeQuery::~S2CrossingEdgeQuery() {
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void S2CrossingEdgeQuery::Init(const S2ShapeIndex* index) {
|
|
45
|
+
index_ = index;
|
|
46
|
+
iter_.Init(index);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vector<s2shapeutil::ShapeEdge> S2CrossingEdgeQuery::GetCrossingEdges(
|
|
50
|
+
const S2Point& a0, const S2Point& a1, CrossingType type) {
|
|
51
|
+
vector<s2shapeutil::ShapeEdge> edges;
|
|
52
|
+
GetCrossingEdges(a0, a1, type, &edges);
|
|
53
|
+
return edges;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
vector<s2shapeutil::ShapeEdge> S2CrossingEdgeQuery::GetCrossingEdges(
|
|
57
|
+
const S2Point& a0, const S2Point& a1, const S2Shape& shape,
|
|
58
|
+
CrossingType type) {
|
|
59
|
+
vector<s2shapeutil::ShapeEdge> edges;
|
|
60
|
+
GetCrossingEdges(a0, a1, shape, type, &edges);
|
|
61
|
+
return edges;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void S2CrossingEdgeQuery::GetCrossingEdges(
|
|
65
|
+
const S2Point& a0, const S2Point& a1, CrossingType type,
|
|
66
|
+
vector<ShapeEdge>* edges) {
|
|
67
|
+
edges->clear();
|
|
68
|
+
GetCandidates(a0, a1, &tmp_candidates_);
|
|
69
|
+
int min_sign = (type == CrossingType::ALL) ? 0 : 1;
|
|
70
|
+
S2CopyingEdgeCrosser crosser(a0, a1);
|
|
71
|
+
int shape_id = -1;
|
|
72
|
+
const S2Shape* shape = nullptr;
|
|
73
|
+
for (ShapeEdgeId candidate : tmp_candidates_) {
|
|
74
|
+
if (candidate.shape_id != shape_id) {
|
|
75
|
+
shape_id = candidate.shape_id;
|
|
76
|
+
shape = index_->shape(shape_id);
|
|
77
|
+
}
|
|
78
|
+
int edge_id = candidate.edge_id;
|
|
79
|
+
S2Shape::Edge b = shape->edge(edge_id);
|
|
80
|
+
if (crosser.CrossingSign(b.v0, b.v1) >= min_sign) {
|
|
81
|
+
edges->push_back(ShapeEdge(shape_id, edge_id, b));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void S2CrossingEdgeQuery::GetCrossingEdges(
|
|
87
|
+
const S2Point& a0, const S2Point& a1, const S2Shape& shape,
|
|
88
|
+
CrossingType type, vector<ShapeEdge>* edges) {
|
|
89
|
+
edges->clear();
|
|
90
|
+
GetCandidates(a0, a1, shape, &tmp_candidates_);
|
|
91
|
+
int min_sign = (type == CrossingType::ALL) ? 0 : 1;
|
|
92
|
+
S2CopyingEdgeCrosser crosser(a0, a1);
|
|
93
|
+
for (ShapeEdgeId candidate : tmp_candidates_) {
|
|
94
|
+
int edge_id = candidate.edge_id;
|
|
95
|
+
S2Shape::Edge b = shape.edge(edge_id);
|
|
96
|
+
if (crosser.CrossingSign(b.v0, b.v1) >= min_sign) {
|
|
97
|
+
edges->push_back(ShapeEdge(shape.id(), edge_id, b));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
vector<ShapeEdgeId> S2CrossingEdgeQuery::GetCandidates(
|
|
103
|
+
const S2Point& a0, const S2Point& a1) {
|
|
104
|
+
vector<ShapeEdgeId> edges;
|
|
105
|
+
GetCandidates(a0, a1, &edges);
|
|
106
|
+
return edges;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
vector<ShapeEdgeId> S2CrossingEdgeQuery::GetCandidates(
|
|
110
|
+
const S2Point& a0, const S2Point& a1, const S2Shape& shape) {
|
|
111
|
+
vector<ShapeEdgeId> edges;
|
|
112
|
+
GetCandidates(a0, a1, shape, &edges);
|
|
113
|
+
return edges;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void S2CrossingEdgeQuery::GetCandidates(const S2Point& a0, const S2Point& a1,
|
|
117
|
+
vector<ShapeEdgeId>* edges) {
|
|
118
|
+
edges->clear();
|
|
119
|
+
int num_edges = s2shapeutil::CountEdgesUpTo(*index_, kMaxBruteForceEdges + 1);
|
|
120
|
+
if (num_edges <= kMaxBruteForceEdges) {
|
|
121
|
+
edges->reserve(num_edges);
|
|
122
|
+
}
|
|
123
|
+
VisitRawCandidates(a0, a1, [edges](ShapeEdgeId id) {
|
|
124
|
+
edges->push_back(id);
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
127
|
+
if (edges->size() > 1) {
|
|
128
|
+
std::sort(edges->begin(), edges->end());
|
|
129
|
+
edges->erase(std::unique(edges->begin(), edges->end()), edges->end());
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
void S2CrossingEdgeQuery::GetCandidates(const S2Point& a0, const S2Point& a1,
|
|
134
|
+
const S2Shape& shape,
|
|
135
|
+
vector<ShapeEdgeId>* edges) {
|
|
136
|
+
edges->clear();
|
|
137
|
+
int num_edges = shape.num_edges();
|
|
138
|
+
if (num_edges <= kMaxBruteForceEdges) {
|
|
139
|
+
edges->reserve(num_edges);
|
|
140
|
+
}
|
|
141
|
+
VisitRawCandidates(a0, a1, shape, [edges](ShapeEdgeId id) {
|
|
142
|
+
edges->push_back(id);
|
|
143
|
+
return true;
|
|
144
|
+
});
|
|
145
|
+
if (edges->size() > 1) {
|
|
146
|
+
std::sort(edges->begin(), edges->end());
|
|
147
|
+
edges->erase(std::unique(edges->begin(), edges->end()), edges->end());
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
bool S2CrossingEdgeQuery::VisitRawCandidates(
|
|
152
|
+
const S2Point& a0, const S2Point& a1, const ShapeEdgeIdVisitor& visitor) {
|
|
153
|
+
int num_edges = s2shapeutil::CountEdgesUpTo(*index_, kMaxBruteForceEdges + 1);
|
|
154
|
+
if (num_edges <= kMaxBruteForceEdges) {
|
|
155
|
+
int num_shape_ids = index_->num_shape_ids();
|
|
156
|
+
for (int s = 0; s < num_shape_ids; ++s) {
|
|
157
|
+
const S2Shape* shape = index_->shape(s);
|
|
158
|
+
if (shape == nullptr) continue;
|
|
159
|
+
int num_shape_edges = shape->num_edges();
|
|
160
|
+
for (int e = 0; e < num_shape_edges; ++e) {
|
|
161
|
+
if (!visitor(ShapeEdgeId(s, e))) return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return VisitCells(a0, a1, [&visitor](const S2ShapeIndexCell& cell) {
|
|
167
|
+
for (int s = 0; s < cell.num_clipped(); ++s) {
|
|
168
|
+
const S2ClippedShape& clipped = cell.clipped(s);
|
|
169
|
+
for (int j = 0; j < clipped.num_edges(); ++j) {
|
|
170
|
+
if (!visitor(ShapeEdgeId(clipped.shape_id(), clipped.edge(j)))) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
bool S2CrossingEdgeQuery::VisitRawCandidates(
|
|
180
|
+
const S2Point& a0, const S2Point& a1, const S2Shape& shape,
|
|
181
|
+
const ShapeEdgeIdVisitor& visitor) {
|
|
182
|
+
int num_edges = shape.num_edges();
|
|
183
|
+
if (num_edges <= kMaxBruteForceEdges) {
|
|
184
|
+
for (int e = 0; e < num_edges; ++e) {
|
|
185
|
+
if (!visitor(ShapeEdgeId(shape.id(), e))) return false;
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return VisitCells(a0, a1, [&shape, &visitor](const S2ShapeIndexCell& cell) {
|
|
190
|
+
const S2ClippedShape* clipped = cell.find_clipped(shape.id());
|
|
191
|
+
if (clipped == nullptr) return true;
|
|
192
|
+
for (int j = 0; j < clipped->num_edges(); ++j) {
|
|
193
|
+
if (!visitor(ShapeEdgeId(shape.id(), clipped->edge(j)))) return false;
|
|
194
|
+
}
|
|
195
|
+
return true;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
bool S2CrossingEdgeQuery::VisitCells(const S2Point& a0, const S2Point& a1,
|
|
200
|
+
const CellVisitor& visitor) {
|
|
201
|
+
visitor_ = &visitor;
|
|
202
|
+
S2::FaceSegmentVector segments;
|
|
203
|
+
S2::GetFaceSegments(a0, a1, &segments);
|
|
204
|
+
for (const auto& segment : segments) {
|
|
205
|
+
a0_ = segment.a;
|
|
206
|
+
a1_ = segment.b;
|
|
207
|
+
|
|
208
|
+
// Optimization: rather than always starting the recursive subdivision at
|
|
209
|
+
// the top level face cell, instead we start at the smallest S2CellId that
|
|
210
|
+
// contains the edge (the "edge root cell"). This typically lets us skip
|
|
211
|
+
// quite a few levels of recursion since most edges are short.
|
|
212
|
+
R2Rect edge_bound = R2Rect::FromPointPair(a0_, a1_);
|
|
213
|
+
S2PaddedCell pcell(S2CellId::FromFace(segment.face), 0);
|
|
214
|
+
S2CellId edge_root = pcell.ShrinkToFit(edge_bound);
|
|
215
|
+
|
|
216
|
+
// Now we need to determine how the edge root cell is related to the cells
|
|
217
|
+
// in the spatial index (cell_map_). There are three cases:
|
|
218
|
+
//
|
|
219
|
+
// 1. edge_root is an index cell or is contained within an index cell.
|
|
220
|
+
// In this case we only need to look at the contents of that cell.
|
|
221
|
+
// 2. edge_root is subdivided into one or more index cells. In this case
|
|
222
|
+
// we recursively subdivide to find the cells intersected by a0a1.
|
|
223
|
+
// 3. edge_root does not intersect any index cells. In this case there
|
|
224
|
+
// is nothing to do.
|
|
225
|
+
S2ShapeIndex::CellRelation relation = iter_.Locate(edge_root);
|
|
226
|
+
if (relation == S2ShapeIndex::INDEXED) {
|
|
227
|
+
// edge_root is an index cell or is contained by an index cell (case 1).
|
|
228
|
+
S2_DCHECK(iter_.id().contains(edge_root));
|
|
229
|
+
if (!visitor(iter_.cell())) return false;
|
|
230
|
+
} else if (relation == S2ShapeIndex::SUBDIVIDED) {
|
|
231
|
+
// edge_root is subdivided into one or more index cells (case 2). We
|
|
232
|
+
// find the cells intersected by a0a1 using recursive subdivision.
|
|
233
|
+
if (!edge_root.is_face()) pcell = S2PaddedCell(edge_root, 0);
|
|
234
|
+
if (!VisitCells(pcell, edge_bound)) return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
bool S2CrossingEdgeQuery::VisitCells(
|
|
241
|
+
const S2Point& a0, const S2Point& a1, const S2PaddedCell& root,
|
|
242
|
+
const CellVisitor& visitor) {
|
|
243
|
+
S2_DCHECK_EQ(root.padding(), 0);
|
|
244
|
+
visitor_ = &visitor;
|
|
245
|
+
// We use padding when clipping to ensure that the result is non-empty
|
|
246
|
+
// whenever the edge (a0, a1) intersects the given root cell.
|
|
247
|
+
if (S2::ClipToPaddedFace(a0, a1, root.id().face(),
|
|
248
|
+
S2::kFaceClipErrorUVCoord, &a0_, &a1_)) {
|
|
249
|
+
R2Rect edge_bound = R2Rect::FromPointPair(a0_, a1_);
|
|
250
|
+
if (root.bound().Intersects(edge_bound)) {
|
|
251
|
+
return VisitCells(root, edge_bound);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Computes the index cells intersected by the current edge that are
|
|
258
|
+
// descendants of "pcell" and calls visitor_ for each one.
|
|
259
|
+
//
|
|
260
|
+
// WARNING: This function is recursive with a maximum depth of 30. The frame
|
|
261
|
+
// size is about 2K in versions of GCC prior to 4.7 due to poor overlapping
|
|
262
|
+
// of storage for temporaries. This is fixed in GCC 4.7, reducing the frame
|
|
263
|
+
// size to about 350 bytes (i.e., worst-case total stack usage of about 10K).
|
|
264
|
+
bool S2CrossingEdgeQuery::VisitCells(const S2PaddedCell& pcell,
|
|
265
|
+
const R2Rect& edge_bound) {
|
|
266
|
+
// This code uses S2PaddedCell because it has the methods we need for
|
|
267
|
+
// efficient splitting, however the actual padding is required to be zero.
|
|
268
|
+
S2_DCHECK_EQ(pcell.padding(), 0);
|
|
269
|
+
|
|
270
|
+
iter_.Seek(pcell.id().range_min());
|
|
271
|
+
if (iter_.done() || iter_.id() > pcell.id().range_max()) {
|
|
272
|
+
// The index does not contain "pcell" or any of its descendants.
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
if (iter_.id() == pcell.id()) {
|
|
276
|
+
return (*visitor_)(iter_.cell());
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Otherwise, split the edge among the four children of "pcell".
|
|
280
|
+
R2Point center = pcell.middle().lo();
|
|
281
|
+
if (edge_bound[0].hi() < center[0]) {
|
|
282
|
+
// Edge is entirely contained in the two left children.
|
|
283
|
+
return ClipVAxis(edge_bound, center[1], 0, pcell);
|
|
284
|
+
} else if (edge_bound[0].lo() >= center[0]) {
|
|
285
|
+
// Edge is entirely contained in the two right children.
|
|
286
|
+
return ClipVAxis(edge_bound, center[1], 1, pcell);
|
|
287
|
+
} else {
|
|
288
|
+
R2Rect child_bounds[2];
|
|
289
|
+
SplitUBound(edge_bound, center[0], child_bounds);
|
|
290
|
+
if (edge_bound[1].hi() < center[1]) {
|
|
291
|
+
// Edge is entirely contained in the two lower children.
|
|
292
|
+
return (VisitCells(S2PaddedCell(pcell, 0, 0), child_bounds[0]) &&
|
|
293
|
+
VisitCells(S2PaddedCell(pcell, 1, 0), child_bounds[1]));
|
|
294
|
+
} else if (edge_bound[1].lo() >= center[1]) {
|
|
295
|
+
// Edge is entirely contained in the two upper children.
|
|
296
|
+
return (VisitCells(S2PaddedCell(pcell, 0, 1), child_bounds[0]) &&
|
|
297
|
+
VisitCells(S2PaddedCell(pcell, 1, 1), child_bounds[1]));
|
|
298
|
+
} else {
|
|
299
|
+
// The edge bound spans all four children. The edge itself intersects
|
|
300
|
+
// at most three children (since no padding is being used).
|
|
301
|
+
return (ClipVAxis(child_bounds[0], center[1], 0, pcell) &&
|
|
302
|
+
ClipVAxis(child_bounds[1], center[1], 1, pcell));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Given either the left (i=0) or right (i=1) side of a padded cell "pcell",
|
|
308
|
+
// determine whether the current edge intersects the lower child, upper child,
|
|
309
|
+
// or both children, and call VisitCells() recursively on those children.
|
|
310
|
+
// "center" is the v-coordinate at the center of "pcell".
|
|
311
|
+
inline bool S2CrossingEdgeQuery::ClipVAxis(const R2Rect& edge_bound,
|
|
312
|
+
double center, int i,
|
|
313
|
+
const S2PaddedCell& pcell) {
|
|
314
|
+
if (edge_bound[1].hi() < center) {
|
|
315
|
+
// Edge is entirely contained in the lower child.
|
|
316
|
+
return VisitCells(S2PaddedCell(pcell, i, 0), edge_bound);
|
|
317
|
+
} else if (edge_bound[1].lo() >= center) {
|
|
318
|
+
// Edge is entirely contained in the upper child.
|
|
319
|
+
return VisitCells(S2PaddedCell(pcell, i, 1), edge_bound);
|
|
320
|
+
} else {
|
|
321
|
+
// The edge intersects both children.
|
|
322
|
+
R2Rect child_bounds[2];
|
|
323
|
+
SplitVBound(edge_bound, center, child_bounds);
|
|
324
|
+
return (VisitCells(S2PaddedCell(pcell, i, 0), child_bounds[0]) &&
|
|
325
|
+
VisitCells(S2PaddedCell(pcell, i, 1), child_bounds[1]));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Split the current edge into two child edges at the given u-value "u" and
|
|
330
|
+
// return the bound for each child.
|
|
331
|
+
void S2CrossingEdgeQuery::SplitUBound(const R2Rect& edge_bound, double u,
|
|
332
|
+
R2Rect child_bounds[2]) const {
|
|
333
|
+
// See comments in MutableS2ShapeIndex::ClipUBound.
|
|
334
|
+
double v = edge_bound[1].Project(
|
|
335
|
+
S2::InterpolateDouble(u, a0_[0], a1_[0], a0_[1], a1_[1]));
|
|
336
|
+
|
|
337
|
+
// "diag_" indicates which diagonal of the bounding box is spanned by a0a1:
|
|
338
|
+
// it is 0 if a0a1 has positive slope, and 1 if a0a1 has negative slope.
|
|
339
|
+
int diag = (a0_[0] > a1_[0]) != (a0_[1] > a1_[1]);
|
|
340
|
+
SplitBound(edge_bound, 0, u, diag, v, child_bounds);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Split the current edge into two child edges at the given v-value "v" and
|
|
344
|
+
// return the bound for each child.
|
|
345
|
+
void S2CrossingEdgeQuery::SplitVBound(const R2Rect& edge_bound, double v,
|
|
346
|
+
R2Rect child_bounds[2]) const {
|
|
347
|
+
double u = edge_bound[0].Project(
|
|
348
|
+
S2::InterpolateDouble(v, a0_[1], a1_[1], a0_[0], a1_[0]));
|
|
349
|
+
int diag = (a0_[0] > a1_[0]) != (a0_[1] > a1_[1]);
|
|
350
|
+
SplitBound(edge_bound, diag, u, 0, v, child_bounds);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Split the current edge into two child edges at the given point (u,v) and
|
|
354
|
+
// return the bound for each child. "u_end" and "v_end" indicate which bound
|
|
355
|
+
// endpoints of child 1 will be updated.
|
|
356
|
+
inline void S2CrossingEdgeQuery::SplitBound(const R2Rect& edge_bound, int u_end,
|
|
357
|
+
double u, int v_end, double v,
|
|
358
|
+
R2Rect child_bounds[2]) {
|
|
359
|
+
child_bounds[0] = edge_bound;
|
|
360
|
+
child_bounds[0][0][1 - u_end] = u;
|
|
361
|
+
child_bounds[0][1][1 - v_end] = v;
|
|
362
|
+
S2_DCHECK(!child_bounds[0].is_empty());
|
|
363
|
+
S2_DCHECK(edge_bound.Contains(child_bounds[0]));
|
|
364
|
+
|
|
365
|
+
child_bounds[1] = edge_bound;
|
|
366
|
+
child_bounds[1][0][u_end] = u;
|
|
367
|
+
child_bounds[1][1][v_end] = v;
|
|
368
|
+
S2_DCHECK(!child_bounds[1].is_empty());
|
|
369
|
+
S2_DCHECK(edge_bound.Contains(child_bounds[1]));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
void S2CrossingEdgeQuery::GetCells(const S2Point& a0, const S2Point& a1,
|
|
373
|
+
const S2PaddedCell& root,
|
|
374
|
+
vector<const S2ShapeIndexCell*>* cells) {
|
|
375
|
+
cells->clear();
|
|
376
|
+
VisitCells(a0, a1, root, [cells](const S2ShapeIndexCell& cell) {
|
|
377
|
+
cells->push_back(&cell);
|
|
378
|
+
return true;
|
|
379
|
+
});
|
|
380
|
+
}
|