Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@geoarrow/deck.gl-layers

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geoarrow/deck.gl-layers - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

dist/earcut.d.ts

2

dist/dist.umd.js

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@deck.gl/core/typed"),require("@deck.gl/layers/typed"),require("apache-arrow")):"function"==typeof define&&define.amd?define(["exports","@deck.gl/core/typed","@deck.gl/layers/typed","apache-arrow"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self)["@geoarrow/deck"]=t["@geoarrow/deck"]||{},t["@geoarrow/deck"]["gl-geoarrow"]={}),t.deck,t.deck,t.arrow)}(this,(function(t,e,i,s){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var o,n=r(s);function p(t){const{props:i,propName:s,propInput:r,chunkIdx:o,geomCoordOffsets:p}=t;if(void 0!==r)if(r instanceof n.Vector){const t=r.data[o];if(n.DataType.isFixedSizeList(t)){e.assert(1===t.children.length);let r=t.children[0].values;p&&(r=a(r,t.type.listSize,p)),i.data.attributes[s]={value:r,size:t.type.listSize,normalized:!0}}else if(n.DataType.isFloat(t)){let e=t.values;p&&(e=a(e,1,p)),i.data.attributes[s]={value:e,size:1}}}else i[s]=r}function a(t,e,i){const s=i[i.length-1],r=new t.constructor(s*e);for(let s=0;s<i.length-1;s++){const o=i[s],n=i[s+1];for(let i=o;i<n;i++)for(let o=0;o<e;o++)r[i*e+o]=t[s*e+o]}return r}function l(t,e){const i=function(t,e,i){const s=t.fields.findIndex((t=>t.name===i||t.metadata.get("ARROW:extension:name")===e));return-1!==s?s:null}(t.schema,e);return null===i?null:t.getChildAt(i)}function d(t,i){for(const s of i)e.assert(t.batches.length===s.data.length);for(const s of i)for(let i=0;i<t.batches.length;i++)e.assert(t.batches[i].numRows===s.data[i].length)}function h(t){e.assert(n.DataType.isFixedSizeList(t.type)),e.assert(3===t.type.listSize||4===t.type.listSize),e.assert(n.DataType.isInt(t.type.children[0])),e.assert(8===t.type.children[0].type.bitWidth)}function u(t){return!!n.DataType.isFixedSizeList(t.type)&&((2===t.type.listSize||3===t.type.listSize)&&!!n.DataType.isFloat(t.type.children[0]))}function c(t){return!!n.DataType.isList(t.type)&&!!u(t.getChildAt(0))}function g(t){return!!n.DataType.isList(t.type)&&!!c(t.getChildAt(0))}function f(t){return e.assert(n.DataType.isFixedSizeList(t)),e.assert(2===t.listSize||3===t.listSize),e.assert(n.DataType.isFloat(t.children[0])),!0}function y(t){return e.assert(n.DataType.isList(t)),f(t.children[0].type),!0}function m(t){return e.assert(n.DataType.isList(t)),y(t.children[0].type),!0}function L(t){return t.children[0]}function C(t){return t.children[0]}function x(t){return t.children[0]}function v(t){return t.children[0]}function P(t){return t.children[0]}function w(t){const e=t.valueOffsets,i=v(t).valueOffsets,s=new Int32Array(e.length);for(let t=0;t<s.length;++t)s[t]=i[e[t]];return s}function I(t){const e=t.valueOffsets,i=x(t).valueOffsets,s=new Int32Array(e.length);for(let t=0;t<s.length;++t)s[t]=i[e[t]];return s}function b(t){const e=P(t),i=x(e),s=t.valueOffsets,r=e.valueOffsets,o=i.valueOffsets,n=new Int32Array(s.length);for(let t=0;t<n.length;++t)n[t]=o[r[s[t]]];return n}!function(t){t.POINT="geoarrow.point",t.LINESTRING="geoarrow.linestring",t.POLYGON="geoarrow.polygon",t.MULTIPOINT="geoarrow.multipoint",t.MULTILINESTRING="geoarrow.multilinestring",t.MULTIPOLYGON="geoarrow.multipolygon"}(o||(o={}));const S={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:"open",_validate:!0,getColor:{type:"accessor",value:[0,0,0,255]},getWidth:{type:"accessor",value:1}};class _ extends e.CompositeLayer{static defaultProps=S;static layerName="GeoArrowPathLayer";renderLayers(){const{data:t}=this.props,e=l(t,o.LINESTRING);if(null!==e)return this._renderLayersLineString(e);const i=l(t,o.MULTILINESTRING);if(null!==i)return this._renderLayersMultiLineString(i);const s=this.props.getPath;if(c(s))return this._renderLayersLineString(s);if(r=s,n.DataType.isList(r.type)&&c(r.getChildAt(0)))return this._renderLayersMultiLineString(s);var r;throw new Error("geometryColumn not LineString or MultiLineString")}_renderLayersLineString(t){const{data:e}=this.props;if(this.props._validate){const i=[t];for(const t of[this.props.getColor,this.props.getWidth])t instanceof n.Vector&&i.push(t);y(t.type),d(e,i),this.props.getColor instanceof n.Vector&&h(this.props.getColor)}const s=[];for(let r=0;r<e.batches.length;r++){const e=t.data[r],o=e.valueOffsets,n=C(e),a=n.type.listSize,l=L(n).values,d={id:`${this.props.id}-geoarrow-path-${r}`,widthUnits:this.props.widthUnits,widthScale:this.props.widthScale,widthMinPixels:this.props.widthMinPixels,widthMaxPixels:this.props.widthMaxPixels,jointRounded:this.props.jointRounded,capRounded:this.props.capRounded,miterLimit:this.props.miterLimit,billboard:this.props.billboard,_pathType:this.props._pathType,data:{length:e.length,startIndices:o,attributes:{getPath:{value:l,size:a}}}};p({props:d,propName:"getColor",propInput:this.props.getColor,chunkIdx:r,geomCoordOffsets:o}),p({props:d,propName:"getWidth",propInput:this.props.getWidth,chunkIdx:r,geomCoordOffsets:o});const h=new i.PathLayer(d);s.push(h)}return s}_renderLayersMultiLineString(t){const{data:s}=this.props;if(this.props._validate){const i=[t];for(const t of[this.props.getColor,this.props.getWidth])t instanceof n.Vector&&i.push(t);r=t.type,e.assert(n.DataType.isList(r)),y(r.children[0].type),d(s,i),this.props.getColor instanceof n.Vector&&h(this.props.getColor)}var r;const o=[];for(let e=0;e<s.batches.length;e++){const s=t.data[e],r=v(s),n=C(r),a=L(n),l=r.valueOffsets,d=n.type.listSize,h=a.values,u=w(s),c={id:`${this.props.id}-geoarrow-path-${e}`,widthUnits:this.props.widthUnits,widthScale:this.props.widthScale,widthMinPixels:this.props.widthMinPixels,widthMaxPixels:this.props.widthMaxPixels,jointRounded:this.props.jointRounded,capRounded:this.props.capRounded,miterLimit:this.props.miterLimit,billboard:this.props.billboard,_pathType:this.props._pathType,data:{length:r.length,startIndices:l,attributes:{getPath:{value:h,size:d}}}};p({props:c,propName:"getColor",propInput:this.props.getColor,chunkIdx:e,geomCoordOffsets:u}),p({props:c,propName:"getWidth",propInput:this.props.getWidth,chunkIdx:e,geomCoordOffsets:u});const g=new i.PathLayer(c);o.push(g)}return o}}const M=[0,0,0,255],O={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,_validate:!0,getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:M},getLineColor:{type:"accessor",value:M},getLineWidth:{type:"accessor",value:1}};class N extends e.CompositeLayer{static defaultProps=O;static layerName="GeoArrowScatterplotLayer";renderLayers(){const{data:t}=this.props,e=l(t,o.POINT);if(null!==e)return this._renderLayersPoint(e);const i=l(t,o.MULTIPOINT);if(null!==i)return this._renderLayersMultiPoint(i);const s=this.props.getPosition;if(u(s))return this._renderLayersPoint(s);if(r=s,n.DataType.isList(r.type)&&u(r.getChildAt(0)))return this._renderLayersMultiPoint(s);var r;throw new Error("geometryColumn not point or multipoint")}_renderLayersPoint(t){const{data:e}=this.props;if(this.props._validate){const i=[t];for(const t of[this.props.getRadius,this.props.getFillColor,this.props.getLineColor,this.props.getLineWidth])t instanceof n.Vector&&i.push(t);f(t.type),d(e,i),this.props.getFillColor instanceof n.Vector&&h(this.props.getFillColor),this.props.getLineColor instanceof n.Vector&&h(this.props.getLineColor)}const s=[];for(let r=0;r<e.batches.length;r++){const e=t.data[r],o=e.children[0].values,n={id:`${this.props.id}-geoarrow-scatterplot-${r}`,radiusUnits:this.props.radiusUnits,radiusScale:this.props.radiusScale,radiusMinPixels:this.props.radiusMinPixels,radiusMaxPixels:this.props.radiusMaxPixels,lineWidthUnits:this.props.lineWidthUnits,lineWidthScale:this.props.lineWidthScale,lineWidthMinPixels:this.props.lineWidthMinPixels,lineWidthMaxPixels:this.props.lineWidthMaxPixels,stroked:this.props.stroked,filled:this.props.filled,billboard:this.props.billboard,antialiasing:this.props.antialiasing,data:{length:e.length,attributes:{getPosition:{value:o,size:e.type.listSize}}}};p({props:n,propName:"getRadius",propInput:this.props.getRadius,chunkIdx:r}),p({props:n,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:r}),p({props:n,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:r}),p({props:n,propName:"getLineWidth",propInput:this.props.getLineWidth,chunkIdx:r});const a=new i.ScatterplotLayer(n);s.push(a)}return s}_renderLayersMultiPoint(t){const{data:s}=this.props;if(this.props._validate){const i=[t];for(const t of[this.props.getRadius,this.props.getFillColor,this.props.getLineColor,this.props.getLineWidth])t instanceof n.Vector&&i.push(t);r=t.type,e.assert(n.DataType.isList(r)),f(r.children[0].type),d(s,i),this.props.getFillColor instanceof n.Vector&&h(this.props.getFillColor),this.props.getLineColor instanceof n.Vector&&h(this.props.getLineColor)}var r;const o=[];for(let e=0;e<s.batches.length;e++){const s=t.data[e],r=s.children[0],n=s.valueOffsets,a=L(r).values,l={id:`${this.props.id}-geoarrow-scatterplot-${e}`,radiusUnits:this.props.radiusUnits,radiusScale:this.props.radiusScale,radiusMinPixels:this.props.radiusMinPixels,radiusMaxPixels:this.props.radiusMaxPixels,lineWidthUnits:this.props.lineWidthUnits,lineWidthScale:this.props.lineWidthScale,lineWidthMinPixels:this.props.lineWidthMinPixels,lineWidthMaxPixels:this.props.lineWidthMaxPixels,stroked:this.props.stroked,filled:this.props.filled,billboard:this.props.billboard,antialiasing:this.props.antialiasing,data:{length:r.length,attributes:{getPosition:{value:a,size:r.type.listSize}}}};p({props:l,propName:"getRadius",propInput:this.props.getRadius,chunkIdx:e,geomCoordOffsets:n}),p({props:l,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:e,geomCoordOffsets:n}),p({props:l,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:e,geomCoordOffsets:n}),p({props:l,propName:"getLineWidth",propInput:this.props.getLineWidth,chunkIdx:e,geomCoordOffsets:n});const d=new i.ScatterplotLayer(l);o.push(d)}return o}}const T=[0,0,0,255],W={filled:!0,extruded:!1,wireframe:!1,_normalize:!1,_windingOrder:"CCW",_full3d:!1,_validate:!0,elevationScale:{type:"number",min:0,value:1},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:T},getLineColor:{type:"accessor",value:T},material:!0};class k extends e.CompositeLayer{static defaultProps=W;static layerName="GeoArrowSolidPolygonLayer";renderLayers(){const{data:t}=this.props,e=l(t,o.POLYGON);if(null!==e)return this._renderLayersPolygon(e);const i=l(t,o.MULTIPOLYGON);if(null!==i)return this._renderLayersMultiPolygon(i);const s=this.props.getPolygon;if(g(s))return this._renderLayersPolygon(s);if(r=s,n.DataType.isList(r.type)&&g(r.getChildAt(0)))return this._renderLayersMultiPolygon(s);var r;throw new Error("geometryColumn not Polygon or MultiPolygon")}_renderLayersPolygon(t){const{data:e}=this.props;if(this.props._validate){const i=[t];for(const t of[this.props.getElevation,this.props.getFillColor,this.props.getLineColor])t instanceof n.Vector&&i.push(t);m(t.type),d(e,i),this.props.getFillColor instanceof n.Vector&&h(this.props.getFillColor),this.props.getLineColor instanceof n.Vector&&h(this.props.getLineColor)}const s=[];for(let r=0;r<e.batches.length;r++){const e=t.data[r],o=C(x(e)),n=L(o),a=o.type.listSize,l=n.values,d=I(e),h={id:`${this.props.id}-geoarrow-point-${r}`,filled:this.props.filled,extruded:this.props.extruded,wireframe:this.props.wireframe,_normalize:this.props._normalize,_windingOrder:this.props._windingOrder,_full3d:this.props._full3d,elevationScale:this.props.elevationScale,material:this.props.material,data:{length:e.length,startIndices:d,attributes:{getPolygon:{value:l,size:a}}}};p({props:h,propName:"getElevation",propInput:this.props.getElevation,chunkIdx:r,geomCoordOffsets:d}),p({props:h,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:r,geomCoordOffsets:d}),p({props:h,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:r,geomCoordOffsets:d});const u=new i.SolidPolygonLayer(h);s.push(u)}return s}_renderLayersMultiPolygon(t){const{data:s}=this.props;if(this.props._validate){const i=[t];for(const t of[this.props.getElevation,this.props.getFillColor,this.props.getLineColor])t instanceof n.Vector&&i.push(t);r=t.type,e.assert(n.DataType.isList(r)),m(r.children[0].type),d(s,i),this.props.getFillColor instanceof n.Vector&&h(this.props.getFillColor),this.props.getLineColor instanceof n.Vector&&h(this.props.getLineColor)}var r;const o=[];for(let e=0;e<s.batches.length;e++){const s=t.data[e],r=P(s),n=C(x(r)),a=L(n),l=n.type.listSize,d=r.valueOffsets,h=a.values,u=b(s),c={id:`${this.props.id}-geoarrow-point-${e}`,filled:this.props.filled,extruded:this.props.extruded,wireframe:this.props.wireframe,_normalize:this.props._normalize,_windingOrder:this.props._windingOrder,_full3d:this.props._full3d,elevationScale:this.props.elevationScale,material:this.props.material,data:{length:r.length,startIndices:d,attributes:{getPolygon:{value:h,size:l}}}};p({props:c,propName:"getElevation",propInput:this.props.getElevation,chunkIdx:e,geomCoordOffsets:u}),p({props:c,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:e,geomCoordOffsets:u}),p({props:c,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:e,geomCoordOffsets:u});const g=new i.SolidPolygonLayer(c);o.push(g)}return o}}t.GeoArrowPathLayer=_,t.GeoArrowScatterplotLayer=N,t.GeoArrowSolidPolygonLayer=k}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@deck.gl/core/typed"),require("@deck.gl/layers/typed"),require("apache-arrow"),require("@math.gl/polygon")):"function"==typeof define&&define.amd?define(["exports","@deck.gl/core/typed","@deck.gl/layers/typed","apache-arrow","@math.gl/polygon"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self)["@geoarrow/deck"]=t["@geoarrow/deck"]||{},t["@geoarrow/deck"]["gl-geoarrow"]={}),t.deck,t.deck,t.arrow,t.polygon)}(this,(function(t,e,s,r,o){"use strict";function i(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}})),e.default=t,Object.freeze(e)}var n,p=i(r);function a(t){const{props:s,propName:r,propInput:o,chunkIdx:i,geomCoordOffsets:n}=t;if(void 0!==o)if(o instanceof p.Vector){const t=o.data[i];if(p.DataType.isFixedSizeList(t)){e.assert(1===t.children.length);let o=t.children[0].values;n&&(o=l(o,t.type.listSize,n)),s.data.attributes[r]={value:o,size:t.type.listSize,normalized:!0}}else if(p.DataType.isFloat(t)){let e=t.values;n&&(e=l(e,1,n)),s.data.attributes[r]={value:e,size:1}}}else s[r]=o}function l(t,e,s){const r=s[s.length-1],o=new t.constructor(r*e);for(let r=0;r<s.length-1;r++){const i=s[r],n=s[r+1];for(let s=i;s<n;s++)for(let i=0;i<e;i++)o[s*e+i]=t[r*e+i]}return o}function d(t,e){const s=function(t,e,s){const r=t.fields.findIndex((t=>t.name===s||t.metadata.get("ARROW:extension:name")===e));return-1!==r?r:null}(t.schema,e);return null===s?null:t.getChildAt(s)}function h(t,s){for(const r of s)e.assert(t.batches.length===r.data.length);for(const r of s)for(let s=0;s<t.batches.length;s++)e.assert(t.batches[s].numRows===r.data[s].length)}function c(t){e.assert(p.DataType.isFixedSizeList(t.type)),e.assert(3===t.type.listSize||4===t.type.listSize),e.assert(p.DataType.isInt(t.type.children[0])),e.assert(8===t.type.children[0].type.bitWidth)}function u(t){return!!p.DataType.isFixedSizeList(t.type)&&((2===t.type.listSize||3===t.type.listSize)&&!!p.DataType.isFloat(t.type.children[0]))}function g(t){return!!p.DataType.isList(t.type)&&!!u(t.getChildAt(0))}function f(t){return!!p.DataType.isList(t.type)&&!!g(t.getChildAt(0))}function y(t){return e.assert(p.DataType.isFixedSizeList(t)),e.assert(2===t.listSize||3===t.listSize),e.assert(p.DataType.isFloat(t.children[0])),!0}function m(t){return e.assert(p.DataType.isList(t)),y(t.children[0].type),!0}function L(t){return e.assert(p.DataType.isList(t)),m(t.children[0].type),!0}function x(t){return t.children[0]}function v(t){return t.children[0]}function C(t){return t.children[0]}function P(t){return t.children[0]}function I(t){return t.children[0]}function w(t){const e=t.valueOffsets,s=P(t).valueOffsets,r=new Int32Array(e.length);for(let t=0;t<r.length;++t)r[t]=s[e[t]];return r}function b(t){const e=t.valueOffsets,s=C(t).valueOffsets,r=new Int32Array(e.length);for(let t=0;t<r.length;++t)r[t]=s[e[t]];return r}function S(t){const e=I(t),s=C(e),r=t.valueOffsets,o=e.valueOffsets,i=s.valueOffsets,n=new Int32Array(r.length);for(let t=0;t<n.length;++t)n[t]=i[o[r[t]]];return n}function O(t){const e=t[t.length-1],s=new(t.length<Math.pow(2,8)?Uint8Array:t.length<Math.pow(2,16)?Uint16Array:Uint32Array)(e);for(let e=0;e<t.length-1;e++){const r=t[e],o=t[e+1];for(let t=r;t<o;t++)s[t]=e}return s}!function(t){t.POINT="geoarrow.point",t.LINESTRING="geoarrow.linestring",t.POLYGON="geoarrow.polygon",t.MULTIPOINT="geoarrow.multipoint",t.MULTILINESTRING="geoarrow.multilinestring",t.MULTIPOLYGON="geoarrow.multipolygon"}(n||(n={}));const _={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:"open",_validate:!0,getColor:{type:"accessor",value:[0,0,0,255]},getWidth:{type:"accessor",value:1}};class M extends e.CompositeLayer{static defaultProps=_;static layerName="GeoArrowPathLayer";getPickingInfo({info:t,sourceLayer:e}){const{data:s}=this.props;let r=t.index;e.props.invertedGeomOffsets&&(r=e.props.invertedGeomOffsets[r]);const o=e.props.recordBatchIdx,i=s.batches[o].get(r);return r+=s._offsets[o],{...t,index:r,object:i}}renderLayers(){const{data:t}=this.props,e=d(t,n.LINESTRING);if(null!==e)return this._renderLayersLineString(e);const s=d(t,n.MULTILINESTRING);if(null!==s)return this._renderLayersMultiLineString(s);const r=this.props.getPath;if(g(r))return this._renderLayersLineString(r);if(o=r,p.DataType.isList(o.type)&&g(o.getChildAt(0)))return this._renderLayersMultiLineString(r);var o;throw new Error("geometryColumn not LineString or MultiLineString")}_renderLayersLineString(t){const{data:e}=this.props;if(this.props._validate){const s=[t];for(const t of[this.props.getColor,this.props.getWidth])t instanceof p.Vector&&s.push(t);m(t.type),h(e,s),this.props.getColor instanceof p.Vector&&c(this.props.getColor)}const r=[];for(let o=0;o<e.batches.length;o++){const e=t.data[o],i=e.valueOffsets,n=v(e),p=n.type.listSize,l=x(n).values,d={recordBatchIdx:o,id:`${this.props.id}-geoarrow-path-${o}`,widthUnits:this.props.widthUnits,widthScale:this.props.widthScale,widthMinPixels:this.props.widthMinPixels,widthMaxPixels:this.props.widthMaxPixels,jointRounded:this.props.jointRounded,capRounded:this.props.capRounded,miterLimit:this.props.miterLimit,billboard:this.props.billboard,_pathType:this.props._pathType,data:{length:e.length,startIndices:i,attributes:{getPath:{value:l,size:p}}}};a({props:d,propName:"getColor",propInput:this.props.getColor,chunkIdx:o,geomCoordOffsets:i}),a({props:d,propName:"getWidth",propInput:this.props.getWidth,chunkIdx:o,geomCoordOffsets:i});const h=new s.PathLayer(this.getSubLayerProps(d));r.push(h)}return r}_renderLayersMultiLineString(t){const{data:r}=this.props;if(this.props._validate){const s=[t];for(const t of[this.props.getColor,this.props.getWidth])t instanceof p.Vector&&s.push(t);o=t.type,e.assert(p.DataType.isList(o)),m(o.children[0].type),h(r,s),this.props.getColor instanceof p.Vector&&c(this.props.getColor)}var o;const i=[];for(let e=0;e<r.batches.length;e++){const r=t.data[e],o=P(r),n=v(o),p=x(n),l=r.valueOffsets,d=o.valueOffsets,h=n.type.listSize,c=p.values,u=w(r),g={recordBatchIdx:e,invertedGeomOffsets:O(l),id:`${this.props.id}-geoarrow-path-${e}`,widthUnits:this.props.widthUnits,widthScale:this.props.widthScale,widthMinPixels:this.props.widthMinPixels,widthMaxPixels:this.props.widthMaxPixels,jointRounded:this.props.jointRounded,capRounded:this.props.capRounded,miterLimit:this.props.miterLimit,billboard:this.props.billboard,_pathType:this.props._pathType,data:{length:o.length,startIndices:d,attributes:{getPath:{value:c,size:h}}}};a({props:g,propName:"getColor",propInput:this.props.getColor,chunkIdx:e,geomCoordOffsets:u}),a({props:g,propName:"getWidth",propInput:this.props.getWidth,chunkIdx:e,geomCoordOffsets:u});const f=new s.PathLayer(this.getSubLayerProps(g));i.push(f)}return i}}const N=[0,0,0,255],T={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,_validate:!0,getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:N},getLineColor:{type:"accessor",value:N},getLineWidth:{type:"accessor",value:1}};class k extends e.CompositeLayer{static defaultProps=T;static layerName="GeoArrowScatterplotLayer";getPickingInfo({info:t,sourceLayer:e}){const{data:s}=this.props;let r=t.index;e.props.invertedGeomOffsets&&(r=e.props.invertedGeomOffsets[r]);const o=e.props.recordBatchIdx,i=s.batches[o].get(r);return r+=s._offsets[o],{...t,index:r,object:i}}renderLayers(){const{data:t}=this.props,e=d(t,n.POINT);if(null!==e)return this._renderLayersPoint(e);const s=d(t,n.MULTIPOINT);if(null!==s)return this._renderLayersMultiPoint(s);const r=this.props.getPosition;if(u(r))return this._renderLayersPoint(r);if(o=r,p.DataType.isList(o.type)&&u(o.getChildAt(0)))return this._renderLayersMultiPoint(r);var o;throw new Error("geometryColumn not point or multipoint")}_renderLayersPoint(t){const{data:e}=this.props;if(this.props._validate){const s=[t];for(const t of[this.props.getRadius,this.props.getFillColor,this.props.getLineColor,this.props.getLineWidth])t instanceof p.Vector&&s.push(t);y(t.type),h(e,s),this.props.getFillColor instanceof p.Vector&&c(this.props.getFillColor),this.props.getLineColor instanceof p.Vector&&c(this.props.getLineColor)}const r=[];for(let o=0;o<e.batches.length;o++){const e=t.data[o],i=e.children[0].values,n={recordBatchIdx:o,id:`${this.props.id}-geoarrow-scatterplot-${o}`,radiusUnits:this.props.radiusUnits,radiusScale:this.props.radiusScale,radiusMinPixels:this.props.radiusMinPixels,radiusMaxPixels:this.props.radiusMaxPixels,lineWidthUnits:this.props.lineWidthUnits,lineWidthScale:this.props.lineWidthScale,lineWidthMinPixels:this.props.lineWidthMinPixels,lineWidthMaxPixels:this.props.lineWidthMaxPixels,stroked:this.props.stroked,filled:this.props.filled,billboard:this.props.billboard,antialiasing:this.props.antialiasing,data:{length:e.length,attributes:{getPosition:{value:i,size:e.type.listSize}}}};a({props:n,propName:"getRadius",propInput:this.props.getRadius,chunkIdx:o}),a({props:n,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:o}),a({props:n,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:o}),a({props:n,propName:"getLineWidth",propInput:this.props.getLineWidth,chunkIdx:o});const p=new s.ScatterplotLayer(this.getSubLayerProps(n));r.push(p)}return r}_renderLayersMultiPoint(t){const{data:r}=this.props;if(this.props._validate){const s=[t];for(const t of[this.props.getRadius,this.props.getFillColor,this.props.getLineColor,this.props.getLineWidth])t instanceof p.Vector&&s.push(t);o=t.type,e.assert(p.DataType.isList(o)),y(o.children[0].type),h(r,s),this.props.getFillColor instanceof p.Vector&&c(this.props.getFillColor),this.props.getLineColor instanceof p.Vector&&c(this.props.getLineColor)}var o;const i=[];for(let e=0;e<r.batches.length;e++){const r=t.data[e],o=r.children[0],n=r.valueOffsets,p=x(o).values,l={recordBatchIdx:e,invertedGeomOffsets:O(n),id:`${this.props.id}-geoarrow-scatterplot-${e}`,radiusUnits:this.props.radiusUnits,radiusScale:this.props.radiusScale,radiusMinPixels:this.props.radiusMinPixels,radiusMaxPixels:this.props.radiusMaxPixels,lineWidthUnits:this.props.lineWidthUnits,lineWidthScale:this.props.lineWidthScale,lineWidthMinPixels:this.props.lineWidthMinPixels,lineWidthMaxPixels:this.props.lineWidthMaxPixels,stroked:this.props.stroked,filled:this.props.filled,billboard:this.props.billboard,antialiasing:this.props.antialiasing,data:{length:o.length,attributes:{getPosition:{value:p,size:o.type.listSize}}}};a({props:l,propName:"getRadius",propInput:this.props.getRadius,chunkIdx:e,geomCoordOffsets:n}),a({props:l,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:e,geomCoordOffsets:n}),a({props:l,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:e,geomCoordOffsets:n}),a({props:l,propName:"getLineWidth",propInput:this.props.getLineWidth,chunkIdx:e,geomCoordOffsets:n});const d=new s.ScatterplotLayer(this.getSubLayerProps(l));i.push(d)}return i}}function W(t){const e=[];let s=0;for(let r=0;r<t.length;r++){const o=z(t,r);e.push(o),s+=o.length}const r=new Uint32Array(s);let o=0;for(const t of e)for(const e of t)r[o]=e,o+=1;return r}function z(t,e){const s=t.valueOffsets,r=C(t),i=r.valueOffsets,n=v(r),p=n.type.listSize,a=x(n),l=s[e],d=s[e+1],h=i[l],c=i[d],u=a.values.subarray(h*p,c*p),g=i[l],f=[];for(let t=l+1;t<d;t++)f.push(i[t]-g);const y=o.earcut(u,f,p);for(let t=0;t<y.length;t++)y[t]+=g;return y}const F=[0,0,0,255],R={filled:!0,extruded:!1,wireframe:!1,_normalize:!1,_windingOrder:"CCW",_full3d:!1,_validate:!0,elevationScale:{type:"number",min:0,value:1},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:F},getLineColor:{type:"accessor",value:F},material:!0};class A extends e.CompositeLayer{static defaultProps=R;static layerName="GeoArrowSolidPolygonLayer";getPickingInfo({info:t,sourceLayer:e}){const{data:s}=this.props;let r=t.index;e.props.invertedGeomOffsets&&(r=e.props.invertedGeomOffsets[r]);const o=e.props.recordBatchIdx,i=s.batches[o].get(r);return r+=s._offsets[o],{...t,index:r,object:i}}renderLayers(){const{data:t}=this.props,e=d(t,n.POLYGON);if(null!==e)return this._renderLayersPolygon(e);const s=d(t,n.MULTIPOLYGON);if(null!==s)return this._renderLayersMultiPolygon(s);const r=this.props.getPolygon;if(f(r))return this._renderLayersPolygon(r);if(o=r,p.DataType.isList(o.type)&&f(o.getChildAt(0)))return this._renderLayersMultiPolygon(r);var o;throw new Error("geometryColumn not Polygon or MultiPolygon")}_renderLayersPolygon(t){const{data:e}=this.props;if(this.props._validate){const s=[t];for(const t of[this.props.getElevation,this.props.getFillColor,this.props.getLineColor])t instanceof p.Vector&&s.push(t);L(t.type),h(e,s),this.props.getFillColor instanceof p.Vector&&c(this.props.getFillColor),this.props.getLineColor instanceof p.Vector&&c(this.props.getLineColor)}const r=[];for(let o=0;o<e.batches.length;o++){const e=t.data[o],i=v(C(e)),n=x(i),p=i.type.listSize,l=n.values,d=b(e),h=W(e),c={recordBatchIdx:o,id:`${this.props.id}-geoarrow-point-${o}`,filled:this.props.filled,extruded:this.props.extruded,wireframe:this.props.wireframe,_normalize:this.props._normalize,_windingOrder:this.props._windingOrder,_full3d:this.props._full3d,elevationScale:this.props.elevationScale,material:this.props.material,data:{length:e.length,startIndices:d,attributes:{getPolygon:{value:l,size:p},indices:{value:h,size:1}}}};a({props:c,propName:"getElevation",propInput:this.props.getElevation,chunkIdx:o,geomCoordOffsets:d}),a({props:c,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:o,geomCoordOffsets:d}),a({props:c,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:o,geomCoordOffsets:d});const u=new s.SolidPolygonLayer(this.getSubLayerProps(c));r.push(u)}return r}_renderLayersMultiPolygon(t){const{data:r}=this.props;if(this.props._validate){const s=[t];for(const t of[this.props.getElevation,this.props.getFillColor,this.props.getLineColor])t instanceof p.Vector&&s.push(t);o=t.type,e.assert(p.DataType.isList(o)),L(o.children[0].type),h(r,s),this.props.getFillColor instanceof p.Vector&&c(this.props.getFillColor),this.props.getLineColor instanceof p.Vector&&c(this.props.getLineColor)}var o;const i=[];for(let e=0;e<r.batches.length;e++){const r=t.data[e],o=I(r),n=v(C(o)),p=x(n),l=n.type.listSize,d=r.valueOffsets,h=p.values,c=W(o),u=b(o),g=S(r),f={recordBatchIdx:e,invertedGeomOffsets:O(d),id:`${this.props.id}-geoarrow-point-${e}`,filled:this.props.filled,extruded:this.props.extruded,wireframe:this.props.wireframe,_normalize:this.props._normalize,_windingOrder:this.props._windingOrder,_full3d:this.props._full3d,elevationScale:this.props.elevationScale,material:this.props.material,data:{length:o.length,startIndices:u,attributes:{getPolygon:{value:h,size:l},indices:{value:c,size:1}}}};a({props:f,propName:"getElevation",propInput:this.props.getElevation,chunkIdx:e,geomCoordOffsets:g}),a({props:f,propName:"getFillColor",propInput:this.props.getFillColor,chunkIdx:e,geomCoordOffsets:g}),a({props:f,propName:"getLineColor",propInput:this.props.getLineColor,chunkIdx:e,geomCoordOffsets:g});const y=new s.SolidPolygonLayer(this.getSubLayerProps(f));i.push(y)}return i}}t.GeoArrowPathLayer=M,t.GeoArrowScatterplotLayer=k,t.GeoArrowSolidPolygonLayer=A}));
//# sourceMappingURL=dist.umd.js.map

