From 26aa537895109dcf76c858e65a3c5915c429d188 Mon Sep 17 00:00:00 2001 From: Christopher Lee Date: Tue, 14 Sep 2021 12:24:41 -0500 Subject: [PATCH] Allow user to retrieve raw PointData buffer --- src/copc/copc.test.ts | 2 +- src/copc/copc.ts | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/copc/copc.test.ts b/src/copc/copc.test.ts index d1b91a2..cca9b6f 100644 --- a/src/copc/copc.test.ts +++ b/src/copc/copc.test.ts @@ -7,7 +7,7 @@ const filename = ellipsoidFilename test('data', async () => { const copc = await Copc.create(filename) - const view = await Copc.loadPointData(filename, copc, '0-0-0-0') + const view = await Copc.loadPointDataView(filename, copc, '0-0-0-0') expect(view.dimensions).toEqual({ X: { type: 'float', size: 8 }, diff --git a/src/copc/copc.ts b/src/copc/copc.ts index 512c944..19ab057 100644 --- a/src/copc/copc.ts +++ b/src/copc/copc.ts @@ -1,5 +1,5 @@ import * as Las from 'las' -import { Getter, View } from 'utils' +import { Getter, View, Binary } from 'utils' import { Hierarchy } from './hierarchy' import { Key } from './key' @@ -11,7 +11,7 @@ export type Copc = { offsets: Offsets hierarchy: Hierarchy } -export const Copc = { create, loadPointData, loadHierarchyPage } +export const Copc = { create, loadPointData, loadPointDataView, loadHierarchyPage } /** * Parse the COPC header and walk VLR and EVLR metadata. @@ -57,7 +57,7 @@ async function loadPointData( filename: string | Getter, copc: Copc, key: Key | string -): Promise { +): Promise { const get = Getter.create(filename) // Ensure that the hierarchy entry for this node is loaded. @@ -87,5 +87,13 @@ async function loadPointData( pointCount, }) - return Las.View.create(copc.header, buffer) + return buffer } + +async function loadPointDataView( + filename: string | Getter, + copc: Copc, + key: Key | string +): Promise { + return Las.View.create(copc.header, (await loadPointData(filename, copc, key))); +} \ No newline at end of file