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

shapefile

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shapefile - npm Package Compare versions

Comparing version 0.5.9 to 0.5.10

2

dist/shapefile.js

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

// https://github.com/mbostock/shapefile Version 0.5.9. Copyright 2016 Mike Bostock.
// https://github.com/mbostock/shapefile Version 0.5.10. Copyright 2017 Mike Bostock.
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

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

// https://github.com/mbostock/shapefile Version 0.5.9. Copyright 2016 Mike Bostock.
// https://github.com/mbostock/shapefile Version 0.5.10. Copyright 2017 Mike Bostock.
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.shapefile=e.shapefile||{})}(this,function(e){"use strict";function n(e){return new t(e instanceof Uint8Array?e:new Uint8Array(e))}function t(e){this._array=e}function r(e){return("function"==typeof fetch?x:m)(e)}function o(e){return"function"==typeof e.read?e:e.getReader()}function i(e,n){if(!e.length)return n;if(!n.length)return e;var t=new Uint8Array(e.length+n.length);return t.set(e),t.set(n,e.length),t}function u(e){return"function"==typeof e.slice?e:new a("function"==typeof e.read?e:e.getReader())}function a(e){this._source=e,this._array=A,this._index=0}function f(e,n,t,r){this._source=e,this._decode=n.decode.bind(n),this._recordLength=t.getUint16(10,!0),this._fields=[];for(var o=0;13!==r.getUint8(o);o+=32){for(var i=0;i<11&&0!==r.getUint8(o+i);++i);this._fields.push({name:this._decode(new Uint8Array(r.buffer,r.byteOffset+o,i)),type:String.fromCharCode(r.getUint8(o+11)),length:r.getUint8(o+16)})}}function c(){return this._source.cancel()}function s(e){if((n=e.length)<4)return!1;for(var n,t=0,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++t<n;)r+=e[t-1][1]*e[t][0]-e[t-1][0]*e[t][1];return r>=0}function l(e,n){for(var t,r=-1,o=n.length;++r<o;)if(t=h(e,n[r]))return t>0;return!1}function h(e,n){for(var t=n[0],r=n[1],o=-1,i=0,u=e.length,a=u-1;i<u;a=i++){var f=e[i],c=f[0],s=f[1],l=e[a],h=l[0],y=l[1];if(d(f,l,n))return 0;s>r!=y>r&&t<(h-c)*(r-s)/(y-s)+c&&(o=-o)}return o}function d(e,n,t){var r=t[0]-e[0],o=t[1]-e[1];if(0===r&&0===o)return!0;var i=n[0]-e[0],u=n[1]-e[1];if(0===i&&0===u)return!1;var a=(r*i+o*u)/(i*i+u*u);return!(a<0||a>1)&&(0===a||1===a||a*i===r&&a*u===o)}function y(e,n){var t=n.getInt32(32,!0);if(!(t in H))throw new Error("unsupported shape type: "+t);this._source=e,this._type=H[t],this.bbox=[n.getFloat64(36,!0),n.getFloat64(44,!0),n.getFloat64(52,!0),n.getFloat64(60,!0)]}function g(){}function p(e,n){this._shp=e,this._dbf=n,this.bbox=e.bbox}function v(e,t,i){return"string"==typeof t?(/\.dbf$/.test(t)||(t+=".dbf"),t=r(t,i)):t instanceof ArrayBuffer||t instanceof Uint8Array?t=n(t):null!=t&&(t=o(t)),"string"==typeof e?(/\.shp$/.test(e)||(e+=".shp"),void 0===t&&(t=r(e.substring(0,e.length-4)+".dbf",i).catch(function(){})),e=r(e,i)):e=e instanceof ArrayBuffer||e instanceof Uint8Array?n(e):o(e),Promise.all([e,t]).then(function(e){var n=e[0],t=e[1],r="windows-1252";return i&&null!=i.encoding&&(r=i.encoding),J(n,t,t&&new TextDecoder(r))})}function _(e,n,t){return v(e,n,t).then(function(e){var n=[],t={type:"FeatureCollection",features:n,bbox:e.bbox};return e.read().then(function r(o){return o.done?t:(n.push(o.value),e.read().then(r))})})}var b=function(){return this._array=null,Promise.resolve()},w=function(){var e=this._array;return this._array=null,Promise.resolve(e?{done:!1,value:e}:{done:!0,value:void 0})};t.prototype.read=w,t.prototype.cancel=b;var x=function(e){return fetch(e).then(function(e){return e.body&&e.body.getReader?e.body.getReader():e.arrayBuffer().then(n)})},m=function(e){return new Promise(function(t,r){var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onload=function(){t(n(o.response))},o.onerror=r,o.ontimeout=r,o.open("GET",e,!0),o.send()})},A=new Uint8Array(0),F=function(){return this._source.cancel()},U=function(){var e=this,n=e._array.subarray(e._index);return e._source.read().then(function(t){return e._array=A,e._index=0,t.done?n.length>0?{done:!1,value:n}:{done:!0,value:void 0}:{done:!1,value:i(n,t.value)}})},P=function(e){if((e|=0)<0)throw new Error("invalid length");var n=this,t=this._array.length-this._index;if(this._index+e<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=e));var r=new Uint8Array(e);return r.set(this._array.subarray(this._index)),function o(){return n._source.read().then(function(i){return i.done?(n._array=A,n._index=0,t>0?r.subarray(0,t):null):t+i.value.length>=e?(n._array=i.value,n._index=e-t,r.set(i.value.subarray(0,e-t),t),r):(r.set(i.value,t),t+=i.value.length,o())})}()};a.prototype.read=U,a.prototype.slice=P,a.prototype.cancel=F;var I=function(){return this._source.cancel()},L=function(e){return!/^[nf]$/i.test(e)&&(!!/^[yt]$/i.test(e)||null)},M=function(e){return new Date(+e.substring(0,4),e.substring(4,6)-1,+e.substring(6,8))},E=function(e){return isNaN(e=+e)?null:e},R=function(e){return e.trim()||null},B={B:E,C:R,D:M,F:E,L:L,M:E,N:E},C=function(){var e=this,n=1;return e._source.slice(e._recordLength).then(function(t){return t?{done:!1,value:e._fields.reduce(function(r,o){return r[o.name]=B[o.type](e._decode(t.subarray(n,n+=o.length))),r},{})}:{done:!0,value:void 0}})},D=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},$=function(e,n){return e=u(e),e.slice(32).then(function(t){var r=D(t);return e.slice(r.getUint16(8,!0)-32).then(function(t){return new f(e,n,r,D(t))})})},N=f.prototype;N.read=C,N.cancel=I;var O=function(e){var n,t=40,r=e.getInt32(36,!0),o=new Array(r);for(n=0;n<r;++n,t+=16)o[n]=[e.getFloat64(t,!0),e.getFloat64(t+8,!0)];return{type:"MultiPoint",coordinates:o}},S=function(){return null},T=function(e){return{type:"Point",coordinates:[e.getFloat64(4,!0),e.getFloat64(12,!0)]}},j=function(e){var n,t=44,r=e.getInt32(36,!0),o=e.getInt32(40,!0),i=new Array(r),u=new Array(o),a=[],f=[];for(n=0;n<r;++n,t+=4)i[n]=e.getInt32(t,!0);for(n=0;n<o;++n,t+=16)u[n]=[e.getFloat64(t,!0),e.getFloat64(t+8,!0)];return i.forEach(function(e,n){var t=u.slice(e,i[n+1]);s(t)?a.push([t]):f.push(t)}),f.forEach(function(e){a.some(function(n){if(l(n[0],e))return n.push(e),!0})||a.push([e])}),1===a.length?{type:"Polygon",coordinates:a[0]}:{type:"MultiPolygon",coordinates:a}},q=function(e){var n,t=44,r=e.getInt32(36,!0),o=e.getInt32(40,!0),i=new Array(r),u=new Array(o);for(n=0;n<r;++n,t+=4)i[n]=e.getInt32(t,!0);for(n=0;n<o;++n,t+=16)u[n]=[e.getFloat64(t,!0),e.getFloat64(t+8,!0)];return 1===r?{type:"LineString",coordinates:u}:{type:"MultiLineString",coordinates:i.map(function(e,n){return u.slice(e,i[n+1])})}},G=function(){var e=this;return e._source.slice(8).then(function(n){if(null==n)return{done:!0,value:void 0};var t=D(n);return e._source.slice(2*t.getInt32(4,!1)).then(function(n){var t=D(n);return{done:!1,value:t.getInt32(0,!0)?e._type(t):S()}})})},H={0:S,1:T,3:q,5:j,8:O,11:T,13:q,15:j,18:O},V=function(e){return e=u(e),e.slice(100).then(function(n){return new y(e,D(n))})},X=y.prototype;X.read=G,X.cancel=c;var k=function(){return Promise.all([this._dbf&&this._dbf.cancel(),this._shp.cancel()]).then(g)},z=function(){var e=this;return Promise.all([e._dbf?e._dbf.read():{value:{}},e._shp.read()]).then(function(e){var n=e[0],t=e[1];return t.done?t:{done:!1,value:{type:"Feature",properties:n.value,geometry:t.value}}})},J=function(e,n,t){return Promise.all([V(e),n&&$(n,t)]).then(function(e){return new p(e[0],e[1])})},K=p.prototype;K.read=z,K.cancel=k,e.open=v,e.read=_,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "shapefile",
"version": "0.5.9",
"version": "0.5.10",
"description": "An implementation of the shapefile (.shp) spatial data format.",