@@ -1,4 +0,4 @@

import { Accessor, Color, CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList, Unit } from "@deck.gl/core/typed";
import { Accessor, Color, CompositeLayer, CompositeLayerProps, DefaultProps, GetPickingInfoParams, Layer, LayersList, Unit } from "@deck.gl/core/typed";
import * as arrow from "apache-arrow";
import { LineStringVector, MultiLineStringVector } from "./types.js";
import { GeoArrowPickingInfo, LineStringVector, MultiLineStringVector } from "./types.js";
/** All properties supported by GeoArrowPathLayer */

@@ -81,2 +81,3 @@ export type GeoArrowPathLayerProps = _GeoArrowPathLayerProps & CompositeLayerProps;

static layerName: string;
getPickingInfo({ info, sourceLayer, }: GetPickingInfoParams): GeoArrowPickingInfo;
renderLayers(): Layer<{}> | LayersList | null;

@@ -83,0 +84,0 @@ _renderLayersLineString(geometryColumn: LineStringVector): Layer<{}> | LayersList | null;

import { CompositeLayer, } from "@deck.gl/core/typed";
import { PathLayer } from "@deck.gl/layers/typed";
import * as arrow from "apache-arrow";
import { assignAccessor, getGeometryVector, getLineStringChild, getMultiLineStringChild, getMultiLineStringResolvedOffsets, getPointChild, isLineStringVector, isMultiLineStringVector, validateColorVector, validateLineStringType, validateMultiLineStringType, validateVectorAccessors, } from "./utils.js";
import { assignAccessor, getGeometryVector, getLineStringChild, getMultiLineStringChild, getMultiLineStringResolvedOffsets, getPointChild, invertOffsets, isLineStringVector, isMultiLineStringVector, validateColorVector, validateLineStringType, validateMultiLineStringType, validateVectorAccessors, } from "./utils.js";
import { EXTENSION_NAME } from "./constants.js";

