Skip to content

Commit

Permalink
add debug msg
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Sep 1, 2022
1 parent 61ef5a3 commit ae4fc8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/common/datatypes/Geography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ Status LineString::isValid() const {
auto s2Region = geo::GeoUtils::s2RegionFromGeography(*this);
CHECK_NOTNULL(s2Region);

auto s2Line = static_cast<S2Polyline*>(s2Region.get());
auto sz = s2Line->num_vertices();
for (auto i = 0; i < sz; ++i) {
auto v = s2Line->vertex(i);
LOG(ERROR) << "vertex " << i << ": " << v.x() << ", " << v.y() << ", " << v.z();
}

S2Error error;
if (static_cast<S2Polyline*>(s2Region.get())->FindValidationError(&error)) {
if (s2Line->FindValidationError(&error)) {
std::stringstream ss;
ss << "FindValidationError, S2 Errorcode: " << error.code() << ", message: " << error.text();
return Status::Error(ss.str());
Expand Down
7 changes: 6 additions & 1 deletion src/common/geo/GeoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ class GeoUtils final {
static S2Point s2PointFromCoordinate(const Coordinate& coord) {
// Note: S2Point requires latitude to be first, and longitude to be last
auto latlng = S2LatLng::FromDegrees(coord.y, coord.x);
return latlng.ToPoint();
CHECK(latlng.is_valid());
LOG(ERROR) << "Coordinate, lng: " << coord.x << ", lat: " << coord.y;
LOG(ERROR) << "S2LatLng, lng: " << latlng.lng() << ", lng: " << latlng.lat();
auto point = latlng.ToPoint();
LOG(ERROR) << "S2Point, [x, y, z]: " << point.x() << " " << point.y() << " " << point.z();
return point;
}

static Coordinate coordinateFromS2Point(const S2Point& s2Point) {
Expand Down

0 comments on commit ae4fc8c

Please sign in to comment.