Turf: ArcByCenterPoint

Created on 7 Apr 2017  路  9Comments  路  Source: Turfjs/turf

Hi!

I did not find any method provided by the Turf lib which handle my case.

In fact, I have:

  • startAngle (degrees)
  • endAngle (degrees)
  • radius (kilometers)
  • centerPoint (long, lat) Center of the whole circle.

Basically I want to generate and ArcByCenterPoint with those data.

Is it possible ?

Thanks.

Most helpful comment

Hey stebogit!

I believe you are talking about this method:

function getArcLine(center, radius, angle1, angle2, steps, units)

It would be really appreciated if you can do that.

Thank you very much.

All 9 comments

Hi!

I just tested the turf-sector method and obviously there is a misunderstanding. Well the method itself is working perfectly but this is not what I requested.

screen shot 2017-04-09 at 6 07 22 pm

In fact I got a circle sector but what I want is ONLY the line Arc not the entire sector :)

Thanks!

I don't think there's any misunderstanding, what @stebogit implemented lines up perfectly with https://github.com/Turfjs/turf/issues/155.

This new module request would be called @turf/line-arc which would have this as a result (red line):

image

@Adraesh Feel free to send a PR to TurfJS if you want specific modules implemented.

Thanks Denis, but what I wanted to say is that my post can't be referenced to the turf-sector module newly implemented :)

@DenisCarriere @Adraesh I can easily implement a turf-arc-line module simply extracting a currently private function inside the sector module.

Hey stebogit!

I believe you are talking about this method:

function getArcLine(center, radius, angle1, angle2, steps, units)

It would be really appreciated if you can do that.

Thank you very much.

馃憤 @stebogit Sounds like a plan, afterwards you can add @turf/line-arc as a dependency to @turf/sector.

Thanks to @stebogit @turf/line-arc is now available on npm.

Tanks also to @DenisCarriere! 馃憤
I'll add @turf/line-arc as a dependency to @turf/sector then.

I'm using a <Layer> and a <Feature> from react-mapbox-gl to draw a line from Point A to Point B ( see screenshot 1)

My goal is to use line-arc and center from turf js in order to have a curved line between point A and point B

I managed to get a curved line, but it's not starting at Point A and it's not finishing at Point B... it is instead drawn in the middle of the map (see screenshot number 2)

Here is my code

     const features = turf.featureCollection([
       turf.point(this.state.startFlying),   // [-122.3811441, 37.6213129]
       turf.point(this.state.destinationFlying),  // [-118.4107187, 33.9415889]
     ]);

    const theCenter = turf.center(features);
    const arcRadius = 5;
    const bearing1 = 25;
    const bearing2 = 47;

    const arc = turf.lineArc(theCenter, arcRadius, bearing1, bearing2);
    const mappedCurvedFlyingCurve = arc.geometry.coordinates;

screen shot 2018-01-08 at 1 17 16 pm

screen shot 2018-01-08 at 1 22 10 pm

screen shot 2018-01-08 at 1 22 31 pm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stebogit picture stebogit  路  5Comments

psi-gh picture psi-gh  路  4Comments

privateOmega picture privateOmega  路  3Comments

amishas157 picture amishas157  路  3Comments

DenisCarriere picture DenisCarriere  路  3Comments