thematic-earth
Version:
HTML-based, whole-Earth thematic maps using locally hosted data layers
2 lines • 1.07 kB
JavaScript
/* Copyright (c) 2023 Read Write Tools. Legal use subject to the Thematic Earth Software License Agreement. */
export const MIN_MAP_SCALE=1;export const MAX_MAP_SCALE=1e6;export const INITIAL_MAP_SCALE=1e4;export const EARTH_RADIUS=6371e3;export const stops=[1,2,3,4,5,6,7,8,9,10,11,12,14,16,19,22,25,28,33,38,43,50,57,66,76,87,100,115,130,150,175,200,230,270,300,350,400,460,530,600,700,800,900,1e3,1100,1200,1400,1600,1900,2200,2500,2800,3300,3800,4300,5e3,5700,6600,7600,8700,1e4,11500,13e3,15e3,17e3,2e4,23e3,27e3,31e3,35e3,4e4,46e3,53e3,61e3,71e3,81e3,93e3,1e5,107e3,123e3,141e3,163e3,187e3,215e3,25e4,285e3,328e3,375e3,433e3,5e5,575e3,66e4,76e4,87e4,1e6];export const numStops=stops.length;export function sliderToMapScale(e){return e<0?stops[0]:e>numStops-1?stops[numStops-1]:stops[e]}export function mapScaleToSlider(e){if(e<=1)return 0;if(e>1e6)return numStops-1;for(let t=1;t<numStops-1;t++){if(e<=stops[t])return e<stops[t-1]+(stops[t]-stops[t-1])/2?t-1:t}return numStops-1}export function normalizeMapScale(e){return sliderToMapScale(mapScaleToSlider(e))}