Skip to content

Commit

Permalink
v0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
connormanning committed Mar 26, 2024
1 parent 805e261 commit 9a1d36a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "copc",
"license": "MIT",
"version": "0.0.5",
"version": "0.0.6",
"main": "lib/index.js",
"scripts": {
"build": "tsc --project tsconfig.production.json && tsc-alias",
Expand Down Expand Up @@ -31,6 +31,6 @@
}
},
"browser": {
"fs": false
"fs": false
}
}
4 changes: 2 additions & 2 deletions src/copc/hierarchy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test('parse invalid', () => {

const b = pack({ key, pointCount: 1, pointDataOffset, pointDataLength })
expect(() => Hierarchy.parse(Buffer.concat([b, Buffer.alloc(1)]))).toThrow(
/length/i
/length/i,
)
expect(() => Hierarchy.parse(b.slice(0, -1))).toThrow(/length/i)
expect(() => Hierarchy.parse(b.subarray(0, -1))).toThrow(/length/i)
})
36 changes: 15 additions & 21 deletions src/las/point-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ const chunkTableAdjustment = 8
test('decompress chunk', async () => {
const buffer = await fs.readFile(join(Test.dirname, 'data/ellipsoid-1.4.laz'))
const header = Las.Header.parse(buffer)
const compressed = buffer.slice(header.pointDataOffset + chunkTableAdjustment)
const compressed = buffer.subarray(
header.pointDataOffset + chunkTableAdjustment,
)
const pointdata = await decompressChunk(compressed, header)

const getter: Getter = async (begin, end) => buffer.slice(begin, end)
const getter: Getter = async (begin, end) => buffer.subarray(begin, end)
const vlrs = await Las.Vlr.walk(getter, header)
const ebVlr = Las.Vlr.find(vlrs, 'LASF_Spec', 4)
const eb = ebVlr && Las.ExtraBytes.parse(await Las.Vlr.fetch(getter, ebVlr))

const view = Las.View.create(pointdata, header, eb)
const getters = [
'X',
'Y',
'Z',
'Intensity',
'InvertedIntensity',
].map(view.getter)
const getters = ['X', 'Y', 'Z', 'Intensity', 'InvertedIntensity'].map(
view.getter,
)

{
const [x, y, z, i, ii] = getters.map(f => f(0))
const [x, y, z, i, ii] = getters.map((f) => f(0))
expect(x >= header.min[0])
expect(y >= header.min[1])
expect(z >= header.min[2])
Expand All @@ -40,7 +38,7 @@ test('decompress chunk', async () => {
expect(i).not.toEqual(ii)
}
{
const [x, y, z, i, ii] = getters.map(f => f(1))
const [x, y, z, i, ii] = getters.map((f) => f(1))
expect(x >= header.min[0])
expect(y >= header.min[1])
expect(z >= header.min[2])
Expand All @@ -56,22 +54,18 @@ test('decompress file', async () => {
const header = Las.Header.parse(buffer)
const pointdata = await decompressFile(buffer)

const getter: Getter = async (begin, end) => buffer.slice(begin, end)
const getter: Getter = async (begin, end) => buffer.subarray(begin, end)
const vlrs = await Las.Vlr.walk(getter, header)
const ebVlr = Las.Vlr.find(vlrs, 'LASF_Spec', 4)
const eb = ebVlr && Las.ExtraBytes.parse(await Las.Vlr.fetch(getter, ebVlr))

const view = Las.View.create(pointdata, header, eb)
const getters = [
'X',
'Y',
'Z',
'Intensity',
'InvertedIntensity',
].map(view.getter)
const getters = ['X', 'Y', 'Z', 'Intensity', 'InvertedIntensity'].map(
view.getter,
)

{
const [x, y, z, i, ii] = getters.map(f => f(0))
const [x, y, z, i, ii] = getters.map((f) => f(0))
expect(x >= header.min[0])
expect(y >= header.min[1])
expect(z >= header.min[2])
Expand All @@ -81,7 +75,7 @@ test('decompress file', async () => {
expect(i).not.toEqual(ii)
}
{
const [x, y, z, i, ii] = getters.map(f => f(1))
const [x, y, z, i, ii] = getters.map((f) => f(1))
expect(x >= header.min[0])
expect(y >= header.min[1])
expect(z >= header.min[2])
Expand Down

0 comments on commit 9a1d36a

Please sign in to comment.