@@ -31,2 +31,29 @@ const DEFAULT_COLOR = [0, 0, 0, 255];

static layerName = "GeoArrowPathLayer";
getPickingInfo({ info, sourceLayer, }) {
const { data: table } = this.props;
// Geometry index as rendered
let index = info.index;
// if a MultiLineString dataset, map from the rendered index back to the
// feature index
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
if (sourceLayer.props.invertedGeomOffsets) {
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
index = sourceLayer.props.invertedGeomOffsets[index];
}
// @ts-expect-error `recordBatchIdx` is manually set on layer props
const recordBatchIdx = sourceLayer.props.recordBatchIdx;
const batch = table.batches[recordBatchIdx];
const row = batch.get(index);
// @ts-expect-error hack: using private method to avoid recomputing via
// batch lengths on each iteration
const offsets = table._offsets;
const currentBatchOffset = offsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return {
...info,
index,
object: row,
};
}
renderLayers() {

@@ -77,2 +104,4 @@ const { data: table } = this.props;

const props = {
// used for picking purposes
recordBatchIdx,
id: `${this.props.id}-geoarrow-path-${recordBatchIdx}`,

@@ -111,3 +140,3 @@ widthUnits: this.props.widthUnits,

});
const layer = new PathLayer(props);
const layer = new PathLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -140,7 +169,11 @@ }

