UNPKG

flatgeobuf

Version:

A performant binary encoding for geographic data

2 lines 1.2 kB
import{magicbytes as e}from"../constants.js";import{buildFeature as t}from"../generic/feature.js";import{buildHeader as r,deserialize as i,deserializeFiltered as l,deserializeStream as n,mapColumn as o}from"../generic/featurecollection.js";import{inferGeometryType as s}from"../generic/header.js";import{fromFeature as a}from"./feature.js";import{parseGC as m,parseGeometry as u}from"./geometry.js";export function serialize(i,l=0){var n;let a,p,f=(a=(n=i).features[0].properties,p=null,a&&(p=Object.keys(a).map(e=>o(a,e))),{geometryType:s(n.features),columns:p,envelope:null,featuresCount:n.features.length,indexNodeSize:0,crs:null,title:null,description:null,metadata:null}),c=r(f,l),g=i.features.map(e=>t("GeometryCollection"===e.geometry.type?m(e.geometry):u(e.geometry),e.properties,f)),d=g.map(e=>e.length).reduce((e,t)=>e+t),y=new Uint8Array(e.length+c.length+d);y.set(c,e.length);let h=e.length+c.length;for(let e of g)y.set(e,h),h+=e.length;return y.set(e),y}export async function*deserialize(e,t,r){yield*i(e,a,t,r)}export function deserializeStream(e,t){return n(e,a,t)}export function deserializeFiltered(e,t,r,i=!1,n={}){return l(e,t,a,r,i,n)} //# sourceMappingURL=featurecollection.js.map