Comparing version 1.0.9 to 1.1.0
import { Coord, CoordType } from '../types/coordinate'; | ||
import { GeoJsonGeom } from '../types/geojson'; | ||
import { BoundingBox } from '../types/data'; | ||
import { BoundingBox, GeomHeader } from '../types/data'; | ||
import { MemoryStream } from '../utils/stream'; | ||
export declare abstract class BaseRecord { | ||
readonly coordType: CoordType; | ||
constructor(coordType: CoordType); | ||
private hasMValuesPresent; | ||
constructor(coordType: CoordType, hasMValuesPresent: boolean); | ||
abstract toGeoJson(): GeoJsonGeom; | ||
get hasZ(): boolean; | ||
get hasOptionalM(): boolean; | ||
get hasM(): boolean; | ||
@@ -14,2 +16,3 @@ get coordLength(): number; | ||
protected static readBbox(stream: MemoryStream): BoundingBox; | ||
static recordReadingFinalized(shpStream: MemoryStream, header: GeomHeader): boolean; | ||
} | ||
@@ -16,0 +19,0 @@ export declare abstract class BaseRingedRecord extends BaseRecord { |
@@ -8,3 +8,3 @@ import { CoordType, MultiPatchCoord } from '../types/coordinate'; | ||
coords: MultiPatchCoord; | ||
constructor(coords: MultiPatchCoord, coordType: CoordType); | ||
constructor(coords: MultiPatchCoord, coordType: CoordType, hasMValuesPresent: boolean); | ||
get type(): "Polygon" | "MultiPolygon"; | ||
@@ -11,0 +11,0 @@ static fromPresetReader(reader: ShapeReader, header: GeomHeader): MultiPatchRecord; |
@@ -8,3 +8,3 @@ import { ShapeReader } from '../reader/shpReader'; | ||
coords: MultiPointCoord; | ||
constructor(coords: MultiPointCoord, coordType: CoordType); | ||
constructor(coords: MultiPointCoord, coordType: CoordType, hasMValuesPresent: boolean); | ||
get type(): string; | ||
@@ -11,0 +11,0 @@ static fromPresetReader(reader: ShapeReader, header: GeomHeader): MultiPointRecord; |
@@ -8,3 +8,3 @@ import { ShapeReader } from '../reader/shpReader'; | ||
coords: PointCoord; | ||
constructor(coords: PointCoord, coordType: CoordType); | ||
constructor(coords: PointCoord, coordType: CoordType, hasMValuesPresent: boolean); | ||
get type(): string; | ||
@@ -11,0 +11,0 @@ static fromPresetReader(reader: ShapeReader, header: GeomHeader): PointRecord; |
@@ -8,3 +8,3 @@ import { ShapeReader } from '../reader/shpReader'; | ||
coords: PolygonCoord; | ||
constructor(coords: PolygonCoord, coordType: CoordType); | ||
constructor(coords: PolygonCoord, coordType: CoordType, hasMValuesPresent: boolean); | ||
get type(): "Polygon" | "MultiPolygon"; | ||
@@ -11,0 +11,0 @@ static fromPresetReader(reader: ShapeReader, header: GeomHeader): PolygonRecord; |
@@ -8,3 +8,3 @@ import { ShapeReader } from '../reader/shpReader'; | ||
coords: PolyLineCoord; | ||
constructor(coords: PolyLineCoord, coordType: CoordType); | ||
constructor(coords: PolyLineCoord, coordType: CoordType, hasMValuesPresent: boolean); | ||
get type(): "LineString" | "MultiLineString"; | ||
@@ -11,0 +11,0 @@ static fromPresetReader(reader: ShapeReader, header: GeomHeader): PolyLineRecord; |
@@ -16,3 +16,3 @@ import { MultiPointRecord } from '../geometry/multipoint'; | ||
readonly hasZ: boolean; | ||
readonly hasM: boolean; | ||
readonly hasOptionalM: boolean; | ||
private constructor(); | ||
@@ -19,0 +19,0 @@ static fromFile(shp: File, shx: File): Promise<ShapeReader>; |
@@ -16,3 +16,4 @@ import { DbfReader } from './reader/dbfReader'; | ||
import { BaseRecord } from './geometry/base'; | ||
import { ShapeType } from './utils/geometry'; | ||
export { DbfReader, DbfRecord, ShapeReader, FeatureCollection, Feature, FeatureReader, PolygonRecord, PolyLineRecord, PointRecord, MultiPointRecord, MultiPatchRecord, CoordType, BaseRecord, triangulate, }; | ||
export type { DbfFieldType, DbfFieldDescr, Coord }; | ||
export type { DbfFieldType, DbfFieldDescr, Coord, ShapeType }; |
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 y = (r, e, t) => (ce(r, typeof e != "symbol" ? e + "" : e, t), t); | ||
var p = (r, e, t) => (ce(r, typeof e != "symbol" ? e + "" : e, t), t); | ||
class X { | ||
constructor(e) { | ||
y(this, "dataView"); | ||
y(this, "offset", 0); | ||
y(this, "size", 0); | ||
p(this, "dataView"); | ||
p(this, "offset", 0); | ||
p(this, "size", 0); | ||
this.size = e.byteLength, this.dataView = new DataView(e); | ||
@@ -121,4 +121,4 @@ } | ||
constructor(e) { | ||
y(this, "encoding"); | ||
y(this, "decoder"); | ||
p(this, "encoding"); | ||
p(this, "decoder"); | ||
this.encoding = e, this.decoder = new TextDecoder(e); | ||
@@ -153,3 +153,3 @@ } | ||
} | ||
function xe(r) { | ||
function ge(r) { | ||
if (r === 0) | ||
@@ -226,4 +226,4 @@ return new L("cp1252"); | ||
let V = E; | ||
y(V, "regExDate", /^(\d\d\d\d)(\d\d)(\d\d)$/); | ||
const ge = { | ||
p(V, "regExDate", /^(\d\d\d\d)(\d\d)(\d\d)$/); | ||
const xe = { | ||
C: "Character", | ||
@@ -237,8 +237,8 @@ N: "Number", | ||
constructor(e, t) { | ||
y(this, "stream"); | ||
y(this, "header"); | ||
y(this, "fields", []); | ||
y(this, "recordStartOffset", 0); | ||
y(this, "recordSize", 0); | ||
y(this, "decoder"); | ||
p(this, "stream"); | ||
p(this, "header"); | ||
p(this, "fields", []); | ||
p(this, "recordStartOffset", 0); | ||
p(this, "recordSize", 0); | ||
p(this, "decoder"); | ||
this.stream = new X(e), this.decoder = t, this.header = this.readHeader(); | ||
@@ -272,3 +272,3 @@ } | ||
const u = e.seek(29).readByte(); | ||
return this.decoder || (this.decoder = xe(u)), this.readFields(e), this.computeRecordSize(e), { | ||
return this.decoder || (this.decoder = ge(u)), this.readFields(e), this.computeRecordSize(e), { | ||
lastUpdated: new Date(n + 1900, s, o), | ||
@@ -298,3 +298,3 @@ recordCount: i, | ||
type: i, | ||
typeName: ge[i] || "Unknown", | ||
typeName: xe[i] || "Unknown", | ||
fieldLen: u, | ||
@@ -314,5 +314,5 @@ decimalCount: a | ||
var v = /* @__PURE__ */ ((r) => (r[r.NULL = 0] = "NULL", r[r.XY = 2] = "XY", r[r.XYM = 3] = "XYM", r[r.XYZM = 4] = "XYZM", r))(v || {}); | ||
class z { | ||
constructor(e) { | ||
this.coordType = e; | ||
class G { | ||
constructor(e, t) { | ||
this.coordType = e, this.hasMValuesPresent = t; | ||
} | ||
@@ -322,5 +322,8 @@ get hasZ() { | ||
} | ||
get hasM() { | ||
get hasOptionalM() { | ||
return this.coordType === v.XYM || this.coordType === v.XYZM; | ||
} | ||
get hasM() { | ||
return this.hasMValuesPresent; | ||
} | ||
get coordLength() { | ||
@@ -338,4 +341,7 @@ return this.coordType === v.XY ? 2 : this.coordType === v.XYM ? 3 : 4; | ||
} | ||
static recordReadingFinalized(e, t) { | ||
return e.tell === t.offset + (4 + t.length) * 2; | ||
} | ||
} | ||
class R extends z { | ||
class W extends G { | ||
static getZValues(e, t) { | ||
@@ -368,3 +374,3 @@ return e.readDouble(!0), e.readDouble(!0), e.readDoubleArray(t, !0); | ||
} | ||
static hasM(e) { | ||
static hasOptionalM(e) { | ||
const t = m.coordType(e); | ||
@@ -377,5 +383,5 @@ return t === v.XYZM || t === v.XYM; | ||
} | ||
class Z extends z { | ||
constructor(e, t) { | ||
super(t), this.coords = e; | ||
class D extends G { | ||
constructor(e, t, n) { | ||
super(t, n), this.coords = e; | ||
} | ||
@@ -386,9 +392,15 @@ get type() { | ||
static fromPresetReader(e, t) { | ||
const n = e.hasZ, s = e.hasM, o = e.shpStream; | ||
const n = e.hasZ, s = e.hasOptionalM, o = e.shpStream; | ||
let i, u; | ||
Z.readBbox(o); | ||
D.readBbox(o); | ||
const a = o.readInt32(!0), c = o.readDoubleArray(a * 2, !0); | ||
n && (i = Z.getZValues(o, a)), s && (u = Z.getMValues(o, a)); | ||
const l = Z.getCoords(a, c, i, u); | ||
return new Z(l, m.coordType(t.type)); | ||
n && (i = D.getZValues(o, a)); | ||
const l = !this.recordReadingFinalized(o, t) && s; | ||
l && (u = D.getMValues(o, a)); | ||
const h = D.getCoords(a, c, i, u); | ||
return new D( | ||
h, | ||
m.coordType(t.type), | ||
l | ||
); | ||
} | ||
@@ -419,5 +431,5 @@ static getZValues(e, t) { | ||
} | ||
class ye extends z { | ||
class ye extends G { | ||
constructor() { | ||
super(v.NULL); | ||
super(v.NULL, !1); | ||
} | ||
@@ -431,5 +443,5 @@ get type() { | ||
} | ||
class j extends z { | ||
constructor(e, t) { | ||
super(t), this.coords = e; | ||
class j extends G { | ||
constructor(e, t, n) { | ||
super(t, n), this.coords = e; | ||
} | ||
@@ -440,4 +452,6 @@ get type() { | ||
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, m.coordType(t.type)); | ||
const n = e.hasZ, s = e.hasOptionalM, o = e.shpStream, i = []; | ||
i.push(o.readDouble(!0)), i.push(o.readDouble(!0)), n && i.push(o.readDouble(!0)); | ||
const u = !this.recordReadingFinalized(o, t) && s; | ||
return u && i.push(o.readDouble(!0)), new j(i, m.coordType(t.type), u); | ||
} | ||
@@ -485,5 +499,5 @@ toGeoJson() { | ||
} | ||
class D extends R { | ||
constructor(e, t) { | ||
super(t), this.coords = e; | ||
class O extends W { | ||
constructor(e, t, n) { | ||
super(t, n), this.coords = e; | ||
} | ||
@@ -494,9 +508,11 @@ get type() { | ||
static fromPresetReader(e, t) { | ||
const n = e.hasZ, s = e.hasM, o = e.shpStream; | ||
const n = e.hasZ, s = e.hasOptionalM, o = e.shpStream; | ||
let i, u; | ||
D.readBbox(o); | ||
O.readBbox(o); | ||
const a = o.readInt32(!0), c = o.readInt32(!0), l = o.readInt32Array(a, !0), h = o.readDoubleArray(c * 2, !0); | ||
n && (i = D.getZValues(o, c)), s && (u = D.getMValues(o, c)); | ||
const f = D.getCoords(l, h, i, u), M = se(f); | ||
return new D(M, m.coordType(t.type)); | ||
n && (i = O.getZValues(o, c)); | ||
const f = !this.recordReadingFinalized(o, t) && s; | ||
f && (u = O.getMValues(o, c)); | ||
const y = O.getCoords(l, h, i, u), d = se(y); | ||
return new O(d, m.coordType(t.type), f); | ||
} | ||
@@ -524,5 +540,5 @@ toGeoJson() { | ||
} | ||
class S extends R { | ||
constructor(e, t) { | ||
super(t), this.coords = e; | ||
class S extends W { | ||
constructor(e, t, n) { | ||
super(t, n), this.coords = e; | ||
} | ||
@@ -533,9 +549,11 @@ get type() { | ||
static fromPresetReader(e, t) { | ||
const n = e.hasZ, s = e.hasM, o = e.shpStream; | ||
const n = e.hasZ, s = e.hasOptionalM, o = e.shpStream; | ||
let i, u; | ||
S.readBbox(o); | ||
const a = o.readInt32(!0), c = o.readInt32(!0), l = o.readInt32Array(a, !0), h = o.readDoubleArray(c * 2, !0); | ||
n && (i = S.getZValues(o, c)), s && (u = S.getMValues(o, c)); | ||
const f = S.getCoords(l, h, i, u); | ||
return new S(f, m.coordType(t.type)); | ||
n && (i = S.getZValues(o, c)); | ||
const f = !this.recordReadingFinalized(o, t) && s; | ||
f && (u = S.getMValues(o, c)); | ||
const y = S.getCoords(l, h, i, u); | ||
return new S(y, m.coordType(t.type), f); | ||
} | ||
@@ -559,5 +577,5 @@ toGeoJson() { | ||
} | ||
class P extends R { | ||
constructor(e, t) { | ||
super(t), this.coords = e; | ||
class P extends W { | ||
constructor(e, t, n) { | ||
super(t, n), this.coords = e; | ||
} | ||
@@ -568,11 +586,14 @@ get type() { | ||
static fromPresetReader(e, t) { | ||
const n = e.hasZ, s = e.hasM, o = e.shpStream; | ||
const n = e.hasZ, s = e.hasOptionalM, o = e.shpStream; | ||
let i, u; | ||
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 = P.getZValues(o, c)), s && (u = P.getMValues(o, c)); | ||
const M = P.getCoords(l, f, i, u), g = P.assemblePolygonsWithHoles(M, h); | ||
n && (i = P.getZValues(o, c)); | ||
const y = !this.recordReadingFinalized(o, t) && s; | ||
y && (u = P.getMValues(o, c)); | ||
const d = P.getCoords(l, f, i, u), Z = P.assemblePolygonsWithHoles(d, h); | ||
return new P( | ||
g, | ||
m.coordType(t.type) | ||
Z, | ||
m.coordType(t.type), | ||
y | ||
); | ||
@@ -639,14 +660,14 @@ } | ||
} | ||
class G { | ||
class z { | ||
constructor(e, t) { | ||
y(this, "shxStream"); | ||
y(this, "shxHeader"); | ||
y(this, "shpHeader"); | ||
y(this, "shpStream"); | ||
y(this, "recordCount", 0); | ||
y(this, "hasZ"); | ||
y(this, "hasM"); | ||
p(this, "shxStream"); | ||
p(this, "shxHeader"); | ||
p(this, "shpHeader"); | ||
p(this, "shpStream"); | ||
p(this, "recordCount", 0); | ||
p(this, "hasZ"); | ||
p(this, "hasOptionalM"); | ||
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 = m.hasZ(this.shpHeader.type), this.hasM = m.hasM(this.shpHeader.type); | ||
this.recordCount = (this.shxHeader.fileLength - 100) / 8, this.hasZ = m.hasZ(this.shpHeader.type), this.hasOptionalM = m.hasOptionalM(this.shpHeader.type); | ||
} | ||
@@ -658,3 +679,3 @@ static async fromFile(e, t) { | ||
static async fromArrayBuffer(e, t) { | ||
return new G(e, t); | ||
return new z(e, t); | ||
} | ||
@@ -675,7 +696,8 @@ readHeader(e) { | ||
readGeomHeader() { | ||
const e = this.shpStream.readInt32(!1), t = this.shpStream.readInt32(!1), n = this.shpStream.readInt32(!0); | ||
const e = this.shpStream.tell, t = this.shpStream.readInt32(!1), n = this.shpStream.readInt32(!1), s = this.shpStream.readInt32(!0); | ||
return { | ||
length: t, | ||
recordNum: e, | ||
type: n | ||
offset: e, | ||
length: n, | ||
recordNum: t, | ||
type: s | ||
}; | ||
@@ -741,3 +763,3 @@ } | ||
readMultiPoint(e) { | ||
return Z.fromPresetReader(this, e); | ||
return D.fromPresetReader(this, e); | ||
} | ||
@@ -748,3 +770,3 @@ readPolyLine(e) { | ||
readPolygon(e) { | ||
return D.fromPresetReader(this, e); | ||
return O.fromPresetReader(this, e); | ||
} | ||
@@ -757,3 +779,3 @@ readMultiPatch(e) { | ||
constructor() { | ||
y(this, "features", []); | ||
p(this, "features", []); | ||
} | ||
@@ -769,4 +791,4 @@ toGeoJson() { | ||
constructor(e, t, n) { | ||
y(this, "geom"); | ||
y(this, "properties", {}); | ||
p(this, "geom"); | ||
p(this, "properties", {}); | ||
if (this.geom = e, !(!t || !n)) | ||
@@ -786,4 +808,4 @@ for (let s = 0; s < n.length; s++) | ||
constructor(e, t) { | ||
y(this, "shpReader"); | ||
y(this, "dbfReader"); | ||
p(this, "shpReader"); | ||
p(this, "dbfReader"); | ||
if (t && e.recordCount !== (t == null ? void 0 : t.recordCount)) | ||
@@ -806,3 +828,3 @@ throw new Error( | ||
static async fromArrayBuffers(e, t, n, s) { | ||
const o = await G.fromArrayBuffer(e, t); | ||
const o = await z.fromArrayBuffer(e, t); | ||
let i; | ||
@@ -812,3 +834,3 @@ return n != null && (i = await H.fromArrayBuffer(n, s)), new U(o, i); | ||
static async fromFiles(e, t, n, s) { | ||
const o = await G.fromFile(e, t); | ||
const o = await z.fromFile(e, t); | ||
let i; | ||
@@ -839,14 +861,14 @@ return n != null && (i = await H.fromFile(n, s)), new U(o, i); | ||
return i; | ||
var u, a, c, l, h, f, M; | ||
if (n && (o = Se(r, e, o, t)), r.length > 80 * t) { | ||
var u, a, c, l, h, f, y; | ||
if (n && (o = Oe(r, e, o, t)), r.length > 80 * t) { | ||
u = c = r[0], a = l = r[1]; | ||
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; | ||
for (var d = t; d < s; d += t) | ||
h = r[d], f = r[d + 1], h < u && (u = h), f < a && (a = f), h > c && (c = h), f > l && (l = f); | ||
y = Math.max(c - u, l - a), y = y !== 0 ? 32767 / y : 0; | ||
} | ||
return k(o, i, t, u, a, M, 0), i; | ||
return k(o, i, t, u, a, y, 0), i; | ||
} | ||
function oe(r, e, t, n, s) { | ||
var o, i; | ||
if (s === W(r, e, t, n) > 0) | ||
if (s === J(r, e, t, n) > 0) | ||
for (o = e; o < t; o += n) | ||
@@ -857,3 +879,3 @@ i = _(o, r[o], r[o + 1], i); | ||
i = _(o, r[o], r[o + 1], i); | ||
return i && Y(i, i.next) && (b(i), i = i.next), i; | ||
return i && Y(i, i.next) && (A(i), i = i.next), i; | ||
} | ||
@@ -866,4 +888,4 @@ function C(r, e) { | ||
do | ||
if (n = !1, !t.steiner && (Y(t, t.next) || p(t.prev, t, t.next) === 0)) { | ||
if (b(t), t = e = t.prev, t === t.next) | ||
if (n = !1, !t.steiner && (Y(t, t.next) || M(t.prev, t, t.next) === 0)) { | ||
if (A(t), t = e = t.prev, t === t.next) | ||
break; | ||
@@ -881,3 +903,3 @@ n = !0; | ||
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; | ||
e.push(a.i / t | 0), e.push(r.i / t | 0), e.push(c.i / t | 0), A(r), r = c.next, u = c.next; | ||
continue; | ||
@@ -894,8 +916,8 @@ } | ||
var e = r.prev, t = r, n = r.next; | ||
if (p(e, t, n) >= 0) | ||
if (M(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, 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) | ||
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, y = u > a ? u > c ? u : c : a > c ? a : c, d = n.next; d !== e; ) { | ||
if (d.x >= l && d.x <= f && d.y >= h && d.y <= y && B(s, u, o, a, i, c, d.x, d.y) && M(d.prev, d, d.next) >= 0) | ||
return !1; | ||
g = g.next; | ||
d = d.next; | ||
} | ||
@@ -906,16 +928,16 @@ return !0; | ||
var s = r.prev, o = r, i = r.next; | ||
if (p(s, o, i) >= 0) | ||
if (M(s, o, i) >= 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, 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)) | ||
for (var u = s.x, a = o.x, c = i.x, l = s.y, h = o.y, f = i.y, y = u < a ? u < c ? u : c : a < c ? a : c, d = l < h ? l < f ? l : f : h < f ? h : f, Z = u > a ? u > c ? u : c : a > c ? a : c, I = l > h ? l > f ? l : f : h > f ? h : f, Q = $(y, d, e, t, n), T = $(Z, I, e, t, n), g = r.prevZ, x = r.nextZ; g && g.z >= Q && x && x.z <= T; ) { | ||
if (g.x >= y && g.x <= Z && g.y >= d && g.y <= I && g !== s && g !== i && B(u, l, a, h, c, f, g.x, g.y) && M(g.prev, g, g.next) >= 0 || (g = g.prevZ, x.x >= y && x.x <= Z && x.y >= d && x.y <= I && x !== s && x !== i && B(u, l, a, h, c, f, x.x, x.y) && M(x.prev, x, x.next) >= 0)) | ||
return !1; | ||
x = x.nextZ; | ||
} | ||
for (; d && d.z >= Q; ) { | ||
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) | ||
for (; g && g.z >= Q; ) { | ||
if (g.x >= y && g.x <= Z && g.y >= d && g.y <= I && g !== s && g !== i && B(u, l, a, h, c, f, g.x, g.y) && M(g.prev, g, g.next) >= 0) | ||
return !1; | ||
d = d.prevZ; | ||
g = g.prevZ; | ||
} | ||
for (; x && x.z <= T; ) { | ||
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) | ||
if (x.x >= y && x.x <= Z && x.y >= d && x.y <= I && x !== s && x !== i && B(u, l, a, h, c, f, x.x, x.y) && M(x.prev, x, x.next) >= 0) | ||
return !1; | ||
@@ -930,3 +952,3 @@ x = x.nextZ; | ||
var s = n.prev, o = n.next.next; | ||
!Y(s, o) && ie(s, n, n.next, o) && A(s, o) && A(o, s) && (e.push(s.i / t | 0), e.push(n.i / t | 0), e.push(o.i / t | 0), b(n), b(n.next), n = r = o), n = n.next; | ||
!Y(s, o) && ie(s, n, n.next, o) && F(s, o) && F(o, s) && (e.push(s.i / t | 0), e.push(n.i / t | 0), e.push(o.i / t | 0), A(n), A(n.next), n = r = o), n = n.next; | ||
} while (n !== r); | ||
@@ -939,3 +961,3 @@ return C(n); | ||
for (var u = i.next.next; u !== i.prev; ) { | ||
if (i.i !== u.i && be(i, u)) { | ||
if (i.i !== u.i && Ae(i, u)) { | ||
var a = ue(i, u); | ||
@@ -950,15 +972,15 @@ i = C(i, i.next), a = C(a, a.next), k(i, e, t, n, s, o, 0), k(a, e, t, n, s, o, 0); | ||
} | ||
function Se(r, e, t, n) { | ||
function Oe(r, e, t, n) { | ||
var s = [], o, i, u, a, c; | ||
for (o = 0, i = e.length; o < i; o++) | ||
u = e[o] * n, a = o < i - 1 ? e[o + 1] * n : r.length, c = oe(r, u, a, n, !1), c === c.next && (c.steiner = !0), s.push(Ae(c)); | ||
for (s.sort(Ce), o = 0; o < s.length; o++) | ||
t = Le(s[o], t); | ||
u = e[o] * n, a = o < i - 1 ? e[o + 1] * n : r.length, c = oe(r, u, a, n, !1), c === c.next && (c.steiner = !0), s.push(Fe(c)); | ||
for (s.sort(Se), o = 0; o < s.length; o++) | ||
t = Ce(s[o], t); | ||
return t; | ||
} | ||
function Ce(r, e) { | ||
function Se(r, e) { | ||
return r.x - e.x; | ||
} | ||
function Le(r, e) { | ||
var t = Oe(r, e); | ||
function Ce(r, e) { | ||
var t = Le(r, e); | ||
if (!t) | ||
@@ -969,3 +991,3 @@ return e; | ||
} | ||
function Oe(r, e) { | ||
function Le(r, e) { | ||
var t = e, n = r.x, s = r.y, o = -1 / 0, i; | ||
@@ -985,3 +1007,3 @@ do { | ||
do | ||
n >= t.x && t.x >= c && n !== t.x && O(s < l ? n : o, s, c, l, s < l ? o : n, s, t.x, t.y) && (f = Math.abs(s - t.y) / (n - t.x), A(t, r) && (f < h || f === h && (t.x > i.x || t.x === i.x && Be(i, t))) && (i = t, h = f)), t = t.next; | ||
n >= t.x && t.x >= c && n !== t.x && B(s < l ? n : o, s, c, l, s < l ? o : n, s, t.x, t.y) && (f = Math.abs(s - t.y) / (n - t.x), F(t, r) && (f < h || f === h && (t.x > i.x || t.x === i.x && Be(i, t))) && (i = t, h = f)), t = t.next; | ||
while (t !== a); | ||
@@ -991,3 +1013,3 @@ return i; | ||
function Be(r, e) { | ||
return p(r.prev, r, e.prev) < 0 && p(e.next, r, r.next) < 0; | ||
return M(r.prev, r, e.prev) < 0 && M(e.next, r, r.next) < 0; | ||
} | ||
@@ -1018,3 +1040,3 @@ function Ie(r, e, t, n) { | ||
} | ||
function Ae(r) { | ||
function Fe(r) { | ||
var e = r, t = r; | ||
@@ -1026,12 +1048,12 @@ do | ||
} | ||
function O(r, e, t, n, s, o, i, u) { | ||
function B(r, e, t, n, s, o, i, u) { | ||
return (s - i) * (e - u) >= (r - i) * (o - u) && (r - i) * (n - u) >= (t - i) * (e - u) && (t - i) * (o - u) >= (s - i) * (n - u); | ||
} | ||
function be(r, e) { | ||
return r.next.i !== e.i && r.prev.i !== e.i && !Fe(r, e) && // dones't intersect other edges | ||
(A(r, e) && A(e, r) && Ne(r, e) && // locally visible | ||
(p(r.prev, r, e.prev) || p(r, e.prev, e)) || // does not create opposite-facing sectors | ||
Y(r, e) && p(r.prev, r, r.next) > 0 && p(e.prev, e, e.next) > 0); | ||
function Ae(r, e) { | ||
return r.next.i !== e.i && r.prev.i !== e.i && !be(r, e) && // dones't intersect other edges | ||
(F(r, e) && F(e, r) && Ne(r, e) && // locally visible | ||
(M(r.prev, r, e.prev) || M(r, e.prev, e)) || // does not create opposite-facing sectors | ||
Y(r, e) && M(r.prev, r, r.next) > 0 && M(e.prev, e, e.next) > 0); | ||
} | ||
function p(r, e, t) { | ||
function M(r, e, t) { | ||
return (e.y - r.y) * (t.x - e.x) - (e.x - r.x) * (t.y - e.y); | ||
@@ -1043,6 +1065,6 @@ } | ||
function ie(r, e, t, n) { | ||
var s = N(p(r, e, t)), o = N(p(r, e, n)), i = N(p(t, n, r)), u = N(p(t, n, e)); | ||
return !!(s !== o && i !== u || s === 0 && F(r, t, e) || o === 0 && F(r, n, e) || i === 0 && F(t, r, n) || u === 0 && F(t, e, n)); | ||
var s = N(M(r, e, t)), o = N(M(r, e, n)), i = N(M(t, n, r)), u = N(M(t, n, e)); | ||
return !!(s !== o && i !== u || s === 0 && b(r, t, e) || o === 0 && b(r, n, e) || i === 0 && b(t, r, n) || u === 0 && b(t, e, n)); | ||
} | ||
function F(r, e, t) { | ||
function b(r, e, t) { | ||
return e.x <= Math.max(r.x, t.x) && e.x >= Math.min(r.x, t.x) && e.y <= Math.max(r.y, t.y) && e.y >= Math.min(r.y, t.y); | ||
@@ -1053,3 +1075,3 @@ } | ||
} | ||
function Fe(r, e) { | ||
function be(r, e) { | ||
var t = r; | ||
@@ -1063,4 +1085,4 @@ do { | ||
} | ||
function A(r, e) { | ||
return p(r.prev, r, r.next) < 0 ? p(r, e, r.next) >= 0 && p(r, r.prev, e) >= 0 : p(r, e, r.prev) < 0 || p(r, r.next, e) < 0; | ||
function F(r, e) { | ||
return M(r.prev, r, r.next) < 0 ? M(r, e, r.next) >= 0 && M(r, r.prev, e) >= 0 : M(r, e, r.prev) < 0 || M(r, r.next, e) < 0; | ||
} | ||
@@ -1075,27 +1097,27 @@ function Ne(r, e) { | ||
function ue(r, e) { | ||
var t = new J(r.i, r.x, r.y), n = new J(e.i, e.x, e.y), s = r.next, o = e.prev; | ||
var t = new R(r.i, r.x, r.y), n = new R(e.i, e.x, e.y), s = r.next, o = e.prev; | ||
return r.next = e, e.prev = r, t.next = s, s.prev = t, n.next = t, t.prev = n, o.next = n, n.prev = o, n; | ||
} | ||
function _(r, e, t, n) { | ||
var s = new J(r, e, t); | ||
var s = new R(r, e, t); | ||
return n ? (s.next = n.next, s.prev = n, n.next.prev = s, n.next = s) : (s.prev = s, s.next = s), s; | ||
} | ||
function b(r) { | ||
function A(r) { | ||
r.next.prev = r.prev, r.prev.next = r.next, r.prevZ && (r.prevZ.nextZ = r.nextZ), r.nextZ && (r.nextZ.prevZ = r.prevZ); | ||
} | ||
function J(r, e, t) { | ||
function R(r, e, t) { | ||
this.i = r, this.x = e, this.y = t, this.prev = null, this.next = null, this.z = 0, this.prevZ = null, this.nextZ = null, this.steiner = !1; | ||
} | ||
K.deviation = function(r, e, t, n) { | ||
var s = e && e.length, o = s ? e[0] * t : r.length, i = Math.abs(W(r, 0, o, t)); | ||
var s = e && e.length, o = s ? e[0] * t : r.length, i = Math.abs(J(r, 0, o, t)); | ||
if (s) | ||
for (var u = 0, a = e.length; u < a; u++) { | ||
var c = e[u] * t, l = u < a - 1 ? e[u + 1] * t : r.length; | ||
i -= Math.abs(W(r, c, l, t)); | ||
i -= Math.abs(J(r, c, l, t)); | ||
} | ||
var h = 0; | ||
for (u = 0; u < n.length; u += 3) { | ||
var f = n[u] * t, M = n[u + 1] * t, g = n[u + 2] * t; | ||
var f = n[u] * t, y = n[u + 1] * t, d = n[u + 2] * t; | ||
h += Math.abs( | ||
(r[f] - r[g]) * (r[M + 1] - r[f + 1]) - (r[f] - r[M]) * (r[g + 1] - r[f + 1]) | ||
(r[f] - r[d]) * (r[y + 1] - r[f + 1]) - (r[f] - r[y]) * (r[d + 1] - r[f + 1]) | ||
); | ||
@@ -1105,3 +1127,3 @@ } | ||
}; | ||
function W(r, e, t, n) { | ||
function J(r, e, t, n) { | ||
for (var s = 0, o = e, i = t - n; o < t; o += n) | ||
@@ -1150,3 +1172,3 @@ s += (r[i] - r[o]) * (r[o + 1] + r[i + 1]), i = o; | ||
})(); | ||
function Ge(r, e) { | ||
function ze(r, e) { | ||
const t = [0, 0, 0], n = r.length; | ||
@@ -1158,3 +1180,3 @@ let s, o, i, u, a, c, l, h; | ||
} | ||
function ze(r, e) { | ||
function Ge(r, e) { | ||
const t = r.length; | ||
@@ -1187,6 +1209,6 @@ let n = 0, s = 0, o = 0; | ||
return r; | ||
const n = Ge(r, t); | ||
const n = ze(r, t); | ||
if (Ue(n)) | ||
return []; | ||
const s = ze(r, t), o = Ye(n), i = []; | ||
const s = Ge(r, t), o = Ye(n), i = []; | ||
for (let u = 0; u < r.length; u += t) { | ||
@@ -1198,7 +1220,7 @@ const [a, c] = Xe(r[u], r[u + 1], r[u + 2], s, o); | ||
} | ||
function We(r, e, t = !1) { | ||
function Je(r, e, t = !1) { | ||
const n = [], s = [], o = e === v.XYZM ? 4 : e === v.XY ? 2 : 3; | ||
r.forEach((l, h) => { | ||
h > 0 && s.push(n.length / o), l.forEach((f, M) => { | ||
M !== l.length - 1 && n.push(...f.slice()); | ||
h > 0 && s.push(n.length / o), l.forEach((f, y) => { | ||
y !== l.length - 1 && n.push(...f.slice()); | ||
}); | ||
@@ -1221,3 +1243,3 @@ }); | ||
export { | ||
z as BaseRecord, | ||
G as BaseRecord, | ||
v as CoordType, | ||
@@ -1230,8 +1252,8 @@ H as DbfReader, | ||
P as MultiPatchRecord, | ||
Z as MultiPointRecord, | ||
D as MultiPointRecord, | ||
j as PointRecord, | ||
S as PolyLineRecord, | ||
D as PolygonRecord, | ||
G as ShapeReader, | ||
We as triangulate | ||
O as PolygonRecord, | ||
z as ShapeReader, | ||
Je as triangulate | ||
}; |
@@ -18,2 +18,3 @@ import { ShapeType } from '../utils/geometry'; | ||
export interface GeomHeader { | ||
offset: number; | ||
recordNum: number; | ||
@@ -20,0 +21,0 @@ length: number; |
@@ -21,4 +21,4 @@ import { CoordType } from '../types/coordinate'; | ||
static hasZ(shapeType: ShapeType): boolean; | ||
static hasM(shapeType: ShapeType): boolean; | ||
static hasOptionalM(shapeType: ShapeType): boolean; | ||
static shapeTypeStr(shapeType: ShapeType): string; | ||
} |
{ | ||
"name": "shpts", | ||
"private": false, | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
84902
1671