const coordData = getPointChild(pointData);
const geomOffsets = multiLineStringData.valueOffsets;
const ringOffsets = lineStringData.valueOffsets;
const nDim = pointData.type.listSize;
const flatCoordinateArray = coordData.values;
const resolvedRingOffsets = getMultiLineStringResolvedOffsets(multiLineStringData);
const multiLineStringToCoordOffsets = getMultiLineStringResolvedOffsets(multiLineStringData);
const props = {
// used for picking purposes
recordBatchIdx,
invertedGeomOffsets: invertOffsets(geomOffsets),
id: `${this.props.id}-geoarrow-path-${recordBatchIdx}`,

@@ -159,2 +192,4 @@ widthUnits: this.props.widthUnits,

length: lineStringData.length,
// Offsets into coordinateArray where each single-line string starts
//
// Note: this is ringOffsets, not geomOffsets because we're rendering

@@ -169,2 +204,4 @@ // the individual paths on the map.

};
// Note: here we use multiLineStringToCoordOffsets, not ringOffsets,
// because we want the mapping from the _feature_ to the vertex
assignAccessor({

@@ -175,3 +212,3 @@ props,

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: multiLineStringToCoordOffsets,
});

@@ -183,5 +220,5 @@ assignAccessor({

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: multiLineStringToCoordOffsets,
});
const layer = new PathLayer(props);
const layer = new PathLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -188,0 +225,0 @@ }

