0๐
If you want an extent centered on point [x, y]
but also containing the extent [x1, y1, x2, y2]
of all other features I think you would need to calculate it
var halfWidth = Math.max(Math.abs(x - x1), Math.abs(x - x2));
var halfHeight = Math.max(Math.abs(y - y1), Math.abs(y - y2));
var extent = [x - halfWidth, y - halfHeight, x + halfWidth, y + halfHeight];
0๐
I think you will get an idea from the source code which was implemented in C# by me.
public static List<Coordinate> GetExtentFromCenterCoordinate(Coordinate center, double distance_km)
{
double hypotenuse_each_quardilator = Math.Sqrt(Math.Pow((distance_km / 2), 2) + Math.Pow((distance_km / 2), 2)); //Hy = Sqrt(L2 + h2)
double rad_angle = (Math.PI / 180) * 45;
double distance = hypotenuse_each_quardilator / 100;
//left-top
double x1 = center.X - distance * Math.Cos(rad_angle);
double y1 = center.Y + distance * Math.Sin(rad_angle);
//right-top
double x2 = center.X + distance * Math.Cos(rad_angle);
double y2 = center.Y + distance * Math.Sin(rad_angle);
//right-bottom
double x3 = center.X + distance * Math.Cos(rad_angle);
double y3 = center.Y - distance * Math.Sin(rad_angle);
//left-bottom
double x4 = center.X - distance * Math.Cos(rad_angle);
double y4 = center.Y - distance * Math.Sin(rad_angle);
List<Coordinate> extent_area = new List<Coordinate>();
extent_area.Add(new Coordinate(x1, y1));//left-top
extent_area.Add(new Coordinate(x2, y2));//right-top
extent_area.Add(new Coordinate(x3, y3));//right-bottom
extent_area.Add(new Coordinate(x4, y4));//left-bottom
return extent_area;
}
- [Vuejs]-Is There Any Way to Get Current Date Time With Timezone in Vue JS?
- [Vuejs]-Dynamically Display Remotely Populated Dropdown in Vue.JS
Source:stackexchange.com