Published
Edited
Aug 15, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
placesH3 = ({
// https://goo.gl/maps/9Df4KotXbhyRm34Q7 ⟵ the building has the shape of an octagon
genevaTheatreCiteBleue: h3.geoToH3( 46.18687624923539, 6.1587771264109294, res),
// https://goo.gl/maps/sqXTUmoG3f1RVDwLA
genevaPontCEVA: h3.geoToH3(46.18669723553891, 6.152944760789058, res),
// https://goo.gl/maps/1X2j3z6Jhca3R8AP8
genevaTourChampel: h3.geoToH3(46.1876405549345, 6.152107936977695, res),
// https://goo.gl/maps/oFsie7hHguQpEQwL8
genevaTCU: h3.geoToH3(46.185601417641635, 6.158754606655257, res),
// https://goo.gl/maps/RWJvZMfXqpdcg5Qt8 ⟶
genevaParcFalaises: h3.geoToH3(46.189051772509536, 6.163180109051049, res),
// https://goo.gl/maps/RyeEa5CaZjCMyD6p8 ⟶
genevaCentreSportifVessy: h3.geoToH3(46.185450129448576, 6.167344654787411, res),
// https://goo.gl/maps/fUWDLbKVpXGnJ58NA ⟶
genevaBergesVessy: h3.geoToH3(46.17938657393315, 6.169982852272059, res),
// https://goo.gl/maps/uLEeUiDeLV8i8TAFA ⟶
genevaCimetiereCarouge: h3.geoToH3(46.18197877945335, 6.145689115998625, res)
})
Insert cell
placesH3AsList = Object.values(placesH3)
Insert cell
Insert cell
boundingHexes = removeDuplicates(placesH3AsList.map( h3Index => h3.h3ToParent( h3Index, 0)))
Insert cell
Insert cell
Insert cell
placesGeoBoundaries = placesH3AsList.map(
(place) => h3.h3ToGeoBoundary(place,false))
Insert cell
Insert cell
placesGeoBoundingBox = {
// This could of course be optimized to avoid unnecessary comparisons
// and null coalescing evals at every step of the loop – but we'll
// leave it that way, for the sake of simplicity and readibility
let minLat, minLng, maxLat, maxLng;
for( const place of placesGeoBoundaries.flat()) {
const [lat,lng] = place;
minLng = Math.min( lng, minLng ?? +Infinity);
maxLng = Math.max( lng, maxLng ?? -Infinity);
minLat = Math.min( lat, minLat ?? +Infinity);
maxLat = Math.max( lat, maxLat ?? -Infinity);
}
return { minLng, minLat, maxLng, maxLat };
}
Insert cell
Insert cell
topLeft = [ placesGeoBoundingBox.minLng, placesGeoBoundingBox.maxLat ]
Insert cell
topRight = [ placesGeoBoundingBox.maxLng, placesGeoBoundingBox.maxLat ]
Insert cell
bottomLeft = [ placesGeoBoundingBox.minLng, placesGeoBoundingBox.minLat ]
Insert cell
bottomRight = [ placesGeoBoundingBox.maxLng, placesGeoBoundingBox.minLat ]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more