Select to view content in your preferred language

4.14 - How to create an ellipse? (JS)

4870
11
Jump to solution
03-11-2020 12:56 PM
JackGeo
Emerging Contributor

I want to transform the table below into graphics on the map as ellipses: 

Table showing lat and lon

I effectively want to create the 'Table to Ellipse' tool : Create Ellipse Tool ArcGIS 10 - YouTube  

The only other thread I found was using the vertices taken from the draw tool:

api 4.11 - How to draw a ellipse? class' "draw.create('ellipse')" doesn't draw ellipse 

UPDATE 1: I've created a codepen with one of the solutions given below, could someone provide assistance? 

https://codepen.io/Jarviz/pen/yLNZqvQ?editors=1000 

UPDATE 2: I've seen that some people recommended a geoprocessing server which then uses the 'Table to Ellipse' tool. Is this still a good idea?

0 Kudos
11 Replies
kobybiton
New Contributor

hi the ellipse shape is awesome!

however, i tried to set the x_axis to 1000 meters and y_axis to 300 meters.

when i try to measure the ellipse on the map (with the esri polyline sketch feature), looks like the result on the map is not in any unit.

for example: x_axis of 1000 meter i measured 28,730.49 meters and for y_axis of 300 meters i measured 10,470.08 meters.

i expected to get the result in other unit like kilometers, miles, meters or any other and then to convert to the units i want (meters). which means the expected result is 10,000 meters if the function calc in km.

any ideas how to get the result in meters on the map?

const getPointsForEllipse = (lat1, lon1, xaxis, yaxis, rotation) => {
//axis distance in km
var rEarth = 6371.01; //# Earth's average radius in km
var rXaxis = (xaxis) / rEarth;
var rYaxis = (yaxis) / rEarth; //that shall be km distance, just use xaxis/yaxis at line 44, 45 if you want to measure by dms

var rRotation = degree2Radium(rotation);
var polygonRings = [];
for(var i=0;i<=360;i+=10){
var t = degree2Radium(i);// # ellipse math ref
var x = rXaxis * Math.cos(t);// # ellipse math
var y = rYaxis * Math.sin(t);// # ellipse math
var rot_x = lon1 +(x*Math.cos(rRotation))-(y*Math.sin(rRotation));// # rotate/transpose ellipse
var rot_y = lat1 +(y*Math.cos(rRotation))+(x*Math.sin(rRotation));// # rotate/transpose ellipse
polygonRings.push([rot_x, rot_y]);
}
return polygonRings;
};

const center_lat = 32.3;
const center_lon = 35.0;
const x_axis = 1000;
const y_axis = 300;
const rotation = 70;

getPointsForEllipse = (lat1, lon1, xaxis, yaxis, rotation)

Guy_srb
Regular Contributor

Hi kobybiton,

I've encountered the same problem and opened a new theard about it(with a a sulotion).

https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-an-ellipse/m-p/1309398/thr... 

0 Kudos