Skip to content

Commit

Permalink
Update average edge lengths (#749)
Browse files Browse the repository at this point in the history
* update average edge lengths in restable docs

Also added a sentence on methodology

* update hard-coded avg edge length values
  • Loading branch information
mciethan committed Mar 23, 2023
1 parent a5449a8 commit 71e09dc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
16 changes: 8 additions & 8 deletions src/h3lib/lib/latLng.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ H3Error H3_EXPORT(getHexagonAreaAvgM2)(int res, double *out) {

H3Error H3_EXPORT(getHexagonEdgeLengthAvgKm)(int res, double *out) {
static const double lens[] = {
1107.712591, 418.6760055, 158.2446558, 59.81085794,
22.6063794, 8.544408276, 3.229482772, 1.220629759,
0.461354684, 0.174375668, 0.065907807, 0.024910561,
0.009415526, 0.003559893, 0.001348575, 0.000509713};
1281.256011, 483.0568391, 182.5129565, 68.97922179,
26.07175968, 9.854090990, 3.724532667, 1.406475763,
0.531414010, 0.200786148, 0.075863783, 0.028663897,
0.010830188, 0.004092010, 0.001546100, 0.000584169};
if (res < 0 || res > MAX_H3_RES) {
return E_RES_DOMAIN;
}
Expand All @@ -305,10 +305,10 @@ H3Error H3_EXPORT(getHexagonEdgeLengthAvgKm)(int res, double *out) {

H3Error H3_EXPORT(getHexagonEdgeLengthAvgM)(int res, double *out) {
static const double lens[] = {
1107712.591, 418676.0055, 158244.6558, 59810.85794,
22606.3794, 8544.408276, 3229.482772, 1220.629759,
461.3546837, 174.3756681, 65.90780749, 24.9105614,
9.415526211, 3.559893033, 1.348574562, 0.509713273};
1281256.011, 483056.8391, 182512.9565, 68979.22179,
26071.75968, 9854.090990, 3724.532667, 1406.475763,
531.4140101, 200.7861476, 75.86378287, 28.66389748,
10.83018784, 4.092010473, 1.546099657, 0.584168630};
if (res < 0 || res > MAX_H3_RES) {
return E_RES_DOMAIN;
}
Expand Down
40 changes: 18 additions & 22 deletions website/docs/library/restable.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,32 +131,28 @@ Edge lengths are computed with a **spherical** model of the earth using the
[authalic radius](https://en.wikipedia.org/wiki/Earth_radius#Authalic_radius)
given by
[WGS84](https://en.wikipedia.org/wiki/WGS84)/[EPSG:4326](https://epsg.io/4326).
:::

:::danger
These values are hard coded into the `getHexagonEdgeLengthAvgKm` function and
related functions in the H3 library. There are [known issues](https://github.com/uber/h3/issues/666)
with these numbers and they are expected to be updated later.
Average edge lengths were calculated exactly for resolutions 0 through 6 and
extrapolated for finer resolutions.
:::

| Res | Average edge length (Km) |
|----:|-------------------------:|
| 0 | 1107.712591 |
| 1 | 418.6760055 |
| 2 | 158.2446558 |
| 3 | 59.81085794 |
| 4 | 22.6063794 |
| 5 | 8.544408276 |
| 6 | 3.229482772 |
| 7 | 1.220629759 |
| 8 | 0.461354684 |
| 9 | 0.174375668 |
| 10 | 0.065907807 |
| 11 | 0.024910561 |
| 12 | 0.009415526 |
| 13 | 0.003559893 |
| 14 | 0.001348575 |
| 15 | 0.000509713 |
| 0 | 1281.256011 |
| 1 | 483.0568391 |
| 2 | 182.5129565 |
| 3 | 68.97922179 |
| 4 | 26.07175968 |
| 5 | 9.854090990 |
| 6 | 3.724532667 |
| 7 | 1.406475763 |
| 8 | 0.531414010 |
| 9 | 0.200786148 |
| 10 | 0.075863783 |
| 11 | 0.028663897 |
| 12 | 0.010830188 |
| 13 | 0.004092010 |
| 14 | 0.001546100 |
| 15 | 0.000584169 |

## Appendix: Methodology

Expand Down

0 comments on commit 71e09dc

Please sign in to comment.