UNPKG

flatgeobuf

Version:

A performant binary encoding for geographic data

2 lines 1.07 kB
import t from"lws";import{afterAll as e,beforeAll as a,describe as o,expect as r,it as s}from"vitest";import{fromFeature as i}from"./geojson/feature";import{HttpReader as n}from"./http-reader";o("http reader",()=>{let o;a(async()=>{o=await t.create({stack:["lws-range","lws-static"]})}),e(()=>{o&&o.server.close()}),s("fetches a subset of data based on bounding box",async()=>{let t=`http://localhost:${o.config.port}/test/data/UScounties.fgb`,e=await n.open(t,!1),a=[];for await(let t of e.selectBbox({minX:-106.88,minY:36.75,maxX:-101.11,maxY:41.24}))a.push(i(t.id,t.feature,e.header));r(a.length).toBe(86),r(a.slice(0,4).map(t=>`${t.properties?.NAME}, ${t.properties?.STATE}`)).toEqual(["Cheyenne, KS","Rawlins, KS","Yuma, CO","Washington, CO"])}),s("can fetch the final feature",async()=>{let t=`http://localhost:${o.config.port}/test/data/countries.fgb`,e=await n.open(t,!0);r(179).toBe(e.header.featuresCount);let a=0;for await(let t of e.selectBbox({minX:-61.2,minY:-51.85,maxX:-60,maxY:-51.25}))a++;r(a).toBe(2)})}); //# sourceMappingURL=http-reader.spec.js.map