Draw a line from a point knowing the direction and distance from it

2517
10
Jump to solution
12-23-2021 10:32 AM
mohammed_raufshaikh
Emerging Contributor

Hi Friends,

IS it possible to draw geometry by knowing the COGO dimension of a parcel from a deed of sale agreement using ARcgis Javascript API? I would like to start drawing from a know point and then traverse the geometry by entering the bearing, distance, radius and other cogo parameters. 

Same operation can be performed in ArcGIS pro using the Traverse tool under COGO section https://pro.arcgis.com/en/pro-app/latest/help/editing/create-a-traverse.htm .

Any help or idea on how to go about this will be much appreciated.

Thanks,

Rauf

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AndyGup
Esri Regular Contributor

@mohammed_raufshaikh here's a snippet the will help you find the new point using latitude, longitude, bearing and radius (distance). That should at least get you started. Once you have the new point you can draw a polyline using the beginning and ending points. Here's a sample that demonstrates the concepts for creating a line (see item number 3 and 4): https://developers.arcgis.com/javascript/latest/sample-code/intro-graphics/

        function bearingDistance(lat, lon, radius, bearing){
          let lat1Rads = toRad(lat);
          let lon1Rads = toRad(lon);
          const R_KM = 6371; // radius in KM
          let d = radius/R_KM; //angular distance on earth's surface

          let bearingRads = toRad(bearing);
          let lat2Rads = Math.asin(
            Math.sin(lat1Rads) * Math.cos(d) + Math.cos(lat1Rads) * Math.sin(d) * Math.cos(bearingRads)
          );

          let lon2Rads = lon1Rads + Math.atan2(
            Math.sin(bearingRads) * Math.sin(d) * Math.cos(lat1Rads),
            Math.cos(d) - Math.sin(lat1Rads) * Math.sin(lat2Rads)
          );

          return {
            latitude: toDeg(lat2Rads),
            longitude: toDeg(lon2Rads)
          }
        }

 

View solution in original post

10 Replies
jcarlson
MVP Esteemed Contributor

The Parcel Drafter WAB Widget already does this, though it's only available in the 3.x JS API. You could open it up and see if you can convert its source code to work in the 4.x API.

- Josh Carlson
Kendall County GIS
0 Kudos
mohammed_raufshaikh
Emerging Contributor

Hi Josh,

Thanks for your response but I don't see the Parcel Drafter Widget in 3.x JS API as well, looks like it is available as part of ArcGIS Web AppBuilder.

Thanks,

Rauf

0 Kudos
jcarlson
MVP Esteemed Contributor

Yes, you'd probably need to download the WAB Developer Edition to look at what's going on in that widget, but it's built for the 3.x API.

- Josh Carlson
Kendall County GIS
0 Kudos
mohammed_raufshaikh
Emerging Contributor

Ok, Thanks for your inputs. This gives me some direction to go forward.

 

Thanks,

Rauf

0 Kudos
AndyGup
Esri Regular Contributor

@mohammed_raufshaikh here's a snippet the will help you find the new point using latitude, longitude, bearing and radius (distance). That should at least get you started. Once you have the new point you can draw a polyline using the beginning and ending points. Here's a sample that demonstrates the concepts for creating a line (see item number 3 and 4): https://developers.arcgis.com/javascript/latest/sample-code/intro-graphics/

        function bearingDistance(lat, lon, radius, bearing){
          let lat1Rads = toRad(lat);
          let lon1Rads = toRad(lon);
          const R_KM = 6371; // radius in KM
          let d = radius/R_KM; //angular distance on earth's surface

          let bearingRads = toRad(bearing);
          let lat2Rads = Math.asin(
            Math.sin(lat1Rads) * Math.cos(d) + Math.cos(lat1Rads) * Math.sin(d) * Math.cos(bearingRads)
          );

          let lon2Rads = lon1Rads + Math.atan2(
            Math.sin(bearingRads) * Math.sin(d) * Math.cos(lat1Rads),
            Math.cos(d) - Math.sin(lat1Rads) * Math.sin(lat2Rads)
          );

          return {
            latitude: toDeg(lat2Rads),
            longitude: toDeg(lon2Rads)
          }
        }

 

raufshkh85
New Contributor

Hi @AndyGup , Thanks a lot for your inputs. I will check it out and will update on the progress.

0 Kudos
AndyGup
Esri Regular Contributor

Oops, 2 functions got cut off and I can't edit my previously reply. You'll also need these two functions:

        function toRad(degrees){
          return degrees * Math.PI / 180;
        }

        function toDeg(radians){
          return radians * 180 / Math.PI;
        }
0 Kudos
mohammed_raufshaikh
Emerging Contributor

Hi @AndyGup , I am able to draw a line from a point based on given bearing (e.x. NE 0 deg 12 min 20 sec) and distance but couldn't find a way to draw a curved line from a point given bearing (e.x. NE 0 deg 12 min 20 sec), radius and arc length. Are you aware of how I can achieve it? Below is an example of how user will enter bearing, distance, radius and arclength values

mohammed_raufshaikh_0-1643300262066.png

 

0 Kudos
AndyGup
Esri Regular Contributor

Hi @mohammed_raufshaikh, I'm aware of the formulas to do it but haven't researched it recently, you might marked this post as answered and create a new post about curved lines to get better visibility from the community. Here's a simple example of how to draw a curved line between two points: https://community.esri.com/t5/arcgis-api-for-javascript-questions/how-to-draw-a-curved-line-between-...

0 Kudos