@@ -1,4 +0,4 @@

import { Accessor, Color, CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList, Unit } from "@deck.gl/core/typed";
import { Accessor, Color, CompositeLayer, CompositeLayerProps, DefaultProps, GetPickingInfoParams, Layer, LayersList, Unit } from "@deck.gl/core/typed";
import * as arrow from "apache-arrow";
import { MultiPointVector, PointVector } from "./types.js";
import { GeoArrowPickingInfo, MultiPointVector, PointVector } from "./types.js";
/** All properties supported by GeoArrowScatterplotLayer */

@@ -104,2 +104,3 @@ export type GeoArrowScatterplotLayerProps = _GeoArrowScatterplotLayerProps & CompositeLayerProps;

static layerName: string;
getPickingInfo({ info, sourceLayer, }: GetPickingInfoParams): GeoArrowPickingInfo;
renderLayers(): Layer<{}> | LayersList | null;

@@ -106,0 +107,0 @@ _renderLayersPoint(geometryColumn: PointVector): Layer<{}> | LayersList | null;

import { CompositeLayer, } from "@deck.gl/core/typed";
import { ScatterplotLayer } from "@deck.gl/layers/typed";
import * as arrow from "apache-arrow";
import { assignAccessor, getGeometryVector, getMultiPointChild, getPointChild, isMultiPointVector, isPointVector, validateColorVector, validateMultiPointType, validatePointType, validateVectorAccessors, } from "./utils.js";
import { assignAccessor, getGeometryVector, getMultiPointChild, getPointChild, invertOffsets, isMultiPointVector, isPointVector, validateColorVector, validateMultiPointType, validatePointType, validateVectorAccessors, } from "./utils.js";
import { EXTENSION_NAME } from "./constants.js";

@@ -33,2 +33,29 @@ const DEFAULT_COLOR = [0, 0, 0, 255];

static layerName = "GeoArrowScatterplotLayer";
getPickingInfo({ info, sourceLayer, }) {
const { data: table } = this.props;
// Geometry index as rendered
let index = info.index;
// if a MultiPoint dataset, map from the rendered index back to the feature
// index
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
if (sourceLayer.props.invertedGeomOffsets) {
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
index = sourceLayer.props.invertedGeomOffsets[index];
}
// @ts-expect-error `recordBatchIdx` is manually set on layer props
const recordBatchIdx = sourceLayer.props.recordBatchIdx;
const batch = table.batches[recordBatchIdx];
const row = batch.get(index);
// @ts-expect-error hack: using private method to avoid recomputing via
// batch lengths on each iteration
const offsets = table._offsets;
const currentBatchOffset = offsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return {
...info,
index,
object: row,
};
}
renderLayers() {

@@ -81,2 +108,4 @@ const { data: table } = this.props;

const props = {
// @ts-expect-error used for picking purposes
recordBatchIdx,
id: `${this.props.id}-geoarrow-scatterplot-${recordBatchIdx}`,

@@ -129,3 +158,3 @@ radiusUnits: this.props.radiusUnits,

});
const layer = new ScatterplotLayer(props);
const layer = new ScatterplotLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -168,2 +197,5 @@ }

