Reputation: 1
this is my problem:
I need to determine the correct coordinates(Latitude,Longitude) of a hexagon/polygon. I have as inputs:
The steps taken:
Given point is translated with the length of the radius, obtaining the first point: lat = lat + radius
New coordinates are obtained (rad is the angle theta in radians)
result.x = Math.cos(rad) * lat + Math.sin(rad) * lon;
result.y = Math.cos(rad) * lon - Math.sin(rad) * lat ;
Problem: Setting the radius to 1 returns me a huge result, a way too bigger hexagon than i want (in the sense that the are contained is almost the entire globe :( ), can anyone englighten me with why this happens and how could i fix it?
and here as you can see, for the input -71.24 43.06 I'm getting a vertice with coordinates 2 83, which is huge
Upvotes: 0
Views: 576
Reputation: 11
I needed that as well on a flutter project, after some research I found out turf.js destination method
By using it, you can get the 6 points of the hexagon around a center point, based on a certain radius:
Point center = Point(coordinates: Position(latitude, longitude)); // Your center point
Point p1 = destination(center, radius, 0, Unit.meters); // top
Point p2 = destination(center, radius, 60, Unit.meters); // top left
Point p3 = destination(center, radius, 120, Unit.meters); // bottom left
Point p4 = destination(center, radius, 180, Unit.meters); // bottom
Point p5 = destination(center, radius, 240, Unit.meters); // bottom right
Point p6 = destination(center, radius, 300, Unit.meters); // top right
Not sure about this, but Turf seems to be porting to Java as well here
Upvotes: 0