Exception: PolyBool: Zero-length segment detected; your epsilon is probably too small or too large
moodstubos opened this issue · 2 comments
moodstubos commented
Thanks for this package!
Unfortunately I get this error with some (valid) coordinates.
polybool 0.2.0
Here is a simple example:
import 'package:polybool/polybool.dart';
void main(args) {
var poly1 = Polygon(regions: [
[
Coordinate(3.73333333, 44.01666667),
Coordinate(3.96666667, 43.76666667),
Coordinate(4.2658333333333, 43.7538888888889),
Coordinate(4.2555555555556, 43.8111111111111),
Coordinate(4.2333333333333, 43.8425),
Coordinate(4.2133333333333, 43.8805555555556),
Coordinate(4.2130555555556, 43.8902777777778),
Coordinate(4.2086111111111, 43.9022222222222),
Coordinate(4.1825, 43.915),
Coordinate(4.2166666666667, 43.9222222222222),
Coordinate(4.2333333333333, 43.9333333333333),
Coordinate(3.73333333, 44.01666667)
]
]);
var poly2 = Polygon(regions: [
[
Coordinate(4.01388889, 43.95555556),
Coordinate(3.96805556, 43.85833333),
Coordinate(4.05555556, 43.84396135),
Coordinate(4.15555556, 43.82753623),
Coordinate(4.25555556, 43.81111111),
Coordinate(4.29444444, 43.80555556),
Coordinate(4.34027778, 43.90138889),
Coordinate(4.21666667, 43.92222222),
Coordinate(4.01388889, 43.95555556),
Coordinate(4.01388889, 43.95555556)
]
]);
final diff = poly1.difference(poly2);
}
Unhandled exception:
Exception: PolyBool: Zero-length segment detected; your epsilon is probably too small or too large
#0 Intersecter.calculate_INTERNAL (package:polybool/src/intersector.dart:333:11)
#1 Intersecter.calculateXD (package:polybool/src/intersector.dart:87:12)
#2 Polygon._combine (package:polybool/src/polygon.dart:60:21)
#3 Polygon._operate (package:polybool/src/polygon.dart:36:18)
#4 Polygon.difference (package:polybool/src/polygon.dart:24:12)
#5 main (bin/polybool_exception_test.dart:36:22)
#6 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
#7 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
mohammedX6 commented
Hi
Try to make your coordinates to have max of 5 decimal points at max
For example:
4.2658333333333
Should be:
4.26583
moodstubos commented
@mohammedX6
That works - thanks you!
Perhaps this could be implemented into this package?
double precision(double d) {
String inString = d.toStringAsFixed(5);
return double.parse(inString);
}