@sentryware/s2-node 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. package/.circleci/config.yml +45 -0
  2. package/.dockerignore +1 -0
  3. package/.gitmodules +3 -0
  4. package/CHANGELOG.md +33 -0
  5. package/LICENSE +201 -0
  6. package/README.md +147 -0
  7. package/binding.gyp +170 -0
  8. package/docker/Dockerfile.node20.test +8 -0
  9. package/docker/Dockerfile.node22.test +8 -0
  10. package/docker/Dockerfile.node24.test +8 -0
  11. package/index.d.ts +117 -0
  12. package/index.js +6 -0
  13. package/jest.config.js +184 -0
  14. package/package.json +43 -0
  15. package/publish-linux.sh +18 -0
  16. package/publish-osx.sh +19 -0
  17. package/src/builder.cc +84 -0
  18. package/src/builder.h +29 -0
  19. package/src/cell.cc +71 -0
  20. package/src/cell.h +26 -0
  21. package/src/cell_id.cc +210 -0
  22. package/src/cell_id.h +44 -0
  23. package/src/cell_union.cc +237 -0
  24. package/src/cell_union.h +34 -0
  25. package/src/earth.cc +185 -0
  26. package/src/earth.h +33 -0
  27. package/src/latlng.cc +132 -0
  28. package/src/latlng.h +28 -0
  29. package/src/loop.cc +51 -0
  30. package/src/loop.h +21 -0
  31. package/src/point.cc +69 -0
  32. package/src/point.h +23 -0
  33. package/src/polygon.cc +36 -0
  34. package/src/polygon.h +20 -0
  35. package/src/polyline.cc +186 -0
  36. package/src/polyline.h +34 -0
  37. package/src/region_coverer.cc +450 -0
  38. package/src/region_coverer.h +56 -0
  39. package/src/s2.cc +27 -0
  40. package/test/Cell.test.js +37 -0
  41. package/test/CellId.test.js +135 -0
  42. package/test/CellUnion.test.js +150 -0
  43. package/test/Earth.test.js +62 -0
  44. package/test/LatLng.test.js +45 -0
  45. package/test/Point.test.js +14 -0
  46. package/test/Polyline.test.js +78 -0
  47. package/test/RegionCoverer.test.js +301 -0
  48. package/test.sh +16 -0
  49. package/third_party/s2geometry/.travis.yml +163 -0
  50. package/third_party/s2geometry/AUTHORS +13 -0
  51. package/third_party/s2geometry/CONTRIBUTING.md +65 -0
  52. package/third_party/s2geometry/CONTRIBUTORS +30 -0
  53. package/third_party/s2geometry/LICENSE +202 -0
  54. package/third_party/s2geometry/NOTICE +5 -0
  55. package/third_party/s2geometry/README.md +127 -0
  56. package/third_party/s2geometry/doc/examples/point_index.cc +44 -0
  57. package/third_party/s2geometry/doc/examples/term_index.cc +99 -0
  58. package/third_party/s2geometry/doc/examples/term_index.py +101 -0
  59. package/third_party/s2geometry/src/python/coder.i +125 -0
  60. package/third_party/s2geometry/src/python/pywraps2_test.py +786 -0
  61. package/third_party/s2geometry/src/python/s2.i +37 -0
  62. package/third_party/s2geometry/src/python/s2_common.i +756 -0
  63. package/third_party/s2geometry/src/s2/_fp_contract_off.h +60 -0
  64. package/third_party/s2geometry/src/s2/base/casts.h +318 -0
  65. package/third_party/s2geometry/src/s2/base/commandlineflags.h +67 -0
  66. package/third_party/s2geometry/src/s2/base/integral_types.h +31 -0
  67. package/third_party/s2geometry/src/s2/base/log_severity.h +40 -0
  68. package/third_party/s2geometry/src/s2/base/logging.h +173 -0
  69. package/third_party/s2geometry/src/s2/base/mutex.h +61 -0
  70. package/third_party/s2geometry/src/s2/base/port.h +999 -0
  71. package/third_party/s2geometry/src/s2/base/spinlock.h +60 -0
  72. package/third_party/s2geometry/src/s2/base/stringprintf.cc +107 -0
  73. package/third_party/s2geometry/src/s2/base/stringprintf.h +53 -0
  74. package/third_party/s2geometry/src/s2/base/strtoint.cc +65 -0
  75. package/third_party/s2geometry/src/s2/base/strtoint.h +106 -0
  76. package/third_party/s2geometry/src/s2/base/timer.h +50 -0
  77. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.cc +164 -0
  78. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.h +110 -0
  79. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector_test.cc +232 -0
  80. package/third_party/s2geometry/src/s2/encoded_s2point_vector.cc +838 -0
  81. package/third_party/s2geometry/src/s2/encoded_s2point_vector.h +140 -0
  82. package/third_party/s2geometry/src/s2/encoded_s2point_vector_test.cc +344 -0
  83. package/third_party/s2geometry/src/s2/encoded_s2shape_index.cc +181 -0
  84. package/third_party/s2geometry/src/s2/encoded_s2shape_index.h +276 -0
  85. package/third_party/s2geometry/src/s2/encoded_s2shape_index_test.cc +244 -0
  86. package/third_party/s2geometry/src/s2/encoded_string_vector.cc +66 -0
  87. package/third_party/s2geometry/src/s2/encoded_string_vector.h +164 -0
  88. package/third_party/s2geometry/src/s2/encoded_string_vector_test.cc +69 -0
  89. package/third_party/s2geometry/src/s2/encoded_uint_vector.h +299 -0
  90. package/third_party/s2geometry/src/s2/encoded_uint_vector_test.cc +124 -0
  91. package/third_party/s2geometry/src/s2/id_set_lexicon.cc +81 -0
  92. package/third_party/s2geometry/src/s2/id_set_lexicon.h +199 -0
  93. package/third_party/s2geometry/src/s2/id_set_lexicon_test.cc +70 -0
  94. package/third_party/s2geometry/src/s2/mutable_s2shape_index.cc +1585 -0
  95. package/third_party/s2geometry/src/s2/mutable_s2shape_index.h +600 -0
  96. package/third_party/s2geometry/src/s2/mutable_s2shape_index_test.cc +589 -0
  97. package/third_party/s2geometry/src/s2/r1interval.h +220 -0
  98. package/third_party/s2geometry/src/s2/r1interval_test.cc +185 -0
  99. package/third_party/s2geometry/src/s2/r2.h +26 -0
  100. package/third_party/s2geometry/src/s2/r2rect.cc +93 -0
  101. package/third_party/s2geometry/src/s2/r2rect.h +234 -0
  102. package/third_party/s2geometry/src/s2/r2rect_test.cc +228 -0
  103. package/third_party/s2geometry/src/s2/s1angle.cc +54 -0
  104. package/third_party/s2geometry/src/s2/s1angle.h +336 -0
  105. package/third_party/s2geometry/src/s2/s1angle_test.cc +185 -0
  106. package/third_party/s2geometry/src/s2/s1chord_angle.cc +159 -0
  107. package/third_party/s2geometry/src/s2/s1chord_angle.h +369 -0
  108. package/third_party/s2geometry/src/s2/s1chord_angle_test.cc +207 -0
  109. package/third_party/s2geometry/src/s2/s1interval.cc +296 -0
  110. package/third_party/s2geometry/src/s2/s1interval.h +266 -0
  111. package/third_party/s2geometry/src/s2/s1interval_test.cc +469 -0
  112. package/third_party/s2geometry/src/s2/s2boolean_operation.cc +2391 -0
  113. package/third_party/s2geometry/src/s2/s2boolean_operation.h +501 -0
  114. package/third_party/s2geometry/src/s2/s2boolean_operation_test.cc +1400 -0
  115. package/third_party/s2geometry/src/s2/s2builder.cc +1828 -0
  116. package/third_party/s2geometry/src/s2/s2builder.h +1057 -0
  117. package/third_party/s2geometry/src/s2/s2builder_graph.cc +1084 -0
  118. package/third_party/s2geometry/src/s2/s2builder_graph.h +799 -0
  119. package/third_party/s2geometry/src/s2/s2builder_graph_test.cc +462 -0
  120. package/third_party/s2geometry/src/s2/s2builder_layer.h +50 -0
  121. package/third_party/s2geometry/src/s2/s2builder_test.cc +1329 -0
  122. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.cc +313 -0
  123. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.h +221 -0
  124. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer_test.cc +261 -0
  125. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.cc +392 -0
  126. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.h +86 -0
  127. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies_test.cc +182 -0
  128. package/third_party/s2geometry/src/s2/s2builderutil_graph_shape.h +57 -0
  129. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.cc +212 -0
  130. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.h +218 -0
  131. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer_test.cc +367 -0
  132. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.cc +74 -0
  133. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.h +122 -0
  134. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer_test.cc +167 -0
  135. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.cc +191 -0
  136. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.h +211 -0
  137. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer_test.cc +312 -0
  138. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.cc +105 -0
  139. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.h +174 -0
  140. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer_test.cc +220 -0
  141. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.cc +98 -0
  142. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.h +292 -0
  143. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer_test.cc +233 -0
  144. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.cc +354 -0
  145. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.h +239 -0
  146. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions_test.cc +716 -0
  147. package/third_party/s2geometry/src/s2/s2builderutil_testing.cc +37 -0
  148. package/third_party/s2geometry/src/s2/s2builderutil_testing.h +100 -0
  149. package/third_party/s2geometry/src/s2/s2builderutil_testing_test.cc +85 -0
  150. package/third_party/s2geometry/src/s2/s2cap.cc +347 -0
  151. package/third_party/s2geometry/src/s2/s2cap.h +286 -0
  152. package/third_party/s2geometry/src/s2/s2cap_test.cc +379 -0
  153. package/third_party/s2geometry/src/s2/s2cell.cc +552 -0
  154. package/third_party/s2geometry/src/s2/s2cell.h +249 -0
  155. package/third_party/s2geometry/src/s2/s2cell_id.cc +619 -0
  156. package/third_party/s2geometry/src/s2/s2cell_id.h +705 -0
  157. package/third_party/s2geometry/src/s2/s2cell_id_test.cc +633 -0
  158. package/third_party/s2geometry/src/s2/s2cell_index.cc +149 -0
  159. package/third_party/s2geometry/src/s2/s2cell_index.h +660 -0
  160. package/third_party/s2geometry/src/s2/s2cell_index_test.cc +411 -0
  161. package/third_party/s2geometry/src/s2/s2cell_test.cc +687 -0
  162. package/third_party/s2geometry/src/s2/s2cell_union.cc +515 -0
  163. package/third_party/s2geometry/src/s2/s2cell_union.h +399 -0
  164. package/third_party/s2geometry/src/s2/s2cell_union_test.cc +598 -0
  165. package/third_party/s2geometry/src/s2/s2centroids.cc +84 -0
  166. package/third_party/s2geometry/src/s2/s2centroids.h +87 -0
  167. package/third_party/s2geometry/src/s2/s2centroids_test.cc +82 -0
  168. package/third_party/s2geometry/src/s2/s2closest_cell_query.cc +123 -0
  169. package/third_party/s2geometry/src/s2/s2closest_cell_query.h +385 -0
  170. package/third_party/s2geometry/src/s2/s2closest_cell_query_base.h +841 -0
  171. package/third_party/s2geometry/src/s2/s2closest_cell_query_base_test.cc +63 -0
  172. package/third_party/s2geometry/src/s2/s2closest_cell_query_test.cc +412 -0
  173. package/third_party/s2geometry/src/s2/s2closest_edge_query.cc +106 -0
  174. package/third_party/s2geometry/src/s2/s2closest_edge_query.h +421 -0
  175. package/third_party/s2geometry/src/s2/s2closest_edge_query_base.h +946 -0
  176. package/third_party/s2geometry/src/s2/s2closest_edge_query_base_test.cc +59 -0
  177. package/third_party/s2geometry/src/s2/s2closest_edge_query_test.cc +505 -0
  178. package/third_party/s2geometry/src/s2/s2closest_edge_query_testing.h +91 -0
  179. package/third_party/s2geometry/src/s2/s2closest_point_query.cc +66 -0
  180. package/third_party/s2geometry/src/s2/s2closest_point_query.h +465 -0
  181. package/third_party/s2geometry/src/s2/s2closest_point_query_base.h +767 -0
  182. package/third_party/s2geometry/src/s2/s2closest_point_query_base_test.cc +63 -0
  183. package/third_party/s2geometry/src/s2/s2closest_point_query_test.cc +312 -0
  184. package/third_party/s2geometry/src/s2/s2contains_point_query.h +328 -0
  185. package/third_party/s2geometry/src/s2/s2contains_point_query_test.cc +159 -0
  186. package/third_party/s2geometry/src/s2/s2contains_vertex_query.cc +39 -0
  187. package/third_party/s2geometry/src/s2/s2contains_vertex_query.h +66 -0
  188. package/third_party/s2geometry/src/s2/s2contains_vertex_query_test.cc +67 -0
  189. package/third_party/s2geometry/src/s2/s2convex_hull_query.cc +198 -0
  190. package/third_party/s2geometry/src/s2/s2convex_hull_query.h +110 -0
  191. package/third_party/s2geometry/src/s2/s2convex_hull_query_test.cc +208 -0
  192. package/third_party/s2geometry/src/s2/s2coords.cc +146 -0
  193. package/third_party/s2geometry/src/s2/s2coords.h +459 -0
  194. package/third_party/s2geometry/src/s2/s2coords_internal.h +71 -0
  195. package/third_party/s2geometry/src/s2/s2coords_test.cc +218 -0
  196. package/third_party/s2geometry/src/s2/s2crossing_edge_query.cc +380 -0
  197. package/third_party/s2geometry/src/s2/s2crossing_edge_query.h +220 -0
  198. package/third_party/s2geometry/src/s2/s2crossing_edge_query_test.cc +382 -0
  199. package/third_party/s2geometry/src/s2/s2debug.cc +23 -0
  200. package/third_party/s2geometry/src/s2/s2debug.h +69 -0
  201. package/third_party/s2geometry/src/s2/s2distance_target.h +165 -0
  202. package/third_party/s2geometry/src/s2/s2earth.cc +52 -0
  203. package/third_party/s2geometry/src/s2/s2earth.h +268 -0
  204. package/third_party/s2geometry/src/s2/s2earth_test.cc +146 -0
  205. package/third_party/s2geometry/src/s2/s2edge_clipping.cc +462 -0
  206. package/third_party/s2geometry/src/s2/s2edge_clipping.h +183 -0
  207. package/third_party/s2geometry/src/s2/s2edge_clipping_test.cc +335 -0
  208. package/third_party/s2geometry/src/s2/s2edge_crosser.cc +85 -0
  209. package/third_party/s2geometry/src/s2/s2edge_crosser.h +343 -0
  210. package/third_party/s2geometry/src/s2/s2edge_crosser_test.cc +264 -0
  211. package/third_party/s2geometry/src/s2/s2edge_crossings.cc +515 -0
  212. package/third_party/s2geometry/src/s2/s2edge_crossings.h +138 -0
  213. package/third_party/s2geometry/src/s2/s2edge_crossings_internal.h +59 -0
  214. package/third_party/s2geometry/src/s2/s2edge_crossings_test.cc +246 -0
  215. package/third_party/s2geometry/src/s2/s2edge_distances.cc +419 -0
  216. package/third_party/s2geometry/src/s2/s2edge_distances.h +192 -0
  217. package/third_party/s2geometry/src/s2/s2edge_distances_test.cc +539 -0
  218. package/third_party/s2geometry/src/s2/s2edge_tessellator.cc +276 -0
  219. package/third_party/s2geometry/src/s2/s2edge_tessellator.h +101 -0
  220. package/third_party/s2geometry/src/s2/s2edge_tessellator_test.cc +492 -0
  221. package/third_party/s2geometry/src/s2/s2edge_vector_shape.h +85 -0
  222. package/third_party/s2geometry/src/s2/s2edge_vector_shape_test.cc +66 -0
  223. package/third_party/s2geometry/src/s2/s2error.cc +29 -0
  224. package/third_party/s2geometry/src/s2/s2error.h +147 -0
  225. package/third_party/s2geometry/src/s2/s2error_test.cc +31 -0
  226. package/third_party/s2geometry/src/s2/s2furthest_edge_query.cc +117 -0
  227. package/third_party/s2geometry/src/s2/s2furthest_edge_query.h +439 -0
  228. package/third_party/s2geometry/src/s2/s2furthest_edge_query_test.cc +487 -0
  229. package/third_party/s2geometry/src/s2/s2latlng.cc +90 -0
  230. package/third_party/s2geometry/src/s2/s2latlng.h +234 -0
  231. package/third_party/s2geometry/src/s2/s2latlng_rect.cc +727 -0
  232. package/third_party/s2geometry/src/s2/s2latlng_rect.h +434 -0
  233. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.cc +344 -0
  234. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.h +89 -0
  235. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder_test.cc +306 -0
  236. package/third_party/s2geometry/src/s2/s2latlng_rect_test.cc +1030 -0
  237. package/third_party/s2geometry/src/s2/s2latlng_test.cc +165 -0
  238. package/third_party/s2geometry/src/s2/s2lax_loop_shape.cc +104 -0
  239. package/third_party/s2geometry/src/s2/s2lax_loop_shape.h +153 -0
  240. package/third_party/s2geometry/src/s2/s2lax_loop_shape_test.cc +101 -0
  241. package/third_party/s2geometry/src/s2/s2lax_polygon_shape.cc +348 -0
  242. package/third_party/s2geometry/src/s2/s2lax_polygon_shape.h +183 -0
  243. package/third_party/s2geometry/src/s2/s2lax_polygon_shape_test.cc +234 -0
  244. package/third_party/s2geometry/src/s2/s2lax_polyline_shape.cc +118 -0
  245. package/third_party/s2geometry/src/s2/s2lax_polyline_shape.h +124 -0
  246. package/third_party/s2geometry/src/s2/s2lax_polyline_shape_test.cc +62 -0
  247. package/third_party/s2geometry/src/s2/s2loop.cc +1509 -0
  248. package/third_party/s2geometry/src/s2/s2loop.h +711 -0
  249. package/third_party/s2geometry/src/s2/s2loop_measures.cc +313 -0
  250. package/third_party/s2geometry/src/s2/s2loop_measures.h +280 -0
  251. package/third_party/s2geometry/src/s2/s2loop_measures_test.cc +367 -0
  252. package/third_party/s2geometry/src/s2/s2loop_test.cc +1371 -0
  253. package/third_party/s2geometry/src/s2/s2max_distance_targets.cc +265 -0
  254. package/third_party/s2geometry/src/s2/s2max_distance_targets.h +241 -0
  255. package/third_party/s2geometry/src/s2/s2max_distance_targets_test.cc +367 -0
  256. package/third_party/s2geometry/src/s2/s2measures.cc +128 -0
  257. package/third_party/s2geometry/src/s2/s2measures.h +78 -0
  258. package/third_party/s2geometry/src/s2/s2measures_test.cc +135 -0
  259. package/third_party/s2geometry/src/s2/s2metrics.cc +122 -0
  260. package/third_party/s2geometry/src/s2/s2metrics.h +199 -0
  261. package/third_party/s2geometry/src/s2/s2metrics_test.cc +127 -0
  262. package/third_party/s2geometry/src/s2/s2min_distance_targets.cc +295 -0
  263. package/third_party/s2geometry/src/s2/s2min_distance_targets.h +273 -0
  264. package/third_party/s2geometry/src/s2/s2min_distance_targets_test.cc +239 -0
  265. package/third_party/s2geometry/src/s2/s2padded_cell.cc +162 -0
  266. package/third_party/s2geometry/src/s2/s2padded_cell.h +108 -0
  267. package/third_party/s2geometry/src/s2/s2padded_cell_test.cc +138 -0
  268. package/third_party/s2geometry/src/s2/s2point.h +38 -0
  269. package/third_party/s2geometry/src/s2/s2point_compression.cc +388 -0
  270. package/third_party/s2geometry/src/s2/s2point_compression.h +78 -0
  271. package/third_party/s2geometry/src/s2/s2point_compression_test.cc +305 -0
  272. package/third_party/s2geometry/src/s2/s2point_index.h +345 -0
  273. package/third_party/s2geometry/src/s2/s2point_index_test.cc +147 -0
  274. package/third_party/s2geometry/src/s2/s2point_region.cc +72 -0
  275. package/third_party/s2geometry/src/s2/s2point_region.h +76 -0
  276. package/third_party/s2geometry/src/s2/s2point_region_test.cc +100 -0
  277. package/third_party/s2geometry/src/s2/s2point_span.h +57 -0
  278. package/third_party/s2geometry/src/s2/s2point_test.cc +47 -0
  279. package/third_party/s2geometry/src/s2/s2point_vector_shape.h +127 -0
  280. package/third_party/s2geometry/src/s2/s2point_vector_shape_test.cc +59 -0
  281. package/third_party/s2geometry/src/s2/s2pointutil.cc +131 -0
  282. package/third_party/s2geometry/src/s2/s2pointutil.h +138 -0
  283. package/third_party/s2geometry/src/s2/s2pointutil_test.cc +157 -0
  284. package/third_party/s2geometry/src/s2/s2polygon.cc +1569 -0
  285. package/third_party/s2geometry/src/s2/s2polygon.h +934 -0
  286. package/third_party/s2geometry/src/s2/s2polygon_test.cc +3025 -0
  287. package/third_party/s2geometry/src/s2/s2polyline.cc +645 -0
  288. package/third_party/s2geometry/src/s2/s2polyline.h +379 -0
  289. package/third_party/s2geometry/src/s2/s2polyline_alignment.cc +414 -0
  290. package/third_party/s2geometry/src/s2/s2polyline_alignment.h +245 -0
  291. package/third_party/s2geometry/src/s2/s2polyline_alignment_internal.h +158 -0
  292. package/third_party/s2geometry/src/s2/s2polyline_alignment_test.cc +610 -0
  293. package/third_party/s2geometry/src/s2/s2polyline_measures.cc +42 -0
  294. package/third_party/s2geometry/src/s2/s2polyline_measures.h +53 -0
  295. package/third_party/s2geometry/src/s2/s2polyline_measures_test.cc +57 -0
  296. package/third_party/s2geometry/src/s2/s2polyline_simplifier.cc +187 -0
  297. package/third_party/s2geometry/src/s2/s2polyline_simplifier.h +109 -0
  298. package/third_party/s2geometry/src/s2/s2polyline_simplifier_test.cc +165 -0
  299. package/third_party/s2geometry/src/s2/s2polyline_test.cc +554 -0
  300. package/third_party/s2geometry/src/s2/s2predicates.cc +1486 -0
  301. package/third_party/s2geometry/src/s2/s2predicates.h +282 -0
  302. package/third_party/s2geometry/src/s2/s2predicates_internal.h +135 -0
  303. package/third_party/s2geometry/src/s2/s2predicates_test.cc +1427 -0
  304. package/third_party/s2geometry/src/s2/s2projections.cc +109 -0
  305. package/third_party/s2geometry/src/s2/s2projections.h +161 -0
  306. package/third_party/s2geometry/src/s2/s2projections_test.cc +78 -0
  307. package/third_party/s2geometry/src/s2/s2r2rect.cc +88 -0
  308. package/third_party/s2geometry/src/s2/s2r2rect.h +292 -0
  309. package/third_party/s2geometry/src/s2/s2r2rect_test.cc +312 -0
  310. package/third_party/s2geometry/src/s2/s2region.cc +26 -0
  311. package/third_party/s2geometry/src/s2/s2region.h +142 -0
  312. package/third_party/s2geometry/src/s2/s2region_coverer.cc +514 -0
  313. package/third_party/s2geometry/src/s2/s2region_coverer.h +356 -0
  314. package/third_party/s2geometry/src/s2/s2region_coverer_test.cc +509 -0
  315. package/third_party/s2geometry/src/s2/s2region_intersection.cc +84 -0
  316. package/third_party/s2geometry/src/s2/s2region_intersection.h +79 -0
  317. package/third_party/s2geometry/src/s2/s2region_term_indexer.cc +270 -0
  318. package/third_party/s2geometry/src/s2/s2region_term_indexer.h +299 -0
  319. package/third_party/s2geometry/src/s2/s2region_term_indexer_test.cc +209 -0
  320. package/third_party/s2geometry/src/s2/s2region_test.cc +370 -0
  321. package/third_party/s2geometry/src/s2/s2region_union.cc +90 -0
  322. package/third_party/s2geometry/src/s2/s2region_union.h +83 -0
  323. package/third_party/s2geometry/src/s2/s2region_union_test.cc +89 -0
  324. package/third_party/s2geometry/src/s2/s2shape.h +283 -0
  325. package/third_party/s2geometry/src/s2/s2shape_index.cc +321 -0
  326. package/third_party/s2geometry/src/s2/s2shape_index.h +781 -0
  327. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.cc +113 -0
  328. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.h +135 -0
  329. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region_test.cc +162 -0
  330. package/third_party/s2geometry/src/s2/s2shape_index_measures.cc +92 -0
  331. package/third_party/s2geometry/src/s2/s2shape_index_measures.h +100 -0
  332. package/third_party/s2geometry/src/s2/s2shape_index_measures_test.cc +136 -0
  333. package/third_party/s2geometry/src/s2/s2shape_index_region.h +350 -0
  334. package/third_party/s2geometry/src/s2/s2shape_index_region_test.cc +161 -0
  335. package/third_party/s2geometry/src/s2/s2shape_index_test.cc +24 -0
  336. package/third_party/s2geometry/src/s2/s2shape_measures.cc +138 -0
  337. package/third_party/s2geometry/src/s2/s2shape_measures.h +95 -0
  338. package/third_party/s2geometry/src/s2/s2shape_measures_test.cc +139 -0
  339. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.cc +120 -0
  340. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.h +66 -0
  341. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries_test.cc +170 -0
  342. package/third_party/s2geometry/src/s2/s2shapeutil_coding.cc +253 -0
  343. package/third_party/s2geometry/src/s2/s2shapeutil_coding.h +283 -0
  344. package/third_party/s2geometry/src/s2/s2shapeutil_coding_test.cc +54 -0
  345. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.cc +40 -0
  346. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.h +41 -0
  347. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force_test.cc +55 -0
  348. package/third_party/s2geometry/src/s2/s2shapeutil_count_edges.h +57 -0
  349. package/third_party/s2geometry/src/s2/s2shapeutil_count_edges_test.cc +43 -0
  350. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.cc +45 -0
  351. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.h +72 -0
  352. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator_test.cc +116 -0
  353. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.cc +107 -0
  354. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.h +48 -0
  355. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point_test.cc +104 -0
  356. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.cc +58 -0
  357. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.h +65 -0
  358. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator_test.cc +61 -0
  359. package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge.h +58 -0
  360. package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge_id.h +97 -0
  361. package/third_party/s2geometry/src/s2/s2shapeutil_testing.cc +104 -0
  362. package/third_party/s2geometry/src/s2/s2shapeutil_testing.h +36 -0
  363. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.cc +440 -0
  364. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.h +72 -0
  365. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs_test.cc +184 -0
  366. package/third_party/s2geometry/src/s2/s2testing.cc +464 -0
  367. package/third_party/s2geometry/src/s2/s2testing.h +385 -0
  368. package/third_party/s2geometry/src/s2/s2testing_test.cc +166 -0
  369. package/third_party/s2geometry/src/s2/s2text_format.cc +506 -0
  370. package/third_party/s2geometry/src/s2/s2text_format.h +289 -0
  371. package/third_party/s2geometry/src/s2/s2text_format_test.cc +417 -0
  372. package/third_party/s2geometry/src/s2/s2wedge_relations.cc +80 -0
  373. package/third_party/s2geometry/src/s2/s2wedge_relations.h +64 -0
  374. package/third_party/s2geometry/src/s2/s2wedge_relations_test.cc +89 -0
  375. package/third_party/s2geometry/src/s2/sequence_lexicon.h +296 -0
  376. package/third_party/s2geometry/src/s2/sequence_lexicon_test.cc +113 -0
  377. package/third_party/s2geometry/src/s2/strings/ostringstream.cc +35 -0
  378. package/third_party/s2geometry/src/s2/strings/ostringstream.h +105 -0
  379. package/third_party/s2geometry/src/s2/strings/serialize.cc +46 -0
  380. package/third_party/s2geometry/src/s2/strings/serialize.h +40 -0
  381. package/third_party/s2geometry/src/s2/third_party/absl/algorithm/algorithm.h +187 -0
  382. package/third_party/s2geometry/src/s2/third_party/absl/base/attributes.h +666 -0
  383. package/third_party/s2geometry/src/s2/third_party/absl/base/casts.h +189 -0
  384. package/third_party/s2geometry/src/s2/third_party/absl/base/config.h +462 -0
  385. package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.cc +129 -0
  386. package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.h +394 -0
  387. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/atomic_hook.h +168 -0
  388. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/identity.h +33 -0
  389. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/inline_variable.h +117 -0
  390. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/invoke.h +188 -0
  391. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.cc +254 -0
  392. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.h +205 -0
  393. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.cc +106 -0
  394. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.h +71 -0
  395. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/unaligned_access.h +322 -0
  396. package/third_party/s2geometry/src/s2/third_party/absl/base/log_severity.h +77 -0
  397. package/third_party/s2geometry/src/s2/third_party/absl/base/macros.h +236 -0
  398. package/third_party/s2geometry/src/s2/third_party/absl/base/optimization.h +177 -0
  399. package/third_party/s2geometry/src/s2/third_party/absl/base/policy_checks.h +124 -0
  400. package/third_party/s2geometry/src/s2/third_party/absl/base/port.h +97 -0
  401. package/third_party/s2geometry/src/s2/third_party/absl/base/thread_annotations.h +277 -0
  402. package/third_party/s2geometry/src/s2/third_party/absl/container/fixed_array.h +523 -0
  403. package/third_party/s2geometry/src/s2/third_party/absl/container/inlined_vector.h +1453 -0
  404. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/compressed_tuple.h +191 -0
  405. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/container_memory.h +424 -0
  406. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/layout.h +739 -0
  407. package/third_party/s2geometry/src/s2/third_party/absl/memory/memory.h +755 -0
  408. package/third_party/s2geometry/src/s2/third_party/absl/meta/type_traits.h +436 -0
  409. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.cc +232 -0
  410. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.h +656 -0
  411. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_have_intrinsic.inc +3 -0
  412. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_no_intrinsic.inc +3 -0
  413. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.cc +198 -0
  414. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.h +239 -0
  415. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii_ctype.h +66 -0
  416. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/bits.h +53 -0
  417. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.cc +110 -0
  418. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.h +146 -0
  419. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/resize_uninitialized.h +72 -0
  420. package/third_party/s2geometry/src/s2/third_party/absl/strings/match.cc +38 -0
  421. package/third_party/s2geometry/src/s2/third_party/absl/strings/match.h +89 -0
  422. package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.cc +909 -0
  423. package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.h +187 -0
  424. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.cc +240 -0
  425. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.h +398 -0
  426. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_join.h +22 -0
  427. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.cc +47 -0
  428. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.h +43 -0
  429. package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.cc +245 -0
  430. package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.h +602 -0
  431. package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.cc +42 -0
  432. package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.h +130 -0
  433. package/third_party/s2geometry/src/s2/third_party/absl/types/span.h +793 -0
  434. package/third_party/s2geometry/src/s2/third_party/absl/utility/utility.h +299 -0
  435. package/third_party/s2geometry/src/s2/util/bits/bit-interleave.cc +274 -0
  436. package/third_party/s2geometry/src/s2/util/bits/bit-interleave.h +53 -0
  437. package/third_party/s2geometry/src/s2/util/bits/bits.cc +155 -0
  438. package/third_party/s2geometry/src/s2/util/bits/bits.h +745 -0
  439. package/third_party/s2geometry/src/s2/util/coding/coder.cc +83 -0
  440. package/third_party/s2geometry/src/s2/util/coding/coder.h +553 -0
  441. package/third_party/s2geometry/src/s2/util/coding/nth-derivative.h +134 -0
  442. package/third_party/s2geometry/src/s2/util/coding/transforms.h +62 -0
  443. package/third_party/s2geometry/src/s2/util/coding/varint.cc +289 -0
  444. package/third_party/s2geometry/src/s2/util/coding/varint.h +476 -0
  445. package/third_party/s2geometry/src/s2/util/endian/endian.h +859 -0
  446. package/third_party/s2geometry/src/s2/util/gtl/btree.h +2471 -0
  447. package/third_party/s2geometry/src/s2/util/gtl/btree_container.h +411 -0
  448. package/third_party/s2geometry/src/s2/util/gtl/btree_map.h +79 -0
  449. package/third_party/s2geometry/src/s2/util/gtl/btree_set.h +73 -0
  450. package/third_party/s2geometry/src/s2/util/gtl/compact_array.h +653 -0
  451. package/third_party/s2geometry/src/s2/util/gtl/container_logging.h +291 -0
  452. package/third_party/s2geometry/src/s2/util/gtl/dense_hash_set.h +358 -0
  453. package/third_party/s2geometry/src/s2/util/gtl/densehashtable.h +1493 -0
  454. package/third_party/s2geometry/src/s2/util/gtl/hashtable_common.h +253 -0
  455. package/third_party/s2geometry/src/s2/util/gtl/layout.h +28 -0
  456. package/third_party/s2geometry/src/s2/util/gtl/legacy_random_shuffle.h +77 -0
  457. package/third_party/s2geometry/src/s2/util/hash/mix.h +76 -0
  458. package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.cc +832 -0
  459. package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.h +646 -0
  460. package/third_party/s2geometry/src/s2/util/math/mathutil.cc +75 -0
  461. package/third_party/s2geometry/src/s2/util/math/mathutil.h +189 -0
  462. package/third_party/s2geometry/src/s2/util/math/matrix3x3.h +574 -0
  463. package/third_party/s2geometry/src/s2/util/math/vector.h +569 -0
  464. package/third_party/s2geometry/src/s2/util/math/vector3_hash.h +54 -0
  465. package/third_party/s2geometry/src/s2/util/units/length-units.cc +21 -0
  466. package/third_party/s2geometry/src/s2/util/units/length-units.h +135 -0
  467. package/third_party/s2geometry/src/s2/util/units/physical-units.h +313 -0
  468. package/third_party/s2geometry/src/s2/value_lexicon.h +234 -0
  469. package/third_party/s2geometry/src/s2/value_lexicon_test.cc +121 -0
  470. package/third_party/s2geometry/third_party/cmake/FindGFlags.cmake +48 -0
  471. package/third_party/s2geometry/third_party/cmake/FindGlog.cmake +48 -0
