turf-concave throws an exception with a group of GPS points
Hi,
https://jsfiddle.net/rnisthal/7tsygLrs/
I have some stops from a GPS and I want to run concave on these points. Why is this dataset causing an exception, and how can I prevent similar ones?
Thanks!
Specific error is

I think we should hit #310 which should fix this issue as well.
I like the output of the current method better than concaveman (it's better suited for my needs). Maybe turf could provide both algorithms, the current implementation and concaveman?
To avoid the exception I first have to deduplicate the array of points.
https://jsfiddle.net/rnisthal/7tsygLrs/8/
For me the precision granted by Open Location Code is enough to fix my problem, at least with the test set. ;) Any ideas for a better deduplication method? In any case, maybe the deduplication should be made inside turf?
Thanks!
PS. What I really need, which is ridiculously slow:
var p = [];
for (i = 0; i < points.features.length; i++) { var p1 = turf.buffer(points.features[i], 0.25, 'kilometers')); p.push(p1.features[0]); }
var fc = turf.merge(turf.featurecollection(p));
- Set a buffer of radius x in every point.
- Merge all the buffers. That would give me a multipolygon. Group Points into each multipolygon Concave hull of each group.
Is there an efficient method for this?
I like the output of the current method better than concaveman (it's better suited for my needs).
Can you be much more specific? How is it better suited to what needs.
The points represent the places a salesperson visits on a week, or any timeframe really. If you group all the stops several salespersons visit, then you have the region that group covers. Then you can compare the region one group covers against the region other groups cover, and see if they overlap, for example.
turf.concave gives for a set of points several polygons. This would happen if you have two regions covered by the same sales group. If you define a maxEdge that is enough to group some stops together but not all.
concaveman groups everything together, at least I could not make it break into different regions for one set of points. It gives one outline even if there are edges longer than the maxEdge you give.
Sorry for my english.
Returning to turf.concave
it gave me a lot of Topology Errors, mostly like
JavaScript runtime error: TopologyError: found non-noded intersection between LINESTRING ( -90.5841035037037 14.654328174074073, -90.58451830599603 14.654413424851943 ) and LINESTRING ( -90.58451830599603 14.654413424851942, -90.58448331552006 14.654437446091392 ) [ (-90.58451830599603, 14.654413424851943) ]
But also one about an edge, didn't capture that one. What I ended doing is reducing even further the precision of my coordinates using:
var item = OpenLocationCode.encode(points.features[i].geometry.coordinates[1], points.features[i].geometry.coordinates[0], 8);
in my deduplication algorithm. The 8 reduces the precision from 0.000125° to 0.0025°
Maybe I will find a hashing algorithm with a precision between those two, but it will have to suffice for the time being.
If someone would like some datasets to test, I can gladly provide them.
Don't know if this is related to the GPS error, but I'm also have JSON.parse errors.
GeoJSON.FeatureCollection<Point>
https://gist.github.com/DenisCarriere/5b5771de1713005ef1fee834f3c4914b
turf.concave(points, 1, 'miles')
/Users/mac/Github/DefinitelyTyped/node_modules/@turf/concave/index.js:104
var merged = JSON.parse(JSON.stringify(polygons.features[0])),
^
SyntaxError: Unexpected token u in JSON at position 0
at Object.parse (native)
at merge (/Users/mac/Github/DefinitelyTyped/node_modules/@turf/concave/index.js:104:23)
at Object.concave (/Users/mac/Github/DefinitelyTyped/node_modules/@turf/concave/index.js:100:12)
at Object.<anonymous> (/Users/mac/Github/DefinitelyTyped/turf/turf-tests.ts:304:6)
at Module._compile (module.js:541:32)
at loader (/usr/local/lib/node_modules/ts-node/src/index.ts:286:14)
at Object.require.extensions.(anonymous function) [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:303:14)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
Fixed (ref. #899)