geotoolbox
Version:
geotoolbox is GIS javascript library. It is based on d3geo, topojson and geos-wasm.
2 lines (1 loc) • 475 B
JavaScript
import{geojsonToGeosGeom as e,geosGeomToGeojson as o}from"../node_modules/geos-wasm/build/package/helpers/geos.helpers.esm.js";import{getGeos as s}from"./helpers/geosloader.js";function r(r,{bbox:t=[90,180,-90,-180]}={}){ensureGeosLoaded();const p=s();let a=JSON.parse(JSON.stringify(r));const m=e(a,p),n=p.GEOSClipByRect(m,t[3],t[2],t[1],t[0]);let l=o(n,p);return p.GEOSFree(m),p.GEOSFree(n),a.features=[{type:"Feature",properties:{},geometry:l}],a}export{r as clipbyrect};