const props = {
// @ts-expect-error used for picking purposes
recordBatchIdx,
invertedGeomOffsets: invertOffsets(geomOffsets),
id: `${this.props.id}-geoarrow-scatterplot-${recordBatchIdx}`,

@@ -221,3 +253,3 @@ radiusUnits: this.props.radiusUnits,

});
const layer = new ScatterplotLayer(props);
const layer = new ScatterplotLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -224,0 +256,0 @@ }

@@ -1,4 +0,4 @@

import { Accessor, Color, CompositeLayer, CompositeLayerProps, Material, DefaultProps, Layer, LayersList } from "@deck.gl/core/typed";
import { Accessor, Color, CompositeLayer, CompositeLayerProps, Material, DefaultProps, Layer, LayersList, GetPickingInfoParams } from "@deck.gl/core/typed";
import * as arrow from "apache-arrow";
import { MultiPolygonVector, PolygonVector } from "./types.js";
import { GeoArrowPickingInfo, MultiPolygonVector, PolygonVector } from "./types.js";
/** All properties supported by GeoArrowSolidPolygonLayer */

@@ -71,2 +71,3 @@ export type GeoArrowSolidPolygonLayerProps = _GeoArrowSolidPolygonLayerProps & CompositeLayerProps;

static layerName: string;
getPickingInfo({ info, sourceLayer, }: GetPickingInfoParams): GeoArrowPickingInfo;
renderLayers(): Layer<{}> | LayersList | null;

@@ -73,0 +74,0 @@ _renderLayersPolygon(geometryColumn: PolygonVector): Layer<{}> | LayersList | null;

import { CompositeLayer, } from "@deck.gl/core/typed";
import { SolidPolygonLayer } from "@deck.gl/layers/typed";
import * as arrow from "apache-arrow";
import { assignAccessor, getGeometryVector, getLineStringChild, getMultiPolygonChild, getMultiPolygonResolvedOffsets, getPointChild, getPolygonChild, getPolygonResolvedOffsets, isMultiPolygonVector, isPolygonVector, validateColorVector, validateMultiPolygonType, validatePolygonType, validateVectorAccessors, } from "./utils.js";
import { assignAccessor, getGeometryVector, getLineStringChild, getMultiPolygonChild, getMultiPolygonResolvedOffsets, getPointChild, getPolygonChild, getPolygonResolvedOffsets, invertOffsets, isMultiPolygonVector, isPolygonVector, validateColorVector, validateMultiPolygonType, validatePolygonType, validateVectorAccessors, } from "./utils.js";
import { EXTENSION_NAME } from "./constants.js";
import { earcutPolygonArray } from "./earcut.js";
const DEFAULT_COLOR = [0, 0, 0, 255];

@@ -27,2 +28,29 @@ const defaultProps = {

static layerName = "GeoArrowSolidPolygonLayer";
getPickingInfo({ info, sourceLayer, }) {
const { data: table } = this.props;
// Geometry index as rendered
let index = info.index;
// if a MultiPolygon dataset, map from the rendered index back to the
// feature index
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
if (sourceLayer.props.invertedGeomOffsets) {
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
index = sourceLayer.props.invertedGeomOffsets[index];
}
// @ts-expect-error `recordBatchIdx` is manually set on layer props
const recordBatchIdx = sourceLayer.props.recordBatchIdx;
const batch = table.batches[recordBatchIdx];
const row = batch.get(index);
// @ts-expect-error hack: using private method to avoid recomputing via
// batch lengths on each iteration
const offsets = table._offsets;
const currentBatchOffset = offsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return {
...info,
index,
object: row,
};
}
renderLayers() {

@@ -80,3 +108,6 @@ const { data: table } = this.props;

const resolvedRingOffsets = getPolygonResolvedOffsets(polygonData);
const earcutTriangles = earcutPolygonArray(polygonData);
const props = {
// used for picking purposes
recordBatchIdx,
id: `${this.props.id}-geoarrow-point-${recordBatchIdx}`,

@@ -99,2 +130,3 @@ filled: this.props.filled,

getPolygon: { value: flatCoordinateArray, size: nDim },
indices: { value: earcutTriangles, size: 1 },
},

@@ -124,3 +156,3 @@ },

});
const layer = new SolidPolygonLayer(props);
const layer = new SolidPolygonLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -160,8 +192,21 @@ }

const nDim = pointData.type.listSize;
// const geomOffsets = multiPolygonData.valueOffsets;
const polygonOffsets = polygonData.valueOffsets;
const geomOffsets = multiPolygonData.valueOffsets;
// const polygonOffsets = polygonData.valueOffsets;
// const ringOffsets = ringData.valueOffsets;
const flatCoordinateArray = coordData.values;
const resolvedRingOffsets = getMultiPolygonResolvedOffsets(multiPolygonData);
const earcutTriangles = earcutPolygonArray(polygonData);
// NOTE: we have two different uses of offsets. One is for _rendering_
// each polygon. The other is for mapping _accessor attributes_ from one
// value per feature to one value per vertex. And for that we need to use
// these offsets in two different ways.
//
// TODO: Don't construct the offsets twice from scratch? I.e. from the
// polygon-to-coord offsets you should be able to infer the
// multi-polygon-to-coord offsets? Or something like that
const resolvedPolygonToCoordOffsets = getPolygonResolvedOffsets(polygonData);
const resolvedMultiPolygonToCoordOffsets = getMultiPolygonResolvedOffsets(multiPolygonData);
const props = {
// used for picking purposes
recordBatchIdx,
invertedGeomOffsets: invertOffsets(geomOffsets),
id: `${this.props.id}-geoarrow-point-${recordBatchIdx}`,

@@ -181,9 +226,18 @@ filled: this.props.filled,

length: polygonData.length,
// Offsets into coordinateArray where each polygon starts
// Note: this is polygonOffsets, not geomOffsets because we're
// rendering the individual polygons on the map.
// @ts-ignore
startIndices: polygonOffsets,
// Offsets into coordinateArray where each single-polygon starts
//
// Note that this is polygonToCoordOffsets and not geomToCoordOffsets
// because we're rendering each part of the MultiPolygon individually
// @ts-expect-error
startIndices: resolvedPolygonToCoordOffsets,
attributes: {
getPolygon: { value: flatCoordinateArray, size: nDim },
indices: { value: earcutTriangles, size: 1 },
// instancePickingColors: {
// value: encodePickingColors(
// resolvedMultiPolygonToCoordOffsets,
// this.encodePickingColor
// ),
// size: 3,
// },
},

@@ -197,3 +251,3 @@ },

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: resolvedMultiPolygonToCoordOffsets,
});

@@ -205,3 +259,3 @@ assignAccessor({

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: resolvedMultiPolygonToCoordOffsets,
});

@@ -213,5 +267,5 @@ assignAccessor({

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: resolvedMultiPolygonToCoordOffsets,
});
const layer = new SolidPolygonLayer(props);
const layer = new SolidPolygonLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -222,1 +276,19 @@ }

}
function encodePickingColors(geomToCoordOffsets, encodePickingColor) {
const largestOffset = geomToCoordOffsets[geomToCoordOffsets.length - 1];
const pickingColors = new Uint8ClampedArray(largestOffset);
const pickingColor = [];
for (let arrayIdx = 0; arrayIdx < geomToCoordOffsets.length - 1; arrayIdx++) {
const thisOffset = geomToCoordOffsets[arrayIdx];
const nextOffset = geomToCoordOffsets[arrayIdx + 1];
// Note: we encode the picking color once per _feature_, but then assign it
// to the color array once per _vertex_
encodePickingColor(arrayIdx, pickingColor);
for (let offset = thisOffset; offset < nextOffset; offset++) {
pickingColors[offset * 3] = pickingColor[0];
pickingColors[offset * 3 + 1] = pickingColor[1];
pickingColors[offset * 3 + 2] = pickingColor[2];
}
}
return pickingColors;
}