@@ -37,3 +37,3 @@ "keywords": [

"stream-source": "0.3",
"text-encoding": "0.6"
"text-encoding": "0.6.1"
},

@@ -40,0 +40,0 @@ "devDependencies": {

@@ -43,3 +43,3 @@ # Streaming Shapefile Parser

For a live example, see [bl.ocks.org/2dd741099154a4da55a7db31fd96a892](http://bl.ocks.org/mbostock/2dd741099154a4da55a7db31fd96a892). See also [ndjson-cli](https://github.com/mbostock/ndjson-cli) for examples of manipulating GeoJSON using newline-delimited JSON streams.
For a live example, see [bl.ocks.org/2dd741099154a4da55a7db31fd96a892](http://bl.ocks.org/mbostock/2dd741099154a4da55a7db31fd96a892). See also [ndjson-cli](https://github.com/mbostock/ndjson-cli) for examples of manipulating GeoJSON using newline-delimited JSON streams. See [Command-Line Cartography](https://medium.com/@mbostock/command-line-cartography-part-1-897aa8f8ca2c) for a longer introduction.

@@ -46,0 +46,0 @@ This parser implementation is based on the [ESRI Shapefile Technical Description](http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf) and [dBASE Table File Format](http://www.digitalpreservation.gov/formats/fdd/fdd000325.shtml). Caveat emptor: this is a work in progress and does not currently support all shapefile geometry types. It only supports dBASE III and has little error checking. Please contribute if you want to help!

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