Comments (2)
This does appear to be a bug or, at least, an implementation inconsistent with the C++ implementation. Below is an equivalent C++ program. The provided loops work fine when calling S2Polygon::InitNested(), but produce an error when calling S2Polygon::InitOriented().
#include <iostream>
#include <memory>
#include <vector>
#include <s2/s2latlng.h>
#include <s2/s2loop.h>
#include <s2/s2point.h>
#include <s2/s2polygon.h>
using std::cout;
using std::endl;
using std::vector;
int main() {
vector<S2Point> s{
S2LatLng::FromDegrees(35.841751, 50.991497).ToPoint(),
S2LatLng::FromDegrees(35.836811, 50.991626).ToPoint(),
S2LatLng::FromDegrees(35.83695, 51.002612).ToPoint(),
S2LatLng::FromDegrees(35.842065, 51.00081).ToPoint(),
};
vector<S2Point> h{
S2LatLng::FromDegrees(35.841056, 50.996089).ToPoint(),
S2LatLng::FromDegrees(35.837785, 50.993557).ToPoint(),
S2LatLng::FromDegrees(35.83789, 51.000381).ToPoint(),
};
vector<std::unique_ptr<S2Loop>> loops;
loops.push_back(std::make_unique<S2Loop>(s));
loops.push_back(std::make_unique<S2Loop>(h));
cout << loops[0]->GetArea() - loops[1]->GetArea() << endl;
S2Polygon polyN;
polyN.InitNested(std::move(loops));
cout << polyN.GetArea() << endl;
cout << polyN.IsValid() << endl;
loops.clear();
loops.push_back(std::make_unique<S2Loop>(s));
loops.push_back(std::make_unique<S2Loop>(h));
S2Polygon polyO;
polyO.InitOriented(std::move(loops));
cout << polyO.GetArea() << endl;
cout << polyO.IsValid() << endl;
return 0;
}
Output:
9.93132e-09
9.93132e-09
1
/home/mark/s2geometry/src/s2/s2polygon.cc:180 ERROR Inconsistent loop orientations detected
/home/mark/s2geometry/src/s2/s2polygon.cc:447 FATAL Check failed: IsValid() Aborted
from geo.
Looks like the implementation is incomplete. The TODO comment in s2/polygon.go indicates that the validation is currently not implementing the orientation check. As you can see, the planned error message, "inconsistent loop orientations detected"
matches the error reported by the C++ implementation.
Lines 462 to 473 in e86565b
from geo.
Related Issues (20)
- Calculate S2 of polygon with OOM Error in golang
- AllNeighbors has a bug
- Is this project out of maintenance?
- s2/lax_polyline_test_test.go
- Loop `validate()` fails to adequately detect duplicate vertices
- Loop.Area() unit HOT 1
- Find Closest Edge Performance with Many Polylines
- Porting bug
- Bug on Polygon Contains (linked to https://github.com/golang/geo/issues/77 ?) HOT 1
- High memory usage in getting s2 cell covering HOT 3
- Polygon.Intersects() method not working for some inputs? HOT 1
- golang-s2 momory leak HOT 1
- Q: How do you calculate the distance in km between 2 lat/lng points? HOT 7
- ppc64le - TestPredicatesRobustSignEqualities failure due to floating point precision differences HOT 1
- ppc64le - TestPointMeasuresPointArea failure due to floating point precision differences
- ppc64le - TestClosestEdgeQueryTrueDistanceLessThanChordAngleDistance failure due to floating point precision differences HOT 1
- Inverted params HOT 1
- Get a random point from a shape HOT 2
- Subdivide polygon
- Memory Leak when a loop contains point multiple time HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geo.