@@ -0,6 +1,7 @@

import { PickingInfo } from "@deck.gl/core/typed";
import * as arrow from "apache-arrow";
export type InterleavedCoord = arrow.FixedSizeList<arrow.Float>;
export type InterleavedCoord = arrow.FixedSizeList<arrow.Float64>;
export type SeparatedCoord = arrow.Struct<{
x: arrow.Float;
y: arrow.Float;
x: arrow.Float64;
y: arrow.Float64;
}>;

@@ -26,1 +27,4 @@ export type Coord = InterleavedCoord;

export type MultiPolygonData = arrow.Data<MultiPolygon>;
export type GeoArrowPickingInfo = PickingInfo & {
object: arrow.StructRowProxy;
};

@@ -75,2 +75,6 @@ import * as arrow from "apache-arrow";

export declare function getMultiPolygonResolvedOffsets(data: MultiPolygonData): Int32Array;
/**
* Invert offsets so that lookup can go in the opposite direction
*/
export declare function invertOffsets(offsets: Int32Array): Uint8Array | Uint16Array | Uint32Array;
export {};

@@ -357,3 +357,2 @@ import { assert } from "@deck.gl/core/typed";

const ringOffsets = ringData.valueOffsets;
// TODO: need to test this.
const resolvedRingOffsets = new Int32Array(geomOffsets.length);

@@ -365,1 +364,21 @@ for (let i = 0; i < resolvedRingOffsets.length; ++i) {

}
/**
* Invert offsets so that lookup can go in the opposite direction
*/
export function invertOffsets(offsets) {
const largestOffset = offsets[offsets.length - 1];
const arrayConstructor = offsets.length < Math.pow(2, 8)
? Uint8Array
: offsets.length < Math.pow(2, 16)
? Uint16Array
: Uint32Array;
const invertedOffsets = new arrayConstructor(largestOffset);
for (let arrayIdx = 0; arrayIdx < offsets.length - 1; arrayIdx++) {
const thisOffset = offsets[arrayIdx];
const nextOffset = offsets[arrayIdx + 1];
for (let offset = thisOffset; offset < nextOffset; offset++) {
invertedOffsets[offset] = arrayIdx;
}
}
return invertedOffsets;
}

@@ -7,3 +7,3 @@ {

"name": "@geoarrow/deck.gl-layers",
"version": "0.1.0",
"version": "0.2.0",
"type": "module",

@@ -43,2 +43,3 @@ "description": "",

"@deck.gl/layers": "^8.9.23",
"@math.gl/polygon": "^3.6.2",
"apache-arrow": "^13.0.0"

@@ -49,2 +50,3 @@ },

"@deck.gl/layers": "^8.9.23",
"@math.gl/polygon": "^3.6.2",
"@rollup/plugin-terser": "^0.4.3",

@@ -51,0 +53,0 @@ "@rollup/plugin-typescript": "^11.1.2",

@@ -7,2 +7,3 @@ import {

DefaultProps,
GetPickingInfoParams,
Layer,

@@ -22,2 +23,3 @@ LayersList,

getPointChild,
invertOffsets,
isLineStringVector,

@@ -30,3 +32,7 @@ isMultiLineStringVector,

} from "./utils.js";
import { LineStringVector, MultiLineStringVector } from "./types.js";
import {
GeoArrowPickingInfo,
LineStringVector,
MultiLineStringVector,
} from "./types.js";
import { EXTENSION_NAME } from "./constants.js";

@@ -144,2 +150,38 @@

getPickingInfo({
info,
sourceLayer,
}: GetPickingInfoParams): GeoArrowPickingInfo {
const { data: table } = this.props;
// Geometry index as rendered
let index = info.index;
// if a MultiLineString dataset, map from the rendered index back to the
// feature index
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
if (sourceLayer.props.invertedGeomOffsets) {
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
index = sourceLayer.props.invertedGeomOffsets[index];
}
// @ts-expect-error `recordBatchIdx` is manually set on layer props
const recordBatchIdx: number = sourceLayer.props.recordBatchIdx;
const batch = table.batches[recordBatchIdx];
const row = batch.get(index);
// @ts-expect-error hack: using private method to avoid recomputing via
// batch lengths on each iteration
const offsets: number[] = table._offsets;
const currentBatchOffset = offsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return {
...info,
index,
object: row,
};
}
renderLayers(): Layer<{}> | LayersList | null {

@@ -213,2 +255,5 @@ const { data: table } = this.props;

const props: PathLayerProps = {
// used for picking purposes
recordBatchIdx,
id: `${this.props.id}-geoarrow-path-${recordBatchIdx}`,

@@ -249,3 +294,3 @@ widthUnits: this.props.widthUnits,

const layer = new PathLayer(props);
const layer = new PathLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -291,2 +336,3 @@ }

const geomOffsets = multiLineStringData.valueOffsets;
const ringOffsets = lineStringData.valueOffsets;

@@ -296,6 +342,10 @@

const flatCoordinateArray = coordData.values;
const resolvedRingOffsets =
const multiLineStringToCoordOffsets =
getMultiLineStringResolvedOffsets(multiLineStringData);
const props: PathLayerProps = {
// used for picking purposes
recordBatchIdx,
invertedGeomOffsets: invertOffsets(geomOffsets),
id: `${this.props.id}-geoarrow-path-${recordBatchIdx}`,

@@ -314,2 +364,4 @@ widthUnits: this.props.widthUnits,

length: lineStringData.length,
// Offsets into coordinateArray where each single-line string starts
//
// Note: this is ringOffsets, not geomOffsets because we're rendering

@@ -325,2 +377,4 @@ // the individual paths on the map.

// Note: here we use multiLineStringToCoordOffsets, not ringOffsets,
// because we want the mapping from the _feature_ to the vertex
assignAccessor({

@@ -331,3 +385,3 @@ props,

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: multiLineStringToCoordOffsets,
});

@@ -339,6 +393,6 @@ assignAccessor({

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: multiLineStringToCoordOffsets,
});
const layer = new PathLayer(props);
const layer = new PathLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -345,0 +399,0 @@ }

@@ -7,2 +7,3 @@ import {

DefaultProps,
GetPickingInfoParams,
Layer,

@@ -20,2 +21,3 @@ LayersList,

getPointChild,
invertOffsets,
isMultiPointVector,

@@ -28,3 +30,3 @@ isPointVector,

} from "./utils.js";
import { MultiPointVector, PointVector } from "./types.js";
import { GeoArrowPickingInfo, MultiPointVector, PointVector } from "./types.js";
import { EXTENSION_NAME } from "./constants.js";

@@ -174,2 +176,38 @@

getPickingInfo({
info,
sourceLayer,
}: GetPickingInfoParams): GeoArrowPickingInfo {
const { data: table } = this.props;
// Geometry index as rendered
let index = info.index;
// if a MultiPoint dataset, map from the rendered index back to the feature
// index
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
if (sourceLayer.props.invertedGeomOffsets) {
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
index = sourceLayer.props.invertedGeomOffsets[index];
}
// @ts-expect-error `recordBatchIdx` is manually set on layer props
const recordBatchIdx: number = sourceLayer.props.recordBatchIdx;
const batch = table.batches[recordBatchIdx];
const row = batch.get(index);
// @ts-expect-error hack: using private method to avoid recomputing via
// batch lengths on each iteration
const offsets: number[] = table._offsets;
const currentBatchOffset = offsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return {
...info,
index,
object: row,
};
}
renderLayers(): Layer<{}> | LayersList | null {

@@ -242,2 +280,5 @@ const { data: table } = this.props;

const props: ScatterplotLayerProps = {
// @ts-expect-error used for picking purposes
recordBatchIdx,
id: `${this.props.id}-geoarrow-scatterplot-${recordBatchIdx}`,

@@ -292,3 +333,3 @@ radiusUnits: this.props.radiusUnits,

const layer = new ScatterplotLayer(props);
const layer = new ScatterplotLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -344,2 +385,6 @@ }

const props: ScatterplotLayerProps = {
// @ts-expect-error used for picking purposes
recordBatchIdx,
invertedGeomOffsets: invertOffsets(geomOffsets),
id: `${this.props.id}-geoarrow-scatterplot-${recordBatchIdx}`,

@@ -399,3 +444,3 @@ radiusUnits: this.props.radiusUnits,

const layer = new ScatterplotLayer(props);
const layer = new ScatterplotLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -402,0 +447,0 @@ }

@@ -10,2 +10,3 @@ import {

LayersList,
GetPickingInfoParams,
} from "@deck.gl/core/typed";

@@ -24,2 +25,3 @@ import { SolidPolygonLayer } from "@deck.gl/layers/typed";

getPolygonResolvedOffsets,
invertOffsets,
isMultiPolygonVector,

@@ -32,4 +34,9 @@ isPolygonVector,

} from "./utils.js";
import { MultiPolygonVector, PolygonVector } from "./types.js";
import {
GeoArrowPickingInfo,
MultiPolygonVector,
PolygonVector,
} from "./types.js";
import { EXTENSION_NAME } from "./constants.js";
import { earcutPolygonArray } from "./earcut.js";

@@ -145,2 +152,38 @@ const DEFAULT_COLOR: [number, number, number, number] = [0, 0, 0, 255];

getPickingInfo({
info,
sourceLayer,
}: GetPickingInfoParams): GeoArrowPickingInfo {
const { data: table } = this.props;
// Geometry index as rendered
let index = info.index;
// if a MultiPolygon dataset, map from the rendered index back to the
// feature index
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
if (sourceLayer.props.invertedGeomOffsets) {
// @ts-expect-error `invertedGeomOffsets` is manually set on layer props
index = sourceLayer.props.invertedGeomOffsets[index];
}
// @ts-expect-error `recordBatchIdx` is manually set on layer props
const recordBatchIdx: number = sourceLayer.props.recordBatchIdx;
const batch = table.batches[recordBatchIdx];
const row = batch.get(index);
// @ts-expect-error hack: using private method to avoid recomputing via
// batch lengths on each iteration
const offsets: number[] = table._offsets;
const currentBatchOffset = offsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return {
...info,
index,
object: row,
};
}
renderLayers(): Layer<{}> | LayersList | null {

@@ -221,3 +264,8 @@ const { data: table } = this.props;

const earcutTriangles = earcutPolygonArray(polygonData);
const props: SolidPolygonLayerProps = {
// used for picking purposes
recordBatchIdx,
id: `${this.props.id}-geoarrow-point-${recordBatchIdx}`,

@@ -240,2 +288,3 @@ filled: this.props.filled,

getPolygon: { value: flatCoordinateArray, size: nDim },
indices: { value: earcutTriangles, size: 1 },
},

@@ -267,3 +316,3 @@ },

const layer = new SolidPolygonLayer(props);
const layer = new SolidPolygonLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -317,11 +366,28 @@ }

