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 #312

Merged
merged 2 commits into from
Apr 27, 2023
Merged

Update to latest google3 version #312

merged 2 commits into from
Apr 27, 2023

Conversation

jmr
Copy link
Member

@jmr jmr commented Apr 24, 2023

  • Use absl::flags and absl::log instead of gflags/glog
  • Use ABSL_UNREACHABLE, requires abseil/abseil-cpp@6a87605
  • New edge/circle intersection ordering predicates
  • New functions GetUVCoordOfEdge and GetIJCoordOfEdge
  • S2PolylineAlignment: Use Norm instead of Norm2
  • S2Polygon::DestructiveUnion: Use priority_queue internally
  • Update CONTRIBUTING.md with more detailed instructions
  • Replace const char * with absl::string_view
  • Replace most gtl::dense_hash_set uses with absl::flat_hash_set
  • Replace most std::set and std::map with absl::flat_hash_set
    and flat_hash_map

jmr added 2 commits April 20, 2023 11:10
* Use absl::flags and absl::log instead of gflags/glog
* Use ABSL_UNREACHABLE, requires abseil/abseil-cpp@6a87605
* New edge/circle intersection ordering predicates
* New functions `GetUVCoordOfEdge` and `GetIJCoordOfEdge`
* S2PolylineAlignment: Use Norm instead of Norm2
* S2Polygon::DestructiveUnion: Use priority_queue internally
* Update CONTRIBUTING.md with more detailed instructions
* Replace `const char *` with `absl::string_view`
* Replace most `gtl::dense_hash_set` uses with `absl::flat_hash_set`
* Replace most `std::set` and `std::map` with `absl::flat_hash_set`
  and `flat_hash_map`
Update to latest google3 version

* Use absl::flags and absl::log instead of gflags/glog
* Use ABSL_UNREACHABLE, requires abseil/abseil-cpp@6a87605
* New edge/circle intersection ordering predicates
* New functions `GetUVCoordOfEdge` and `GetIJCoordOfEdge`
* S2PolylineAlignment: Use Norm instead of Norm2
* S2Polygon::DestructiveUnion: Use priority_queue internally
* Update CONTRIBUTING.md with more detailed instructions
* Replace `const char *` with `absl::string_view`
* Replace most `gtl::dense_hash_set` uses with `absl::flat_hash_set`
* Replace most `std::set` and `std::map` with `absl::flat_hash_set`
  and `flat_hash_map`
@jmr
Copy link
Member Author

jmr commented Apr 25, 2023

@MBkkt

add_definitions(-DS2_USE_GFLAGS)
endif()
# Don't output anything for LOG(INFO).
add_definitions(-DABSL_MIN_LOG_LEVEL=1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like now impossible to disable s2 log, flags, asserts without patching

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that going to be a problem for you?

The main reason there was S2_USE_GFLAGS was in case someone didn't have it installed. Since it's all part of absl, it's less important now, but I can imagine people wanting to swap in another flags/logging package or save the size.

I think -DABSL_MIN_LOG_LEVEL=99 -DDABSL_MAX_VLOG_VERBOSITY=0 will disable logging. I don't think there's currently an "absl flags are just constants" option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, just noticed it can be big behavior change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll see if anyone complains.

src/s2/s2cell.h Show resolved Hide resolved
src/s2/s2cell_id_test.cc Show resolved Hide resolved
// The XYZ -> UV conversion is a single division per coordinate, which is
// promised to be at most 0.5*DBL_EPSILON absolute error for values with
// magnitude less than two.
constexpr double kMaxXYZtoUVError = 0.5 * DBL_EPSILON;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline constexpr? Or maybe at least todo if you're using C++14
https://quuxplusone.github.io/blog/2022/07/08/inline-constexpr/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an implicit TODO for all these C++17 features when we bump the minimum version.

extern const double kFaceClipErrorRadians;
extern const double kFaceClipErrorUVDist;
extern const double kFaceClipErrorUVCoord;
constexpr double kFaceClipErrorRadians = 3 * DBL_EPSILON;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all these variables

src/s2/s2edge_crossings_test.cc Show resolved Hide resolved
using PriorityQueue = priority_queue<Pair, vector<Pair>, greater<Pair>>;
PriorityQueue queue; // Least vertices is `top`.
for (size_t i = 0; i < polygons.size(); ++i) {
queue.emplace(polygons[i]->num_vertices(), i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size of polygons doesn't change here, so you can use address instead of compute it in loop with index

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes the resulting polygon depend on the addresses of the input polygons, which some clients complained about.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I probably should looked how union polygons work.
Ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I understand, above exist comment, I missed it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But wait, addresses of polygon in vector is monotonically increasing.
So I think this comment was about elements itself (addresses of polygons, not their cell in vector)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah, the comment was about S2Polygon *. You want to use a unique_ptr<S2Polygon> *? Yeah, that's probably better since it can't be confused with num_vertices.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need the index to put the polygon back into the array. Subtracting the pointers to get the index seems a bit roundabout.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably do this in a future release.

src/s2/s2polygon.cc Show resolved Hide resolved
src/s2/s2shapeutil_shape_edge_id.h Show resolved Hide resolved
@jmr jmr merged commit d184302 into google:master Apr 27, 2023
1 check passed
@jmr jmr deleted the update-2023-04-20 branch April 27, 2023 07:35
// right angles, that would get a different matching of points for distance
// cost versus squared distance cost. If we had used squared distance for the
// cost the path would be {{0, 0}, {1, 0}, {2, 0}, {3, 1}, {3, 2}}; See
// https://screenshot.googleplex.com/7eeMjdSc5HeSeTD for the costs between the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably add a check for internal URL's for screenshot.googleplex.com

return ExactIntersectionOrdering( //
ToExact(a), ToExact(b), ToExact(c), ToExact(d), ToExact(m), ToExact(n));

return 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There two returns here (line 913 && 916)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shocked the linter doesn't catch this, I'll get it fixed for the next roll. Glad to see you're still contributing btw =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants