turfjs

turfjs lineArc with leaflet - angle problem?


I have the following code. lineArc works fine for the 1st three(R167B, D630C, R192B) but lineArc does not like R192A or R168A.

       //R167B ok
        var centerw = turf.point([115.959444, -31.945]);
        var startAnglew = 233;
        var endAnglew = 253;
        var radiusw =35.965;
        var arc = turf.lineArc(centerw, radiusw * 1.852, startAnglew, endAnglew, options);


        //D630C ok
        var centerx = turf.point([152.711944, -27640556]);
        var startAnglex = 287;
        var endAnglex = 331;
        var radiusx = 35.057;
        var arc = turf.lineArc(centerx, radiusx * 1.852, startAnglex, endAnglex, options);

        //R192B ok
        var centery = turf.point([115.959444, -31.945]);
        var startAngley = 253; 
        var endAngley = 278;
        var radiusy =69.83195;
        var arc = turf.lineArc(centery, radiusy * 1.852, startAngley, endAngley, options);

        //R192A not ok
        var centery = turf.point([115.959444, -31.945]);
        var startAngley = 253;
        var endAngley = 277; //change this to 276 or 278 and works fine?!?
        var radiusy =119.7195;          
        var arc = turf.lineArc(centery, radiusy * 1.852, startAngley, endAngley, options);

        //R168A not ok
        var centerx = turf.point([115.959444, -31.945]);
        var startAnglex = 303;
        var endAnglex = 327;
        var radiusx = 60.0439;
        var arc = turf.lineArc(centerx, radiusx * 1.852, startAnglex, endAnglex, options);

Error message output from lineArc is:

> turf.min.js:1  Uncaught Error: coordinates must be an array of two or
> more positions
>     at h (turf.min.js:1:2371)
>     at Object.bi [as lineArc] (turf.min.js:43:85958)
>     at getOrderedPolyLines (?dataset=7a95f134-be37-49e6-9aca-0b0780f30258:223009:18)
>     at drawVolume (?dataset=7a95f134-be37-49e6-9aca-0b0780f30258:222669:22)
>     at HTMLDivElement.<anonymous> (?dataset=7a95f134-be37-49e6-9aca-0b0780f30258:222549:8)
>     at HTMLDivElement.dispatch (jquery.min.js:2:43331)
>     at y.handle (jquery.min.js:2:41315)
>     at Object.trigger (jquery.min.js:2:71937)
>     at E.fn.init.triggerHandler (jquery.min.js:2:72616)
>     at Object.checkboxChange (gijgo.min.js:1:121495)

In a fiddle: https://jsfiddle.net/7g9smnkd/1/

Any ideas? Thanks in advance.


Solution

  • Issue raised on turfjs after no responses here:

    It has been noted that this is a bug, but there is a work around which is to change the steps option down to 14 then it passes without an error.

    See:

    https://github.com/Turfjs/turf/issues/2446