// const geomOffsets = multiPolygonData.valueOffsets;
const polygonOffsets = polygonData.valueOffsets;
const geomOffsets = multiPolygonData.valueOffsets;
// const polygonOffsets = polygonData.valueOffsets;
// const ringOffsets = ringData.valueOffsets;
const flatCoordinateArray = coordData.values;
const resolvedRingOffsets =
const earcutTriangles = earcutPolygonArray(polygonData);
// NOTE: we have two different uses of offsets. One is for _rendering_
// each polygon. The other is for mapping _accessor attributes_ from one
// value per feature to one value per vertex. And for that we need to use
// these offsets in two different ways.
//
// TODO: Don't construct the offsets twice from scratch? I.e. from the
// polygon-to-coord offsets you should be able to infer the
// multi-polygon-to-coord offsets? Or something like that
const resolvedPolygonToCoordOffsets =
getPolygonResolvedOffsets(polygonData);
const resolvedMultiPolygonToCoordOffsets =
getMultiPolygonResolvedOffsets(multiPolygonData);
const props: SolidPolygonLayerProps = {
// used for picking purposes
recordBatchIdx,
invertedGeomOffsets: invertOffsets(geomOffsets),
id: `${this.props.id}-geoarrow-point-${recordBatchIdx}`,

@@ -341,9 +407,18 @@ filled: this.props.filled,

length: polygonData.length,
// Offsets into coordinateArray where each polygon starts
// Note: this is polygonOffsets, not geomOffsets because we're
// rendering the individual polygons on the map.
// @ts-ignore
startIndices: polygonOffsets,
// Offsets into coordinateArray where each single-polygon starts
//
// Note that this is polygonToCoordOffsets and not geomToCoordOffsets
// because we're rendering each part of the MultiPolygon individually
// @ts-expect-error
startIndices: resolvedPolygonToCoordOffsets,
attributes: {
getPolygon: { value: flatCoordinateArray, size: nDim },
indices: { value: earcutTriangles, size: 1 },
// instancePickingColors: {
// value: encodePickingColors(
// resolvedMultiPolygonToCoordOffsets,
// this.encodePickingColor
// ),
// size: 3,
// },
},

@@ -358,3 +433,3 @@ },

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: resolvedMultiPolygonToCoordOffsets,
});

@@ -366,3 +441,3 @@ assignAccessor({

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: resolvedMultiPolygonToCoordOffsets,
});

@@ -374,6 +449,6 @@ assignAccessor({

chunkIdx: recordBatchIdx,
geomCoordOffsets: resolvedRingOffsets,
geomCoordOffsets: resolvedMultiPolygonToCoordOffsets,
});
const layer = new SolidPolygonLayer(props);
const layer = new SolidPolygonLayer(this.getSubLayerProps(props));
layers.push(layer);

@@ -385,1 +460,26 @@ }

}
function encodePickingColors(
geomToCoordOffsets: Int32Array,
encodePickingColor: (id: number, result: number[]) => void
): Uint8ClampedArray {
const largestOffset = geomToCoordOffsets[geomToCoordOffsets.length - 1];
const pickingColors = new Uint8ClampedArray(largestOffset);
const pickingColor = [];
for (let arrayIdx = 0; arrayIdx < geomToCoordOffsets.length - 1; arrayIdx++) {
const thisOffset = geomToCoordOffsets[arrayIdx];
const nextOffset = geomToCoordOffsets[arrayIdx + 1];
// Note: we encode the picking color once per _feature_, but then assign it
// to the color array once per _vertex_
encodePickingColor(arrayIdx, pickingColor);
for (let offset = thisOffset; offset < nextOffset; offset++) {
pickingColors[offset * 3] = pickingColor[0];
pickingColors[offset * 3 + 1] = pickingColor[1];
pickingColors[offset * 3 + 2] = pickingColor[2];
}
}
return pickingColors;
}

@@ -0,7 +1,8 @@

import { PickingInfo } from "@deck.gl/core/typed";
import * as arrow from "apache-arrow";
export type InterleavedCoord = arrow.FixedSizeList<arrow.Float>;
export type InterleavedCoord = arrow.FixedSizeList<arrow.Float64>;
export type SeparatedCoord = arrow.Struct<{
x: arrow.Float;
y: arrow.Float;
x: arrow.Float64;
y: arrow.Float64;
}>;

@@ -30,1 +31,5 @@ // TODO: support separated coords

export type MultiPolygonData = arrow.Data<MultiPolygon>;
export type GeoArrowPickingInfo = PickingInfo & {
object: arrow.StructRowProxy
}

@@ -537,3 +537,2 @@ import { assert } from "@deck.gl/core/typed";

// TODO: need to test this.
const resolvedRingOffsets = new Int32Array(geomOffsets.length);

@@ -546,1 +545,28 @@ for (let i = 0; i < resolvedRingOffsets.length; ++i) {

}
/**
* Invert offsets so that lookup can go in the opposite direction
*/
export function invertOffsets(
offsets: Int32Array
): Uint8Array | Uint16Array | Uint32Array {
const largestOffset = offsets[offsets.length - 1];
const arrayConstructor =
offsets.length < Math.pow(2, 8)
? Uint8Array
: offsets.length < Math.pow(2, 16)
? Uint16Array
: Uint32Array;
const invertedOffsets = new arrayConstructor(largestOffset);
for (let arrayIdx = 0; arrayIdx < offsets.length - 1; arrayIdx++) {
const thisOffset = offsets[arrayIdx];
const nextOffset = offsets[arrayIdx + 1];
for (let offset = thisOffset; offset < nextOffset; offset++) {
invertedOffsets[offset] = arrayIdx;
}
}
return invertedOffsets;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc