Closed NickHeiner closed 8 years ago
I've reproduced this issue with another test case:
var turf = require('turf');
var feature = {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[[-77.04709500074387, 38.89175098284184],
[-77.04718619585037, 38.891700879145844],
[-77.04723984003067, 38.89156100614076],
[-77.04739272594452, 38.89153595423019],
[-77.04737395048141, 38.891494201026234],
[-77.04719960689545, 38.891515077631254],
[-77.04711645841599, 38.89141278220791],
[-77.04717546701431, 38.89136685360256],
[-77.04733908176422, 38.891421132860245],
[-77.04733371734619, 38.891337626292795],
[-77.0474624633789, 38.89131674963559],
[-77.0474624633789, 38.89076560366621],
[-77.04648613929749, 38.89076560366621],
[-77.04644590616226, 38.89081362034119],
[-77.04651027917862, 38.890928442693195],
[-77.04644054174423, 38.89103908951131],
[-77.04647809267044, 38.89132718796495],
[-77.04660683870316, 38.891408606881384],
[-77.0468321442604, 38.89137311659593],
[-77.04681068658829, 38.89143992182437],
[-77.04672753810883, 38.89143157117428],
[-77.04672485589981, 38.89148376272141],
[-77.04679995775223, 38.89150881465039],
[-77.04675167798996, 38.89161946056447],
[-77.0469206571579, 38.89169252852642],
[-77.04696893692017, 38.89166956431788],
[-77.04703867435455, 38.89174054457476],
[-77.04709500074387, 38.89175098284184]],
[[-77.0414462685585, 38.89186789132842],
[-77.04195320606232, 38.891813612412165],
[-77.04202562570572, 38.8917843852862],
[-77.04212754964828, 38.89181778771487],
[-77.0422026515007, 38.891765596413194],
[-77.04234480857849, 38.89179273589488],
[-77.0424011349678, 38.891640337132685],
[-77.0424896478653, 38.89159232101656],
[-77.04290807247162, 38.89156518145833],
[-77.04322189092636, 38.891642424789154],
[-77.0432299375534, 38.89171131741875],
[-77.04331308603287, 38.89174680753521],
[-77.04357326030731, 38.89178647293846],
[-77.0437154173851, 38.89173845692116],
[-77.04378515481949, 38.89178647293846],
[-77.04397022724152, 38.891773947024035],
[-77.04400509595871, 38.891684177906],
[-77.04410433769226, 38.89164660010195],
[-77.04491972923279, 38.891527603591356],
[-77.04506993293762, 38.89143157117428],
[-77.04493314027786, 38.891001511366],
[-77.04496264457703, 38.89077186671261],
[-77.04496800899506, 38.89076560366621],
[-77.04070597887039, 38.89076560366621],
[-77.04071938991547, 38.890796918892704],
[-77.04070329666138, 38.891085018328596],
[-77.04077035188675, 38.891101719709326],
[-77.04068720340729, 38.89114764848611],
[-77.04070061445236, 38.89121445392658],
[-77.04077303409576, 38.89123741828226],
[-77.04071670770645, 38.89137311659593],
[-77.04081594944, 38.891500464008374],
[-77.04091787338257, 38.891496288686994],
[-77.04105734825134, 38.89164660010195],
[-77.04126119613647, 38.891732193959996],
[-77.0413202047348, 38.891811524760726],
[-77.04138189554214, 38.89179482354686],
[-77.04136312007904, 38.89183866422482],
[-77.0414462685585, 38.89186789132842]]
]},
};
var tilePoly = {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[[-77.04574584960938, 38.892101707724294],
[-77.04437255859375, 38.892101707724294],
[-77.04437255859375, 38.89103282648847],
[-77.04574584960938, 38.89103282648847],
[-77.04574584960938, 38.892101707724294]]
]},
};
var result = turf.intersect(feature, tilePoly);
console.log("result: ", result);
Output with node is as in the original report.
In a browser, I get the following error message:
TopologyError: no outgoing dirEdge found [ (-77.04574584960938, 38.892101707724294) ]
@jamesbursa in your first polygon, the start and end coordinates do not match. That makes it an invalid polygon.
The start and end coordinates do match in each of the 2 rings - isn't that all that is needed?
Ah, I see the issue now. Your polygon has a hole that is outside the outer ring, making it invalid.
The original test case had a similar issue. The first polygon contained two rings that touched, which is invalid.
Thanks for reporting this. Polygon validity can be a tricky issue to nail down. I'm closing this issue, but if you still run into snags after fixing your polygons, please reopen.
Here is my code:
When I run this, I get:
Is this a bug, or am I doing something wrong? If I am doing something wrong, it would be nice if the error were more descriptive.