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

shpts

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shpts - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

1

dist/geometry/base.d.ts

@@ -12,2 +12,3 @@ import { Coord, CoordType } from '../types/coordinate';

get coordLength(): number;
abstract get type(): string;
protected static readBbox(stream: MemoryStream): BoundingBox;

@@ -14,0 +15,0 @@ }

@@ -9,2 +9,3 @@ import { CoordType, MultiPatchCoord } from '../types/coordinate';

constructor(coords: MultiPatchCoord, coordType: CoordType);
get type(): "Polygon" | "MultiPolygon";
static fromPresetReader(reader: ShapeReader, header: GeomHeader): MultiPatchRecord;

@@ -11,0 +12,0 @@ private static assemblePolygonsWithHoles;

@@ -9,2 +9,3 @@ import { ShapeReader } from '../reader/shpReader';

constructor(coords: MultiPointCoord, coordType: CoordType);
get type(): string;
static fromPresetReader(reader: ShapeReader, header: GeomHeader): MultiPointRecord;

@@ -11,0 +12,0 @@ private static getZValues;

@@ -5,3 +5,4 @@ import { GeoJsonGeom } from '../types/geojson';

constructor();
get type(): string;
toGeoJson(): GeoJsonGeom;
}

@@ -9,4 +9,5 @@ import { ShapeReader } from '../reader/shpReader';

constructor(coords: PointCoord, coordType: CoordType);
get type(): string;
static fromPresetReader(reader: ShapeReader, header: GeomHeader): PointRecord;
toGeoJson(): GeoJsonPoint;
}

@@ -9,4 +9,5 @@ import { ShapeReader } from '../reader/shpReader';

constructor(coords: PolygonCoord, coordType: CoordType);
get type(): "Polygon" | "MultiPolygon";
static fromPresetReader(reader: ShapeReader, header: GeomHeader): PolygonRecord;
toGeoJson(): GeoJsonGeom;
}

@@ -9,4 +9,5 @@ import { ShapeReader } from '../reader/shpReader';

constructor(coords: PolyLineCoord, coordType: CoordType);
get type(): "LineString" | "MultiLineString";
static fromPresetReader(reader: ShapeReader, header: GeomHeader): PolyLineRecord;
toGeoJson(): GeoJsonLineString | GeoJsonMultiLineString;
}

156