@@ -0,0 +1,711 @@
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
+ #ifndef S2_S2LOOP_H_
19
+ #define S2_S2LOOP_H_
20
+
21
+ #include <atomic>
22
+ #include <bitset>
23
+ #include <cmath>
24
+ #include <cstddef>
25
+ #include <map>
26
+ #include <vector>
27
+
28
+ #include "s2/base/integral_types.h"
29
+ #include "s2/base/logging.h"
30
+ #include "s2/_fp_contract_off.h"
31
+ #include "s2/mutable_s2shape_index.h"
32
+ #include "s2/s1angle.h"
33
+ #include "s2/s1chord_angle.h"
34
+ #include "s2/s2debug.h"
35
+ #include "s2/s2latlng_rect.h"
36
+ #include "s2/s2loop_measures.h"
37
+ #include "s2/s2pointutil.h"
38
+ #include "s2/s2region.h"
39
+ #include "s2/s2shape_index.h"
40
+ #include "s2/third_party/absl/base/macros.h"
41
+ #include "s2/util/math/matrix3x3.h"
42
+ #include "s2/util/math/vector.h"
43
+
44
+ class Decoder;
45
+ class Encoder;
46
+ class LoopCrosser;
47
+ class LoopRelation;
48
+ class MergingIterator;
49
+ class S2Cap;
50
+ class S2Cell;
51
+ class S2CrossingEdgeQuery;
52
+ class S2Error;
53
+ class S2Loop;
54
+ struct S2XYZFaceSiTi;
55
+ namespace s2builderutil { class S2PolygonLayer; }
56
+
57
+ // An S2Loop represents a simple spherical polygon. It consists of a single
58
+ // chain of vertices where the first vertex is implicitly connected to the
59
+ // last. All loops are defined to have a CCW orientation, i.e. the interior of
60
+ // the loop is on the left side of the edges. This implies that a clockwise
61
+ // loop enclosing a small area is interpreted to be a CCW loop enclosing a
62
+ // very large area.
63
+ //
64
+ // Loops are not allowed to have any duplicate vertices (whether adjacent or
65
+ // not). Non-adjacent edges are not allowed to intersect, and furthermore edges
66
+ // of length 180 degrees are not allowed (i.e., adjacent vertices cannot be
67
+ // antipodal). Loops must have at least 3 vertices (except for the empty and
68
+ // full loops discussed below). Although these restrictions are not enforced
69
+ // in optimized code, you may get unexpected results if they are violated.
70
+ //
71
+ // There are two special loops: the "empty loop" contains no points, while the
72
+ // "full loop" contains all points. These loops do not have any edges, but to
73
+ // preserve the invariant that every loop can be represented as a vertex
74
+ // chain, they are defined as having exactly one vertex each (see kEmpty and
75
+ // kFull).
76
+ //
77
+ // Point containment of loops is defined such that if the sphere is subdivided
78
+ // into faces (loops), every point is contained by exactly one face. This
79
+ // implies that loops do not necessarily contain their vertices.
80
+ //
81
+ // Note: The reason that duplicate vertices and intersecting edges are not
82
+ // allowed is that they make it harder to define and implement loop
83
+ // relationships, e.g. whether one loop contains another. If your data does
84
+ // not satisfy these restrictions, you can use S2Builder to normalize it.
85
+ class S2Loop final : public S2Region {
86
+ public:
87
+ // Default constructor. The loop must be initialized by calling Init() or
88
+ // Decode() before it is used.
89
+ S2Loop();
90
+
91
+ // Convenience constructor that calls Init() with the given vertices.
92
+ explicit S2Loop(const std::vector<S2Point>& vertices);
93
+
94
+ // Convenience constructor to disable the automatic validity checking
95
+ // controlled by the --s2debug flag. Example:
96
+ //
97
+ // S2Loop* loop = new S2Loop(vertices, S2Debug::DISABLE);
98
+ //
99
+ // This is equivalent to:
100
+ //
101
+ // S2Loop* loop = new S2Loop;
102
+ // loop->set_s2debug_override(S2Debug::DISABLE);
103
+ // loop->Init(vertices);
104
+ //
105
+ // The main reason to use this constructor is if you intend to call
106
+ // IsValid() explicitly. See set_s2debug_override() for details.
107
+ S2Loop(const std::vector<S2Point>& vertices, S2Debug override);
108
+
109
+ // Initialize a loop with given vertices. The last vertex is implicitly
110
+ // connected to the first. All points should be unit length. Loops must
111
+ // have at least 3 vertices (except for the empty and full loops, see
112
+ // kEmpty and kFull). This method may be called multiple times.
113
+ void Init(const std::vector<S2Point>& vertices);
114
+
115
+ // A special vertex chain of length 1 that creates an empty loop (i.e., a
116
+ // loop with no edges that contains no points). Example usage:
117
+ //
118
+ // S2Loop empty(S2Loop::kEmpty());
119
+ //
120
+ // The loop may be safely encoded lossily (e.g. by snapping it to an S2Cell
121
+ // center) as long as its position does not move by 90 degrees or more.
122
+ static std::vector<S2Point> kEmpty();
123
+
124
+ // A special vertex chain of length 1 that creates a full loop (i.e., a loop
125
+ // with no edges that contains all points). See kEmpty() for details.
126
+ static std::vector<S2Point> kFull();
127
+
128
+ // Construct a loop corresponding to the given cell.
129
+ //
130
+ // Note that the loop and cell *do not* contain exactly the same set of
131
+ // points, because S2Loop and S2Cell have slightly different definitions of
132
+ // point containment. For example, an S2Cell vertex is contained by all
133
+ // four neighboring S2Cells, but it is contained by exactly one of four
134
+ // S2Loops constructed from those cells. As another example, the S2Cell
135
+ // coverings of "cell" and "S2Loop(cell)" will be different, because the
136
+ // loop contains points on its boundary that actually belong to other cells
137
+ // (i.e., the covering will include a layer of neighboring cells).
138
+ explicit S2Loop(const S2Cell& cell);
139
+
140
+ ~S2Loop() override;
141
+
142
+ // Allows overriding the automatic validity checks controlled by the
143
+ // --s2debug flag. If this flag is true, then loops are automatically
144
+ // checked for validity as they are initialized. The main reason to disable
145
+ // this flag is if you intend to call IsValid() explicitly, like this:
146
+ //
147
+ // S2Loop loop;
148
+ // loop.set_s2debug_override(S2Debug::DISABLE);
149
+ // loop.Init(...);
150
+ // if (!loop.IsValid()) { ... }
151
+ //
152
+ // Without the call to set_s2debug_override(), invalid data would cause a
153
+ // fatal error in Init() whenever the --s2debug flag is enabled.
154
+ //
155
+ // This setting is preserved across calls to Init() and Decode().
156
+ void set_s2debug_override(S2Debug override);
157
+ S2Debug s2debug_override() const;
158
+
159
+ // Returns true if this is a valid loop. Note that validity is checked
160
+ // automatically during initialization when --s2debug is enabled (true by
161
+ // default in debug binaries).
162
+ bool IsValid() const;
163
+
164
+ // Returns true if this is *not* a valid loop and sets "error"
165
+ // appropriately. Otherwise returns false and leaves "error" unchanged.
166
+ //
167
+ // REQUIRES: error != nullptr
168
+ bool FindValidationError(S2Error* error) const;
169
+
170
+ int num_vertices() const { return num_vertices_; }
171
+
172
+ // For convenience, we make two entire copies of the vertex list available:
173
+ // vertex(n..2*n-1) is mapped to vertex(0..n-1), where n == num_vertices().
174
+ //
175
+ // REQUIRES: 0 <= i < 2 * num_vertices()
176
+ const S2Point& vertex(int i) const {
177
+ S2_DCHECK_GE(i, 0);
178
+ S2_DCHECK_LT(i, 2 * num_vertices());
179
+ int j = i - num_vertices();
180
+ return vertices_[j < 0 ? i : j];
181
+ }
182
+
183
+ // Like vertex(), but this method returns vertices in reverse order if the
184
+ // loop represents a polygon hole. For example, arguments 0, 1, 2 are
185
+ // mapped to vertices n-1, n-2, n-3, where n == num_vertices(). This
186
+ // ensures that the interior of the polygon is always to the left of the
187
+ // vertex chain.
188
+ //
189
+ // REQUIRES: 0 <= i < 2 * num_vertices()
190
+ const S2Point& oriented_vertex(int i) const {
191
+ S2_DCHECK_GE(i, 0);
192
+ S2_DCHECK_LT(i, 2 * num_vertices());
193
+ int j = i - num_vertices();
194
+ if (j < 0) j = i;
195
+ if (is_hole()) j = num_vertices() - 1 - j;
196
+ return vertices_[j];
197
+ }
198
+
199
+ // Returns true if this is the special empty loop that contains no points.
200
+ bool is_empty() const;
201
+
202
+ // Returns true if this is the special full loop that contains all points.
203
+ bool is_full() const;
204
+
205
+ // Returns true if this loop is either empty or full.
206
+ bool is_empty_or_full() const;
207
+
208
+ // The depth of a loop is defined as its nesting level within its containing
209
+ // polygon. "Outer shell" loops have depth 0, holes within those loops have
210
+ // depth 1, shells within those holes have depth 2, etc. This field is only
211
+ // used by the S2Polygon implementation.
212
+ int depth() const { return depth_; }
213
+ void set_depth(int depth) { depth_ = depth; }
214
+
215
+ // Returns true if this loop represents a hole in its containing polygon.
216
+ bool is_hole() const { return (depth_ & 1) != 0; }
217
+
218
+ // The sign of a loop is -1 if the loop represents a hole in its containing
219
+ // polygon, and +1 otherwise.
220
+ int sign() const { return is_hole() ? -1 : 1; }
221
+
222
+ // Returns true if the loop area is at most 2*Pi. Degenerate loops are
223
+ // handled consistently with s2pred::Sign(), i.e., if a loop can be
224
+ // expressed as the union of degenerate or nearly-degenerate CCW triangles,
225
+ // then it will always be considered normalized.
226
+ bool IsNormalized() const;
227
+
228
+ // Invert the loop if necessary so that the area enclosed by the loop is at
229
+ // most 2*Pi.
230
+ void Normalize();
231
+
232
+ // Reverse the order of the loop vertices, effectively complementing the
233
+ // region represented by the loop. For example, the loop ABCD (with edges
234
+ // AB, BC, CD, DA) becomes the loop DCBA (with edges DC, CB, BA, AD).
235
+ // Notice that the last edge is the same in both cases except that its
236
+ // direction has been reversed.
237
+ void Invert();
238
+
239
+ // Returns the area of the loop interior, i.e. the region on the left side of
240
+ // the loop. The return value is between 0 and 4*Pi. (Note that the return
241
+ // value is not affected by whether this loop is a "hole" or a "shell".)
242
+ double GetArea() const;
243
+
244
+ // Returns the true centroid of the loop multiplied by the area of the loop
245
+ // (see s2centroids.h for details on centroids). The result is not unit
246
+ // length, so you may want to normalize it. Also note that in general, the
247
+ // centroid may not be contained by the loop.
248
+ //
249
+ // We prescale by the loop area for two reasons: (1) it is cheaper to
250
+ // compute this way, and (2) it makes it easier to compute the centroid of
251
+ // more complicated shapes (by splitting them into disjoint regions and
252
+ // adding their centroids).
253
+ //
254
+ // Note that the return value is not affected by whether this loop is a
255
+ // "hole" or a "shell".
256
+ S2Point GetCentroid() const;
257
+
258
+ // Returns the geodesic curvature of the loop, defined as the sum of the turn
259
+ // angles at each vertex (see S2::TurnAngle). The result is positive if the
260
+ // loop is counter-clockwise, negative if the loop is clockwise, and zero if
261
+ // the loop is a great circle. The geodesic curvature is equal to 2*Pi minus
262
+ // the area of the loop.
263
+ //
264
+ // Degenerate and nearly-degenerate loops are handled consistently with
265
+ // s2pred::Sign(). So for example, if a loop has zero area (i.e., it is a
266
+ // very small CCW loop) then its geodesic curvature will always be positive.
267
+ double GetCurvature() const;
268
+
269
+ // Returns the maximum error in GetCurvature(). The return value is not
270
+ // constant; it depends on the loop.
271
+ double GetCurvatureMaxError() const;
272
+
273
+ // Returns the distance from the given point to the loop interior. If the
274
+ // loop is empty, return S1Angle::Infinity(). "x" should be unit length.
275
+ S1Angle GetDistance(const S2Point& x) const;
276
+
277
+ // Returns the distance from the given point to the loop boundary. If the
278
+ // loop is empty or full, return S1Angle::Infinity() (since the loop has no
279
+ // boundary). "x" should be unit length.
280
+ S1Angle GetDistanceToBoundary(const S2Point& x) const;
281
+
282
+ // If the given point is contained by the loop, return it. Otherwise return
283
+ // the closest point on the loop boundary. If the loop is empty, return the
284
+ // input argument. Note that the result may or may not be contained by the
285
+ // loop. "x" should be unit length.
286
+ S2Point Project(const S2Point& x) const;
287
+
288
+ // Returns the closest point on the loop boundary to the given point. If the
289
+ // loop is empty or full, return the input argument (since the loop has no
290
+ // boundary). "x" should be unit length.
291
+ S2Point ProjectToBoundary(const S2Point& x) const;
292
+
293
+ // Returns true if the region contained by this loop is a superset of the
294
+ // region contained by the given other loop.
295
+ bool Contains(const S2Loop* b) const;
296
+
297
+ // Returns true if the region contained by this loop intersects the region
298
+ // contained by the given other loop.
299
+ bool Intersects(const S2Loop* b) const;
300
+
301
+ // Returns true if two loops have the same vertices in the same linear order
302
+ // (i.e., cyclic rotations are not allowed).
303
+ bool Equals(const S2Loop* b) const;
304
+
305
+ // Returns true if two loops have the same boundary. This is true if and
306
+ // only if the loops have the same vertices in the same cyclic order (i.e.,
307
+ // the vertices may be cyclically rotated). The empty and full loops are
308
+ // considered to have different boundaries.
309
+ bool BoundaryEquals(const S2Loop* b) const;
310
+
311
+ // Returns true if two loops have the same boundary except for vertex
312
+ // perturbations. More precisely, the vertices in the two loops must be in
313
+ // the same cyclic order, and corresponding vertex pairs must be separated
314
+ // by no more than "max_error".
315
+ bool BoundaryApproxEquals(const S2Loop& b,
316
+ S1Angle max_error = S1Angle::Radians(1e-15)) const;
317
+
318
+ // Returns true if the two loop boundaries are within "max_error" of each
319
+ // other along their entire lengths. The two loops may have different
320
+ // numbers of vertices. More precisely, this method returns true if the two
321
+ // loops have parameterizations a:[0,1] -> S^2, b:[0,1] -> S^2 such that
322
+ // distance(a(t), b(t)) <= max_error for all t. You can think of this as
323
+ // testing whether it is possible to drive two cars all the way around the
324
+ // two loops such that no car ever goes backward and the cars are always
325
+ // within "max_error" of each other.
326
+ bool BoundaryNear(const S2Loop& b,
327
+ S1Angle max_error = S1Angle::Radians(1e-15)) const;
328
+
329
+ // This method computes the oriented surface integral of some quantity f(x)
330
+ // over the loop interior, given a function f_tri(A,B,C) that returns the
331
+ // corresponding integral over the spherical triangle ABC. Here "oriented
332
+ // surface integral" means:
333
+ //
334
+ // (1) f_tri(A,B,C) must be the integral of f if ABC is counterclockwise,
335
+ // and the integral of -f if ABC is clockwise.
336
+ //
337
+ // (2) The result of this function is *either* the integral of f over the
338
+ // loop interior, or the integral of (-f) over the loop exterior.
339
+ //
340
+ // Note that there are at least two common situations where it easy to work
341
+ // around property (2) above:
342
+ //
343
+ // - If the integral of f over the entire sphere is zero, then it doesn't
344
+ // matter which case is returned because they are always equal.
345
+ //
346
+ // - If f is non-negative, then it is easy to detect when the integral over
347
+ // the loop exterior has been returned, and the integral over the loop
348
+ // interior can be obtained by adding the integral of f over the entire
349
+ // unit sphere (a constant) to the result.
350
+ //
351
+ // Also requires that the default constructor for T must initialize the
352
+ // value to zero. (This is true for built-in types such as "double".)
353
+ template <class T>
354
+ T GetSurfaceIntegral(T f_tri(const S2Point&, const S2Point&, const S2Point&))
355
+ const;
356
+
357
+ // Constructs a regular polygon with the given number of vertices, all
358
+ // located on a circle of the specified radius around "center". The radius
359
+ // is the actual distance from "center" to each vertex.
360
+ static std::unique_ptr<S2Loop> MakeRegularLoop(const S2Point& center,
361
+ S1Angle radius,
362
+ int num_vertices);
363
+
364
+ // Like the function above, but this version constructs a loop centered
365
+ // around the z-axis of the given coordinate frame, with the first vertex in
366
+ // the direction of the positive x-axis. (This allows the loop to be
367
+ // rotated for testing purposes.)
368
+ static std::unique_ptr<S2Loop> MakeRegularLoop(const Matrix3x3_d& frame,
369
+ S1Angle radius,
370
+ int num_vertices);
371
+
372
+ // Returnss the total number of bytes used by the loop.
373
+ size_t SpaceUsed() const;
374
+
375
+ ////////////////////////////////////////////////////////////////////////
376
+ // S2Region interface (see s2region.h for details):
377
+
378
+ S2Loop* Clone() const override;
379
+
380
+ // GetRectBound() returns essentially tight results, while GetCapBound()
381
+ // might have a lot of extra padding. Both bounds are conservative in that
382
+ // if the loop contains a point P, then the bound contains P also.
383
+ S2Cap GetCapBound() const override;
384
+ S2LatLngRect GetRectBound() const override { return bound_; }
385
+
386
+ bool Contains(const S2Cell& cell) const override;
387
+ bool MayIntersect(const S2Cell& cell) const override;
388
+
389
+ // The point 'p' does not need to be normalized.
390
+ bool Contains(const S2Point& p) const override;
391
+
392
+ // Appends a serialized representation of the S2Loop to "encoder".
393
+ //
394
+ // Generally clients should not use S2Loop::Encode(). Instead they should
395
+ // encode an S2Polygon, which unlike this method supports (lossless)
396
+ // compression.
397
+ //
398
+ // REQUIRES: "encoder" uses the default constructor, so that its buffer
399
+ // can be enlarged as necessary by calling Ensure(int).
400
+ void Encode(Encoder* const encoder) const;
401
+
402
+ // Decodes a loop encoded with Encode() or the private method
403
+ // EncodeCompressed() (used by the S2Polygon encoder). Returns true on
404
+ // success.
405
+ //
406
+ // This method may be called with loops that have already been initialized.
407
+ bool Decode(Decoder* const decoder);
408
+
409
+ // Provides the same functionality as Decode, except that decoded regions
410
+ // are allowed to point directly into the Decoder's memory buffer rather
411
+ // than copying the data. This can be much faster, but the decoded loop is
412
+ // only valid within the scope (lifetime) of the Decoder's memory buffer.
413
+ bool DecodeWithinScope(Decoder* const decoder);
414
+
415
+ ////////////////////////////////////////////////////////////////////////
416
+ // Methods intended primarily for use by the S2Polygon implementation:
417
+
418
+ // Given two loops of a polygon, return true if A contains B. This version
419
+ // of Contains() is cheap because it does not test for edge intersections.
420
+ // The loops must meet all the S2Polygon requirements; for example this
421
+ // implies that their boundaries may not cross or have any shared edges
422
+ // (although they may have shared vertices).
423
+ bool ContainsNested(const S2Loop* b) const;
424
+
425
+ // Returns +1 if A contains the boundary of B, -1 if A excludes the boundary
426
+ // of B, and 0 if the boundaries of A and B cross. Shared edges are handled
427
+ // as follows: If XY is a shared edge, define Reversed(XY) to be true if XY
428
+ // appears in opposite directions in A and B. Then A contains XY if and
429
+ // only if Reversed(XY) == B->is_hole(). (Intuitively, this checks whether
430
+ // A contains a vanishingly small region extending from the boundary of B
431
+ // toward the interior of the polygon to which loop B belongs.)
432
+ //
433
+ // This method is used for testing containment and intersection of
434
+ // multi-loop polygons. Note that this method is not symmetric, since the
435
+ // result depends on the direction of loop A but not on the direction of
436
+ // loop B (in the absence of shared edges).
437
+ //
438
+ // REQUIRES: neither loop is empty.
439
+ // REQUIRES: if b->is_full(), then !b->is_hole().
440
+ int CompareBoundary(const S2Loop* b) const;
441
+
442
+ // Given two loops whose boundaries do not cross (see CompareBoundary),
443
+ // return true if A contains the boundary of B. If "reverse_b" is true, the
444
+ // boundary of B is reversed first (which only affects the result when there
445
+ // are shared edges). This method is cheaper than CompareBoundary() because
446
+ // it does not test for edge intersections.
447
+ //
448
+ // REQUIRES: neither loop is empty.
449
+ // REQUIRES: if b->is_full(), then reverse_b == false.
450
+ bool ContainsNonCrossingBoundary(const S2Loop* b, bool reverse_b) const;
451
+
452
+ // Wrapper class for indexing a loop (see S2ShapeIndex). Once this object
453
+ // is inserted into an S2ShapeIndex it is owned by that index, and will be
454
+ // automatically deleted when no longer needed by the index. Note that this
455
+ // class does not take ownership of the loop itself (see OwningShape below).
456
+ // You can also subtype this class to store additional data (see S2Shape for
457
+ // details).
458
+ #ifndef SWIG
459
+ class Shape : public S2Shape {
460
+ public:
461
+ Shape() : loop_(nullptr) {} // Must call Init().
462
+
463
+ // Initialize the shape. Does not take ownership of "loop".
464
+ explicit Shape(const S2Loop* loop) { Init(loop); }
465
+ void Init(const S2Loop* loop) { loop_ = loop; }
466
+
467
+ const S2Loop* loop() const { return loop_; }
468
+
469
+ // S2Shape interface:
470
+ int num_edges() const final {
471
+ return loop_->is_empty_or_full() ? 0 : loop_->num_vertices();
472
+ }
473
+ Edge edge(int e) const final {
474
+ return Edge(loop_->vertex(e), loop_->vertex(e + 1));
475
+ }
476
+ int dimension() const final { return 2; }
477
+ ReferencePoint GetReferencePoint() const final {
478
+ return ReferencePoint(S2::Origin(), loop_->contains_origin());
479
+ }
480
+ int num_chains() const final;
481
+ Chain chain(int i) const final;
482
+ Edge chain_edge(int i, int j) const final {
483
+ S2_DCHECK_EQ(i, 0);
484
+ return Edge(loop_->vertex(j), loop_->vertex(j + 1));
485
+ }
486
+ ChainPosition chain_position(int e) const final {
487
+ return ChainPosition(0, e);
488
+ }
489
+
490
+ private:
491
+ const S2Loop* loop_;
492
+ };
493
+
494
+ // Like Shape, except that the S2Loop is automatically deleted when this
495
+ // object is deleted by the S2ShapeIndex. This is useful when an S2Loop
496
+ // is constructed solely for the purpose of indexing it.
497
+ class OwningShape : public Shape {
498
+ public:
499
+ OwningShape() {} // Must call Init().
500
+ explicit OwningShape(std::unique_ptr<const S2Loop> loop)
501
+ : Shape(loop.release()) {
502
+ }
503
+ void Init(std::unique_ptr<const S2Loop> loop) {
504
+ Shape::Init(loop.release());
505
+ }
506
+ ~OwningShape() override { delete loop(); }
507
+ };
508
+ #endif // SWIG
509
+
510
+ private:
511
+ // All of the following need access to contains_origin(). Possibly this
512
+ // method should be public.
513
+ friend class Shape;
514
+ friend class S2Polygon;
515
+ friend class S2Stats;
516
+ friend class S2LoopTestBase;
517
+ friend class LoopCrosser;
518
+ friend class s2builderutil::S2PolygonLayer;
519
+
520
+ // Internal copy constructor used only by Clone() that makes a deep copy of
521
+ // its argument.
522
+ S2Loop(const S2Loop& src);
523
+
524
+ // Returns an S2PointLoopSpan containing the loop vertices, for use with the
525
+ // functions defined in s2loop_measures.h.
526
+ S2PointLoopSpan vertices_span() const {
527
+ return S2PointLoopSpan(vertices_, num_vertices());
528
+ }
529
+
530
+ // Returns true if this loop contains S2::Origin().
531
+ bool contains_origin() const { return origin_inside_; }
532
+
533
+ // The single vertex in the "empty loop" vertex chain.
534
+ static S2Point kEmptyVertex();
535
+
536
+ // The single vertex in the "full loop" vertex chain.
537
+ static S2Point kFullVertex();
538
+
539
+ void InitOriginAndBound();
540
+ void InitBound();
541
+ void InitIndex();
542
+
543
+ // A version of Contains(S2Point) that does not use the S2ShapeIndex.
544
+ // Used by the S2Polygon implementation.
545
+ bool BruteForceContains(const S2Point& p) const;
546
+
547
+ // Like FindValidationError(), but skips any checks that would require
548
+ // building the S2ShapeIndex (i.e., self-intersection tests). This is used
549
+ // by the S2Polygon implementation, which uses its own index to check for
550
+ // loop self-intersections.
551
+ bool FindValidationErrorNoIndex(S2Error* error) const;
552
+
553
+ // Internal implementation of the Decode and DecodeWithinScope methods above.
554
+ // If within_scope is true, memory is allocated for vertices_ and data
555
+ // is copied from the decoder using std::copy. If it is false, vertices_
556
+ // will point to the memory area inside the decoder, and the field
557
+ // owns_vertices_ is set to false.
558
+ bool DecodeInternal(Decoder* const decoder, bool within_scope);
559
+
560
+ // Converts the loop vertices to the S2XYZFaceSiTi format and store the result
561
+ // in the given array, which must be large enough to store all the vertices.
562
+ void GetXYZFaceSiTiVertices(S2XYZFaceSiTi* vertices) const;
563
+
564
+ // Encode the loop's vertices using S2EncodePointsCompressed. Uses
565
+ // approximately 8 bytes for the first vertex, going down to less than 4 bytes
566
+ // per vertex on Google's geographic repository, plus 24 bytes per vertex that
567
+ // does not correspond to the center of a cell at level 'snap_level'. The loop
568
+ // vertices must first be converted to the S2XYZFaceSiTi format with
569
+ // GetXYZFaceSiTiVertices.
570
+ //
571
+ // REQUIRES: the loop is initialized and valid.
572
+ void EncodeCompressed(Encoder* encoder, const S2XYZFaceSiTi* vertices,
573
+ int snap_level) const;
574
+
575
+ // Decode a loop encoded with EncodeCompressed. The parameters must be the
576
+ // same as the one used when EncodeCompressed was called.
577
+ bool DecodeCompressed(Decoder* decoder, int snap_level);
578
+
579
+ // Returns a bitset of properties used by EncodeCompressed
580
+ // to efficiently encode boolean values. Properties are
581
+ // origin_inside and whether the bound was encoded.
582
+ std::bitset<2> GetCompressedEncodingProperties() const;
583
+
584
+ // Given an iterator that is already positioned at the S2ShapeIndexCell
585
+ // containing "p", returns Contains(p).
586
+ bool Contains(const MutableS2ShapeIndex::Iterator& it,
587
+ const S2Point& p) const;
588
+
589
+ // Returns true if the loop boundary intersects "target". It may also
590
+ // return true when the loop boundary does not intersect "target" but
591
+ // some edge comes within the worst-case error tolerance.
592
+ //
593
+ // REQUIRES: it.id().contains(target.id())
594
+ // [This condition is true whenever it.Locate(target) returns INDEXED.]
595
+ bool BoundaryApproxIntersects(const MutableS2ShapeIndex::Iterator& it,
596
+ const S2Cell& target) const;
597
+
598
+ // Returns an index "first" and a direction "dir" such that the vertex
599
+ // sequence (first, first + dir, ..., first + (n - 1) * dir) does not change
600
+ // when the loop vertex order is rotated or reversed. This allows the loop
601
+ // vertices to be traversed in a canonical order.
602
+ S2::LoopOrder GetCanonicalLoopOrder() const;
603
+
604
+ // Returns the index of a vertex at point "p", or -1 if not found.
605
+ // The return value is in the range 1..num_vertices_ if found.
606
+ int FindVertex(const S2Point& p) const;
607
+
608
+ // This method checks all edges of loop A for intersection against all edges
609
+ // of loop B. If there is any shared vertex, the wedges centered at this
610
+ // vertex are sent to "relation".
611
+ //
612
+ // If the two loop boundaries cross, this method is guaranteed to return
613
+ // true. It also returns true in certain cases if the loop relationship is
614
+ // equivalent to crossing. For example, if the relation is Contains() and a
615
+ // point P is found such that B contains P but A does not contain P, this
616
+ // method will return true to indicate that the result is the same as though
617
+ // a pair of crossing edges were found (since Contains() returns false in
618
+ // both cases).
619
+ //
620
+ // See Contains(), Intersects() and CompareBoundary() for the three uses of
621
+ // this function.
622
+ static bool HasCrossingRelation(const S2Loop& a, const S2Loop& b,
623
+ LoopRelation* relation);
624
+
625
+ // When the loop is modified (Invert(), or Init() called again) then the
626
+ // indexing structures need to be cleared since they become invalid.
627
+ void ClearIndex();
628
+
629
+ // The nesting depth, if this field belongs to an S2Polygon. We define it
630
+ // here to optimize field packing.
631
+ int depth_ = 0;
632
+
633
+ // We store the vertices in an array rather than a vector because we don't
634
+ // need any STL methods, and computing the number of vertices using size()
635
+ // would be relatively expensive (due to division by sizeof(S2Point) == 24).
636
+ // When DecodeWithinScope is used to initialize the loop, we do not
637
+ // take ownership of the memory for vertices_, and the owns_vertices_ field
638
+ // is used to prevent deallocation and overwriting.
639
+ int num_vertices_ = 0;
640
+ S2Point* vertices_ = nullptr;
641
+ bool owns_vertices_ = false;
642
+
643
+ S2Debug s2debug_override_ = S2Debug::ALLOW;
644
+ bool origin_inside_ = false; // Does the loop contain S2::Origin()?
645
+
646
+ // In general we build the index the first time it is needed, but we make an
647
+ // exception for Contains(S2Point) because this method has a simple brute
648
+ // force implementation that is also relatively cheap. For this one method
649
+ // we keep track of the number of calls made and only build the index once
650
+ // enough calls have been made that we think an index would be worthwhile.
651
+ mutable std::atomic<int32> unindexed_contains_calls_;
652
+
653
+ // "bound_" is a conservative bound on all points contained by this loop:
654
+ // if A.Contains(P), then A.bound_.Contains(S2LatLng(P)).
655
+ S2LatLngRect bound_;
656
+
657
+ // Since "bound_" is not exact, it is possible that a loop A contains
658
+ // another loop B whose bounds are slightly larger. "subregion_bound_"
659
+ // has been expanded sufficiently to account for this error, i.e.
660
+ // if A.Contains(B), then A.subregion_bound_.Contains(B.bound_).
661
+ S2LatLngRect subregion_bound_;
662
+
663
+ // Spatial index for this loop.
664
+ MutableS2ShapeIndex index_;
665
+
666
+ // SWIG doesn't understand "= delete".
667
+ #ifndef SWIG
668
+ void operator=(const S2Loop&) = delete;
669
+ #endif // SWIG
670
+ };
671
+
672
+
673
+ //////////////////// Implementation Details Follow ////////////////////////
674
+
675
+
676
+ // Any single-vertex loop is interpreted as being either the empty loop or the
677
+ // full loop, depending on whether the vertex is in the northern or southern
678
+ // hemisphere respectively.
679
+ inline S2Point S2Loop::kEmptyVertex() { return S2Point(0, 0, 1); }
680
+ inline S2Point S2Loop::kFullVertex() { return S2Point(0, 0, -1); }
681
+
682
+ inline std::vector<S2Point> S2Loop::kEmpty() {
683
+ return std::vector<S2Point>(1, kEmptyVertex());
684
+ }
685
+
686
+ inline std::vector<S2Point> S2Loop::kFull() {
687
+ return std::vector<S2Point>(1, kFullVertex());
688
+ }
689
+
690
+ inline bool S2Loop::is_empty() const {
691
+ return is_empty_or_full() && !contains_origin();
692
+ }
693
+
694
+ inline bool S2Loop::is_full() const {
695
+ return is_empty_or_full() && contains_origin();
696
+ }
697
+
698
+ inline bool S2Loop::is_empty_or_full() const {
699
+ return num_vertices() == 1;
700
+ }
701
+
702
+ // Since this method is templatized and public, the implementation needs to be
703
+ // in the .h file.
704
+
705
+ template <class T>
706
+ T S2Loop::GetSurfaceIntegral(T f_tri(const S2Point&, const S2Point&,
707
+ const S2Point&)) const {
708
+ return S2::GetSurfaceIntegral(vertices_span(), f_tri);
709
+ }
710
+
711
+ #endif // S2_S2LOOP_H_