Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest google3 version #254

Merged
merged 2 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/python/s2_common.i
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,11 @@ class S2Point {
%define USE_EQUALS_FN_FOR_EQ_AND_NE(type)
%extend type {
bool __eq__(const type& other) {
return $self->Equals(&other);
return $self->Equals(other);
}

bool __ne__(const type& other) {
return !$self->Equals(&other);
return !$self->Equals(other);
}
}
%enddef
Expand Down
4 changes: 2 additions & 2 deletions src/s2/encoded_s2point_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ void EncodeS2PointVectorFast(Span<const S2Point> points, Encoder* encoder) {
bool EncodedS2PointVector::InitUncompressedFormat(Decoder* decoder) {
#if !defined(IS_LITTLE_ENDIAN) || defined(__arm__) || \
defined(ABSL_INTERNAL_NEED_ALIGNED_LOADS)
// TODO(ericv): Make this work on platforms that don't support unaligned
// 64-bit little-endian reads, e.g. by falling back to
// TODO(b/231674214): Make this work on platforms that don't support
// unaligned 64-bit little-endian reads, e.g. by falling back to
//
// bit_cast<double>(little_endian::Load64()).
//
Expand Down
2 changes: 1 addition & 1 deletion src/s2/encoded_s2point_vector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ TEST(EncodedS2PointVectorTest, SnappedFractalLoops) {
lax_polygon_size +=
TestEncodedS2PointVector(points, CodingHint::COMPACT, -1) + 2;
}
printf("n=%5d s2=%9" PRIuS " lax=%9" PRIuS "\n",
printf("n=%5d s2=%9zu lax=%9zu\n",
num_points, s2polygon_size, lax_polygon_size);
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/s2/encoded_s2shape_index_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ TEST(EncodedS2ShapeIndex, RegularLoops) {
}
}

#ifndef __EMSCRIPTEN__
// TODO(b/232496949): This test relies on `random()` return values because
// it tests an exact encoded byte size. Either change it to accept a range
// of sizes, or decode and check either the number of shapes, or possibly
// the points themselves by resetting the RNG state.
TEST(EncodedS2ShapeIndex, OverlappingPointClouds) {
struct TestCase {
int num_shapes, num_points_per_shape;
Expand Down Expand Up @@ -144,6 +149,7 @@ TEST(EncodedS2ShapeIndex, OverlappingPointClouds) {
}
}

// TODO(b/232496949): This test relies on `random()` return values.
TEST(EncodedS2ShapeIndex, OverlappingPolylines) {
struct TestCase {
int num_shapes, num_shape_edges;
Expand Down Expand Up @@ -174,6 +180,7 @@ TEST(EncodedS2ShapeIndex, OverlappingPolylines) {
}
}

// TODO(b/232496949): This test relies on `random()` return values.
TEST(EncodedS2ShapeIndex, OverlappingLoops) {
struct TestCase {
int num_shapes, max_edges_per_loop;
Expand Down Expand Up @@ -203,6 +210,7 @@ TEST(EncodedS2ShapeIndex, OverlappingLoops) {
index, test_case.expected_bytes);
}
}
#endif // defined(__EMSCRIPTEN__)

// Like S2PolylineLayer, but converts the polyline to an S2LaxPolylineShape
// and adds it to an S2ShapeIndex (if the polyline is non-empty).
Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2boolean_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ extern bool s2builder_verbose;
namespace { // Anonymous namespace for helper classes.

using absl::flat_hash_map;
using absl::make_unique;
using std::lower_bound;
using std::make_pair;
using absl::make_unique;
using std::max;
using std::min;
using std::pair;
Expand Down
6 changes: 3 additions & 3 deletions src/s2/s2boolean_operation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ namespace {
using absl::ByAnyChar;
using absl::SkipEmpty;
using absl::StrContains;
using absl::StrSplit;
using absl::make_unique;
using absl::string_view;
using absl::StrSplit;
using s2builderutil::IndexMatchingLayer;
using s2builderutil::LaxPolygonLayer;
using s2shapeutil::ContainsBruteForce;
using absl::make_unique;
using std::pair;
using std::unique_ptr;
using std::string;
using std::unique_ptr;
using std::vector;

using EdgeType = S2Builder::EdgeType;
Expand Down
4 changes: 2 additions & 2 deletions src/s2/s2buffer_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
#include "s2/s2shapeutil_contains_brute_force.h"
#include "s2/util/math/mathutil.h"

using absl::make_unique;
using s2pred::DBL_ERR;
using std::ceil;
using absl::make_unique;
using std::max;
using std::min;
using std::vector;
using std::unique_ptr;
using std::vector;

// The errors due to buffering can be categorized as follows:
//
Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
#include "s2/s2text_format.h"
#include "s2/util/gtl/dense_hash_set.h"

using absl::make_unique;
using gtl::compact_array;
using gtl::dense_hash_set;
using absl::make_unique;
using std::max;
using std::pair;
using std::unique_ptr;
Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builder_graph_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include "s2/s2lax_polyline_shape.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2builderutil::GraphClone;
using s2builderutil::GraphCloningLayer;
using s2textformat::MakeLaxPolylineOrDie;
using s2textformat::ParsePointsOrDie;
using absl::make_unique;
using std::vector;

using EdgeType = S2Builder::EdgeType;
Expand Down
25 changes: 16 additions & 9 deletions src/s2/s2builder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@

using absl::StrAppend;
using absl::StrCat;
using absl::make_unique;
using std::cout;
using std::endl;
using std::make_pair;
using std::min;
using std::pair;
using std::string;
using std::unique_ptr;
using std::vector;
using s2builderutil::GraphClone;
using s2builderutil::IdentitySnapFunction;
using s2builderutil::IntLatLngSnapFunction;
Expand All @@ -81,6 +72,15 @@ using s2builderutil::S2PolylineVectorLayer;
using s2textformat::MakePointOrDie;
using s2textformat::MakePolygonOrDie;
using s2textformat::MakePolylineOrDie;
using std::cout;
using std::endl;
using std::make_pair;
using absl::make_unique;
using std::min;
using std::pair;
using std::string;
using std::unique_ptr;
using std::vector;
using EdgeType = S2Builder::EdgeType;
using InputEdgeId = S2Builder::Graph::InputEdgeId;
using Graph = S2Builder::Graph;
Expand Down Expand Up @@ -1716,4 +1716,11 @@ TEST(S2Builder, IncorrectSeparationSiteBug) {
ASSERT_TRUE(builder.Build(&error)) << error;
}

TEST(S2Builder, PushPopLabel) {
// TODO(b/232074544): Test more thoroughly.
S2Builder builder;
builder.push_label(S2Builder::Label{1});
builder.pop_label();
}

} // namespace
3 changes: 2 additions & 1 deletion src/s2/s2builderutil_find_polygon_degeneracies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <algorithm>
#include <cstdlib>
#include <memory>
#include <utility>
#include <vector>

Expand All @@ -32,8 +33,8 @@
#include "s2/s2pointutil.h"
#include "s2/s2predicates.h"

using absl::make_unique;
using std::make_pair;
using absl::make_unique;
using std::pair;
using std::vector;

Expand Down
1 change: 1 addition & 0 deletions src/s2/s2builderutil_get_snapped_winding_delta_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "s2/s2builderutil_get_snapped_winding_delta.h"

#include <iostream>
#include <memory>

#include <gtest/gtest.h>
#include "absl/memory/memory.h"
Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builderutil_lax_polygon_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
#include "s2/s2debug.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using absl::string_view;
using s2builderutil::IndexedLaxPolygonLayer;
using s2builderutil::LaxPolygonLayer;
using s2textformat::MakeLaxPolygonOrDie;
using s2textformat::MakePointOrDie;
using s2textformat::MakePolylineOrDie;
using absl::make_unique;
using std::map;
using std::set;
using std::string;
Expand Down
3 changes: 2 additions & 1 deletion src/s2/s2builderutil_lax_polyline_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "s2/s2builderutil_lax_polyline_layer.h"

#include <memory>
#include <string>

#include "s2/base/casts.h"
Expand All @@ -26,10 +27,10 @@
#include "s2/s2builderutil_snap_functions.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2builderutil::IndexedLaxPolylineLayer;
using s2builderutil::LaxPolylineLayer;
using s2textformat::MakeLaxPolylineOrDie;
using absl::make_unique;
using std::string;
using std::vector;

Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builderutil_s2point_vector_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
#include "s2/mutable_s2shape_index.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2builderutil::IndexedS2PointVectorLayer;
using s2builderutil::S2PointVectorLayer;
using s2textformat::MakePointOrDie;
using absl::make_unique;
using std::string;
using std::vector;

Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builderutil_s2polygon_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "absl/memory/memory.h"
#include "s2/s2debug.h"

using absl::make_unique;
using std::make_pair;
using absl::make_unique;
using std::pair;
using std::unique_ptr;
using std::vector;
Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builderutil_s2polygon_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#include "s2/s2debug.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2builderutil::IndexedS2PolygonLayer;
using s2builderutil::S2PolygonLayer;
using s2textformat::MakePolylineOrDie;
using absl::make_unique;
using std::map;
using std::set;
using std::string;
Expand Down
3 changes: 2 additions & 1 deletion src/s2/s2builderutil_s2polyline_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "s2/s2builderutil_s2polyline_layer.h"

#include <memory>
#include <string>

#include "s2/base/casts.h"
Expand All @@ -27,10 +28,10 @@
#include "s2/s2debug.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2builderutil::IndexedS2PolylineLayer;
using s2builderutil::S2PolylineLayer;
using s2textformat::MakePolylineOrDie;
using absl::make_unique;
using std::string;
using std::vector;

Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2builderutil_s2polyline_vector_layer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
#include "s2/s2builderutil_snap_functions.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2builderutil::IndexedS2PolylineVectorLayer;
using s2builderutil::S2PolylineVectorLayer;
using s2textformat::MakePolylineOrDie;
using absl::make_unique;
using std::string;
using std::unique_ptr;
using std::vector;
Expand Down
1 change: 1 addition & 0 deletions src/s2/s2cell_id.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "s2/base/integral_types.h"
#include "s2/base/logging.h"
#include "s2/util/bits/bits.h"
#include "s2/util/coding/coder.h"
#include "s2/r1interval.h"
#include "s2/s2coords.h"
#include "s2/s2latlng.h"
Expand Down
1 change: 0 additions & 1 deletion src/s2/s2cell_id_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ TEST(S2CellId, DecodeFailsWithTruncatedBuffer) {
EXPECT_FALSE(decoded_id.Decode(&decoder));
}


static const int kMaxExpandLevel = 3;

static void ExpandCell(
Expand Down
1 change: 1 addition & 0 deletions src/s2/s2cell_union.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "absl/base/macros.h"
#include "absl/flags/flag.h"
#include "absl/hash/hash.h"

#include "s2/base/commandlineflags.h"
#include "s2/base/integral_types.h"
Expand Down
2 changes: 1 addition & 1 deletion src/s2/s2closest_cell_query_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@

namespace {

using absl::make_unique;
using s2testing::FractalLoopShapeIndexFactory;
using s2textformat::MakeCellIdOrDie;
using s2textformat::MakePointOrDie;
using absl::make_unique;
using std::pair;
using std::unique_ptr;
using std::vector;
Expand Down
16 changes: 15 additions & 1 deletion src/s2/s2closest_edge_query_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
#include "s2/s2testing.h"
#include "s2/s2text_format.h"

using absl::make_unique;
using s2shapeutil::ShapeEdgeId;
using s2textformat::MakeIndexOrDie;
using s2textformat::MakePointOrDie;
using absl::make_unique;
using std::min;
using std::pair;
using std::string;
Expand Down Expand Up @@ -210,12 +210,26 @@ TEST(S2ClosestEdgeQuery, TargetPolygonContainingIndexedPoints) {
target.set_include_interiors(true);
auto results = query.FindClosestEdges(&target);
ASSERT_EQ(2, results.size());

EXPECT_EQ(S1ChordAngle::Zero(), results[0].distance());
EXPECT_EQ(0, results[0].shape_id());
EXPECT_EQ(2, results[0].edge_id()); // 1:11
EXPECT_FALSE(results[0].is_interior());
S2Shape::Edge e0 = query.GetEdge(results[0]);
EXPECT_TRUE(S2::ApproxEquals(e0.v0, S2LatLng::FromDegrees(1, 11).ToPoint()))
<< S2LatLng(e0.v0);
EXPECT_TRUE(S2::ApproxEquals(e0.v1, S2LatLng::FromDegrees(1, 11).ToPoint()))
<< S2LatLng(e0.v1);

EXPECT_EQ(S1ChordAngle::Zero(), results[1].distance());
EXPECT_EQ(0, results[1].shape_id());
EXPECT_EQ(3, results[1].edge_id()); // 3:13
EXPECT_FALSE(results[1].is_interior());
S2Shape::Edge e1 = query.GetEdge(results[1]);
EXPECT_TRUE(S2::ApproxEquals(e1.v0, S2LatLng::FromDegrees(3, 13).ToPoint()))
<< S2LatLng(e1.v0);
EXPECT_TRUE(S2::ApproxEquals(e1.v1, S2LatLng::FromDegrees(3, 13).ToPoint()))
<< S2LatLng(e1.v1);
}

TEST(S2ClosestEdgeQuery, EmptyTargetOptimized) {
Expand Down
7 changes: 7 additions & 0 deletions src/s2/s2edge_clipping_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ void TestFaceClipping(const S2Point& a_raw, const S2Point& b_raw) {
EXPECT_LE(b.Angle(S2::FaceUVtoXYZ(segments[n-1].face, segments[n-1].b)),
kErrorRadians);

// Similarly, in UV space.
R2Point a_uv, b_uv;
EXPECT_TRUE(S2::FaceXYZtoUV(segments[0].face, a, &a_uv));
EXPECT_TRUE(S2::FaceXYZtoUV(segments[n-1].face, b, &b_uv));
EXPECT_LE((a_uv - segments[0].a).Norm(), S2::kFaceClipErrorUVDist);
EXPECT_LE((b_uv - segments[n-1].b).Norm(), S2::kFaceClipErrorUVDist);

S2Point norm = S2::RobustCrossProd(a, b).Normalize();
S2Point a_tangent = norm.CrossProd(a);
S2Point b_tangent = b.CrossProd(norm);
Expand Down
Loading