dist/shpts.js
var ae = Object.defineProperty;
var ce = (r, e, t) => e in r ? ae(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var g = (r, e, t) => (ce(r, typeof e != "symbol" ? e + "" : e, t), t);
var y = (r, e, t) => (ce(r, typeof e != "symbol" ? e + "" : e, t), t);
class X {
constructor(e) {
g(this, "dataView");
g(this, "offset", 0);
g(this, "size", 0);
y(this, "dataView");
y(this, "offset", 0);
y(this, "size", 0);
this.size = e.byteLength, this.dataView = new DataView(e);

@@ -121,4 +121,4 @@ }

constructor(e) {
g(this, "encoding");
g(this, "decoder");
y(this, "encoding");
y(this, "decoder");
this.encoding = e, this.decoder = new TextDecoder(e);

@@ -225,4 +225,4 @@ }

let V = E;
g(V, "regExDate", /^(\d\d\d\d)(\d\d)(\d\d)$/);
const ye = {
y(V, "regExDate", /^(\d\d\d\d)(\d\d)(\d\d)$/);
const ge = {
C: "Character",

@@ -236,8 +236,8 @@ N: "Number",

constructor(e, t) {
g(this, "stream");
g(this, "header");
g(this, "fields", []);
g(this, "recordStartOffset", 0);
g(this, "recordSize", 0);
g(this, "decoder");
y(this, "stream");
y(this, "header");
y(this, "fields", []);
y(this, "recordStartOffset", 0);
y(this, "recordSize", 0);
y(this, "decoder");
this.stream = new X(e), this.decoder = t, this.header = this.readHeader();

@@ -296,3 +296,3 @@ }

type: i,
typeName: ye[i] || "Unknown",
typeName: ge[i] || "Unknown",
fieldLen: u,

@@ -356,3 +356,3 @@ decimalCount: a

var w = /* @__PURE__ */ ((r) => (r[r.Null = 0] = "Null", r[r.Point = 1] = "Point", r[r.PolyLine = 3] = "PolyLine", r[r.Polygon = 5] = "Polygon", r[r.MultiPoint = 8] = "MultiPoint", r[r.PointZ = 11] = "PointZ", r[r.PolyLineZ = 13] = "PolyLineZ", r[r.PolygonZ = 15] = "PolygonZ", r[r.MultiPointZ = 18] = "MultiPointZ", r[r.PointM = 21] = "PointM", r[r.PolyLineM = 23] = "PolyLineM", r[r.PolygonM = 25] = "PolygonM", r[r.MultiPointM = 28] = "MultiPointM", r[r.MultiPatch = 31] = "MultiPatch", r))(w || {});
class P {
class m {
static coordType(e) {

@@ -362,6 +362,6 @@ return e === 0 ? v.NULL : e < 10 ? v.XY : e < 20 ? v.XYZM : e < 30 ? v.XYM : e < 40 ? v.XYZM : v.NULL;

static hasZ(e) {
return P.coordType(e) === v.XYZM;
return m.coordType(e) === v.XYZM;
}
static hasM(e) {
const t = P.coordType(e);
const t = m.coordType(e);
return t === v.XYZM || t === v.XYM;

@@ -377,2 +377,5 @@ }

}
get type() {
return "MultiPoint";
}
static fromPresetReader(e, t) {

@@ -385,3 +388,3 @@ const n = e.hasZ, s = e.hasM, o = e.shpStream;

const l = Z.getCoords(a, c, i, u);
return new Z(l, P.coordType(t.type));
return new Z(l, m.coordType(t.type));
}

@@ -412,6 +415,9 @@ static getZValues(e, t) {

}
class ge extends z {
class ye extends z {
constructor() {
super(v.NULL);
}
get type() {
return "Null";
}
toGeoJson() {

@@ -425,5 +431,8 @@ throw new Error("Method cannot be implemented.");

}
get type() {
return "Point";
}
static fromPresetReader(e, t) {
const n = e.hasZ, s = e.hasM, o = e.shpStream, i = [];
return i.push(o.readDouble(!0)), i.push(o.readDouble(!0)), s && (n && i.push(o.readDouble(!0)), i.push(o.readDouble(!0))), new j(i, P.coordType(t.type));
return i.push(o.readDouble(!0)), i.push(o.readDouble(!0)), s && (n && i.push(o.readDouble(!0)), i.push(o.readDouble(!0))), new j(i, m.coordType(t.type));
}

@@ -475,2 +484,5 @@ toGeoJson() {

}
get type() {
return this.coords.length === 1 ? "Polygon" : "MultiPolygon";
}
static fromPresetReader(e, t) {

@@ -483,3 +495,3 @@ const n = e.hasZ, s = e.hasM, o = e.shpStream;

const f = D.getCoords(l, h, i, u), M = se(f);
return new D(M, P.coordType(t.type));
return new D(M, m.coordType(t.type));
}

@@ -511,2 +523,5 @@ toGeoJson() {

}
get type() {
return this.coords.length === 1 ? "LineString" : "MultiLineString";
}
static fromPresetReader(e, t) {

@@ -519,3 +534,3 @@ const n = e.hasZ, s = e.hasM, o = e.shpStream;

const f = S.getCoords(l, h, i, u);
return new S(f, P.coordType(t.type));
return new S(f, m.coordType(t.type));
}

@@ -539,16 +554,19 @@ toGeoJson() {

}
class m extends R {
class P extends R {
constructor(e, t) {
super(t), this.coords = e;
}
get type() {
return this.coords.length === 1 ? "Polygon" : "MultiPolygon";
}
static fromPresetReader(e, t) {
const n = e.hasZ, s = e.hasM, o = e.shpStream;
let i, u;
m.readBbox(o);
P.readBbox(o);
const a = o.readInt32(!0), c = o.readInt32(!0), l = o.readInt32Array(a, !0), h = o.readInt32Array(a, !0), f = o.readDoubleArray(c * 2, !0);
n && (i = m.getZValues(o, c)), s && (u = m.getMValues(o, c));
const M = m.getCoords(l, f, i, u), y = m.assemblePolygonsWithHoles(M, h);
return new m(
y,
P.coordType(t.type)
n && (i = P.getZValues(o, c)), s && (u = P.getMValues(o, c));
const M = P.getCoords(l, f, i, u), g = P.assemblePolygonsWithHoles(M, h);
return new P(
g,
m.coordType(t.type)
);

@@ -561,16 +579,16 @@ }

if (t[i] === 0)
m.closePolygon(s, n), n.push(...m.triangleStripToPolygon(e[i])), o = !1;
P.closePolygon(s, n), n.push(...P.triangleStripToPolygon(e[i])), o = !1;
else if (t[i] === 1)
m.closePolygon(s, n), n.push(...m.triangleFanToPolygon(e[i])), o = !1;
P.closePolygon(s, n), n.push(...P.triangleFanToPolygon(e[i])), o = !1;
else if (t[i] === 2)
m.closePolygon(s, n), s.push(e[i]), o = !1;
P.closePolygon(s, n), s.push(e[i]), o = !1;
else if (t[i] === 3)
s.push(e[i]), o = !1;
else if (t[i] === 4)
m.closePolygon(s, n), s.push(e[i]), o = !0;
P.closePolygon(s, n), s.push(e[i]), o = !0;
else if (t[i] === 5)
o || m.closePolygon(s, n), s.push(e[i]);
o || P.closePolygon(s, n), s.push(e[i]);
else
throw new Error(`Invalid part type in MultiPatch: ${t[i]}`);
return m.closePolygon(s, n), n;
return P.closePolygon(s, n), n;
}

@@ -618,12 +636,12 @@ static closePolygon(e, t) {

constructor(e, t) {
g(this, "shxStream");
g(this, "shxHeader");
g(this, "shpHeader");
g(this, "shpStream");
g(this, "recordCount", 0);
g(this, "hasZ");
g(this, "hasM");
y(this, "shxStream");
y(this, "shxHeader");
y(this, "shpHeader");
y(this, "shpStream");
y(this, "recordCount", 0);
y(this, "hasZ");
y(this, "hasM");
if (this.shpStream = new X(e), this.shpHeader = this.readHeader(this.shpStream), this.shxStream = new X(t), this.shxHeader = this.readHeader(this.shxStream), this.shpHeader.type !== this.shxHeader.type)
throw new Error("SHP / SHX shapetype mismatch");
this.recordCount = (this.shxHeader.fileLength - 100) / 8, this.hasZ = P.hasZ(this.shpHeader.type), this.hasM = P.hasM(this.shpHeader.type);
this.recordCount = (this.shxHeader.fileLength - 100) / 8, this.hasZ = m.hasZ(this.shpHeader.type), this.hasM = m.hasM(this.shpHeader.type);
}

@@ -684,3 +702,3 @@ static async fromFile(e, t) {

case w.Null:
return new ge();
return new ye();
case w.Point:

@@ -710,3 +728,3 @@ case w.PointZ:

throw new Error(
`Unexpected shape type ${P.shapeTypeStr(e.type)}(${e.type}), expected ${P.shapeTypeStr(this.shpHeader.type)}`
`Unexpected shape type ${m.shapeTypeStr(e.type)}(${e.type}), expected ${m.shapeTypeStr(this.shpHeader.type)}`
);

@@ -727,3 +745,3 @@ }

readMultiPatch(e) {
return m.fromPresetReader(this, e);
return P.fromPresetReader(this, e);
}

@@ -733,3 +751,3 @@ }

constructor() {
g(this, "features", []);
y(this, "features", []);
}

@@ -743,6 +761,6 @@ toGeoJson() {

}
class me {
class Pe {
constructor(e, t, n) {
g(this, "geom");
g(this, "properties", {});
y(this, "geom");
y(this, "properties", {});
if (this.geom = e, !(!t || !n))

@@ -762,4 +780,4 @@ for (let s = 0; s < n.length; s++)

constructor(e, t) {
g(this, "shpReader");
g(this, "dbfReader");
y(this, "shpReader");
y(this, "dbfReader");
if (e.recordCount !== (t == null ? void 0 : t.recordCount))

@@ -797,3 +815,3 @@ throw new Error(

let n = [];
return this.dbfReader != null && (n = this.dbfReader.readRecord(e)), t == null ? null : new me(t, n, (s = this.dbfReader) == null ? void 0 : s.fields);
return this.dbfReader != null && (n = this.dbfReader.readRecord(e)), t == null ? null : new Pe(t, n, (s = this.dbfReader) == null ? void 0 : s.fields);
}

@@ -817,4 +835,4 @@ readFeatureCollection() {

u = c = r[0], a = l = r[1];
for (var y = t; y < s; y += t)
h = r[y], f = r[y + 1], h < u && (u = h), f < a && (a = f), h > c && (c = h), f > l && (l = f);
for (var g = t; g < s; g += t)
h = r[g], f = r[g + 1], h < u && (u = h), f < a && (a = f), h > c && (c = h), f > l && (l = f);
M = Math.max(c - u, l - a), M = M !== 0 ? 32767 / M : 0;

@@ -853,3 +871,3 @@ }

for (var u = r, a, c; r.prev !== r.next; ) {
if (a = r.prev, c = r.next, o ? Ee(r, n, s, o) : Pe(r)) {
if (a = r.prev, c = r.next, o ? Ee(r, n, s, o) : me(r)) {
e.push(a.i / t | 0), e.push(r.i / t | 0), e.push(c.i / t | 0), b(r), r = c.next, u = c.next;

@@ -865,10 +883,10 @@ continue;

}
function Pe(r) {
function me(r) {
var e = r.prev, t = r, n = r.next;
if (p(e, t, n) >= 0)
return !1;
for (var s = e.x, o = t.x, i = n.x, u = e.y, a = t.y, c = n.y, l = s < o ? s < i ? s : i : o < i ? o : i, h = u < a ? u < c ? u : c : a < c ? a : c, f = s > o ? s > i ? s : i : o > i ? o : i, M = u > a ? u > c ? u : c : a > c ? a : c, y = n.next; y !== e; ) {
if (y.x >= l && y.x <= f && y.y >= h && y.y <= M && O(s, u, o, a, i, c, y.x, y.y) && p(y.prev, y, y.next) >= 0)
for (var s = e.x, o = t.x, i = n.x, u = e.y, a = t.y, c = n.y, l = s < o ? s < i ? s : i : o < i ? o : i, h = u < a ? u < c ? u : c : a < c ? a : c, f = s > o ? s > i ? s : i : o > i ? o : i, M = u > a ? u > c ? u : c : a > c ? a : c, g = n.next; g !== e; ) {
if (g.x >= l && g.x <= f && g.y >= h && g.y <= M && O(s, u, o, a, i, c, g.x, g.y) && p(g.prev, g, g.next) >= 0)
return !1;
y = y.next;
g = g.next;
}

@@ -881,4 +899,4 @@ return !0;

return !1;
for (var u = s.x, a = o.x, c = i.x, l = s.y, h = o.y, f = i.y, M = u < a ? u < c ? u : c : a < c ? a : c, y = l < h ? l < f ? l : f : h < f ? h : f, B = u > a ? u > c ? u : c : a > c ? a : c, I = l > h ? l > f ? l : f : h > f ? h : f, Q = $(M, y, e, t, n), T = $(B, I, e, t, n), d = r.prevZ, x = r.nextZ; d && d.z >= Q && x && x.z <= T; ) {
if (d.x >= M && d.x <= B && d.y >= y && d.y <= I && d !== s && d !== i && O(u, l, a, h, c, f, d.x, d.y) && p(d.prev, d, d.next) >= 0 || (d = d.prevZ, x.x >= M && x.x <= B && x.y >= y && x.y <= I && x !== s && x !== i && O(u, l, a, h, c, f, x.x, x.y) && p(x.prev, x, x.next) >= 0))
for (var u = s.x, a = o.x, c = i.x, l = s.y, h = o.y, f = i.y, M = u < a ? u < c ? u : c : a < c ? a : c, g = l < h ? l < f ? l : f : h < f ? h : f, B = u > a ? u > c ? u : c : a > c ? a : c, I = l > h ? l > f ? l : f : h > f ? h : f, Q = $(M, g, e, t, n), T = $(B, I, e, t, n), d = r.prevZ, x = r.nextZ; d && d.z >= Q && x && x.z <= T; ) {
if (d.x >= M && d.x <= B && d.y >= g && d.y <= I && d !== s && d !== i && O(u, l, a, h, c, f, d.x, d.y) && p(d.prev, d, d.next) >= 0 || (d = d.prevZ, x.x >= M && x.x <= B && x.y >= g && x.y <= I && x !== s && x !== i && O(u, l, a, h, c, f, x.x, x.y) && p(x.prev, x, x.next) >= 0))
return !1;

@@ -888,3 +906,3 @@ x = x.nextZ;

for (; d && d.z >= Q; ) {
if (d.x >= M && d.x <= B && d.y >= y && d.y <= I && d !== s && d !== i && O(u, l, a, h, c, f, d.x, d.y) && p(d.prev, d, d.next) >= 0)
if (d.x >= M && d.x <= B && d.y >= g && d.y <= I && d !== s && d !== i && O(u, l, a, h, c, f, d.x, d.y) && p(d.prev, d, d.next) >= 0)
return !1;

@@ -894,3 +912,3 @@ d = d.prevZ;

for (; x && x.z <= T; ) {
if (x.x >= M && x.x <= B && x.y >= y && x.y <= I && x !== s && x !== i && O(u, l, a, h, c, f, x.x, x.y) && p(x.prev, x, x.next) >= 0)
if (x.x >= M && x.x <= B && x.y >= g && x.y <= I && x !== s && x !== i && O(u, l, a, h, c, f, x.x, x.y) && p(x.prev, x, x.next) >= 0)
return !1;

@@ -1061,5 +1079,5 @@ x = x.nextZ;

for (u = 0; u < n.length; u += 3) {
var f = n[u] * t, M = n[u + 1] * t, y = n[u + 2] * t;
var f = n[u] * t, M = n[u + 1] * t, g = n[u + 2] * t;
h += Math.abs(
(r[f] - r[y]) * (r[M + 1] - r[f + 1]) - (r[f] - r[M]) * (r[y + 1] - r[f + 1])
(r[f] - r[g]) * (r[M + 1] - r[f + 1]) - (r[f] - r[M]) * (r[g + 1] - r[f + 1])
);

@@ -1183,6 +1201,6 @@ }

V as DbfRecord,
me as Feature,
Pe as Feature,
we as FeatureCollection,
U as FeatureReader,
m as MultiPatchRecord,
P as MultiPatchRecord,
Z as MultiPointRecord,

@@ -1189,0 +1207,0 @@ j as PointRecord,

{
"name": "shpts",
"private": false,
"version": "1.0.5",
"version": "1.0.6",
"type": "module",

@@ -6,0 +6,0 @@ "repository": {

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