Open EMRJ opened 8 years ago
not sure I understand what you are trying to do
getPolygon() returns the geometry of one hexagon on a particular zoom level
if you want to get all hexagons contained in a specific hexagon on the next zoom level, take its code and append 0,1,2,3,4,5,6 to it
PX0072320 should contain these: PX00723200 PX00723201 PX00723202 PX00723203 ...
I want to find adjacent hexagons (7 hexagon),There are only 4 geohex were present (refer incomplete_hex)
Output:
Expected Output:
I want to fill the remaining hexagon (refer expected_output) Is there any way to achieve using x, y coordinates?
Ah, ok, this is less obvious, no API function for that.
I would try to calculate the coords of their center points based on the center of the starting hexagon and its radius. Then, call getZoneByLocation for each of them.
something like this:
for i in 0 to 5
getZoneByLocation(x0 + r*cos(i * PI/3), y0 + r*sin(i * PI/3))
@ilyabo Can you elaborate the above sample, what are all the values needs to replaced for x0, y0 and r
x0 and y0 are the lon and lat of the starting hexagon, respectively R is two times its inner radius (=the diameter) which can be calculated from the coords of the hexagon vertices:
R = 2 * midpoint(coords[0], coords[1]), midpoint(coords[3], coords[4])
where midpoint is:
function midpoint(p1, p2) {
return [ (p1[0] + p2[0])/2, (p1[1] + p2[1])/2 ];
}
@ilyabo From the above midpoint(coords[0], coords[1]), midpoint(coords[3], coords[4]) returns [80.2697759487883, 13.086934044236282] [80.27892089620485, 13.081791282653175]
It returns array, Is that the radius? Is the above is correct?
sorry it should be the distance between these two points of course
When I call getPolygon() method, it returns latitude and longitude when I convert back them into encoded value I get 4 values remaining 3 values are redundant
How to find all the polygons associated with the geohex?
e.g Geohex = "PX0072320"
Encoded values = ["PX0072320", "PX0072324", "PX0072323", "PX0072323", "PX0072312", "PX0072320", "PX0072320"]