Public
Edited
Sep 22, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
centralCambridgeCoords = [
[544748.5367636156, 258372.49178149243, 9.61],
[544750.8907704452, 258365.94195330486, 9.61]
]
Insert cell
// Create a context for a given definition
ctx = new Geodesy(definition)
Insert cell
cambridgeWebMercCoords = {
return ctx.forward(centralCambridgeCoords);
}
Insert cell
roundTrip = {
return ctx.roundTrip(centralCambridgeCoords);
}
Insert cell
Insert cell
hydeParkWgs84 = [51.505, -0.09]
Insert cell
wgs84WebmercCtx = new Geodesy("webmerc lat_0=0 lon_0=0 x_0=0 y_0=0 ellps=WGS84")
Insert cell
hydeParkWebmercCoords = wgs84WebmercCtx.forward([hydeParkWgs84.map(c => c * Math.PI/180)])
Insert cell
Insert cell
hydeParkRoundTripBackToWgs84 = wgs84WebmercCtx.inverse(hydeParkWebmercCoords)[0].map(c => c * 180/Math.PI)
Insert cell
Insert cell
geodesyModule = {
const geodesyJs = await import(
"https://unpkg.com/geodesy-wasm@0.2.0/esm/index.js"
);

// When using geodesy-wasm natively we need to import the wasm module separately so we can instantiate the Webassembly
const wasmModule = await import(
"https://unpkg.com/geodesy-wasm@0.2.0/esm/geodesy-wasm.js"
);
// Need to await the default export first to initialize the WebAssembly code
const { memory } = await wasmModule.default();
geodesyJs.GeodesyWasm.set_panic_hook();

return [geodesyJs, memory];
}
Insert cell
Geodesy = {
return geodesyModule[0].Geodesy;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more