Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ept-tools",
"version": "0.0.13",
"version": "0.0.14",
"description": "Entwine Point Tiles utility library",
"repository": "github:connormanning/ept-tools",
"main": "lib/index.js",
Expand All @@ -12,7 +12,7 @@
"dev": "ts-node -r tsconfig-paths/register src/app/index.ts",
"lambda": "ncc build src/app/lambda.ts -o ./lambda && copyfiles -f src/lib/* lambda/lib/",
"lambda-zip": "(cd lambda && zip -r ../ept-tools.zip .)",
"prepublish": "$npm_execpath build",
"prepublish": "$npm_execpath run build",
"test": "jest"
},
"dependencies": {
Expand All @@ -23,6 +23,7 @@
"fs-extra": "^9.1.0",
"koa": "^2.13.1",
"koa-logger": "^3.2.1",
"laz-perf": "^0.0.6",
"log-symbols": "^4.0.0",
"node-fetch": "^2.6.1",
"protopath": "^0.0.0",
Expand Down Expand Up @@ -52,7 +53,7 @@
"ts-jest": "^26.5.2",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"ttypescript": "^1.5.12",
"ttypescript": "^1.5.13",
"typescript": "^4.2.2"
},
"husky": {
Expand Down
13 changes: 12 additions & 1 deletion src/3d-tiles/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Translate = {
cache?: Cache
}

const targetEpsgCode = 4978

/**
* Generates a 3D-Tiles file translation of an EPT dataset at the virtual path
* <ept-directory>/ept-tileset/. So the virtual "tileset.json" for an EPT
Expand All @@ -33,6 +35,15 @@ export async function translate({ filename, cache, options = {} }: Translate) {
JsonSchema.validate<Ept>(Ept.schema, await getJson(eptfilename))[0]

const { bounds, dataType, schema, srs } = ept

// If source is already projected to 4978 and does
// not include horizontal epsg code assign the missing
// srs properties to support downstream actions
if (srs?.wkt?.includes(`"EPSG","${targetEpsgCode}"`) && !srs.horizontal) {
srs.authority = 'EPSG'
srs.horizontal = targetEpsgCode.toString()
}

const codeString = Srs.horizontalCodeString(srs)
if (!codeString) {
throw new EptToolsError('Cannot translate to 3D Tiles without an SRS code')
Expand Down Expand Up @@ -67,6 +78,6 @@ export async function translate({ filename, cache, options = {} }: Translate) {

const view = await DataType.view(dataType, buffer, schema)
const tileBounds = Bounds.stepTo(bounds, key)
const toEcef = Reproject.create(codeString, 'EPSG:4978')
const toEcef = Reproject.create(codeString, `EPSG:${targetEpsgCode}`)
return Pnts.translate({ view, tileBounds, toEcef, options })
}
29 changes: 25 additions & 4 deletions src/ept/data-type/laszip/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Module from 'lib/laz-perf'
import { createLazPerf, LazPerf } from 'laz-perf'
// import Module from 'lib/laz-perf'
// // import { createLazPerf, LazPerf } from 'lib/laz-perf'

import { Schema } from 'ept'

Expand All @@ -12,9 +14,27 @@ export const extension = 'laz'

export const Laszip = { view }

// load laz-perf
let isReady = false
let Module: LazPerf
createLazPerf().then((lazPerf: LazPerf) => {
isReady = true;
Module = lazPerf;
})

Module.onRuntimeInitialized = () => isReady = true
function isDetached(ab: any) {
if (ab.byteLength != 0) {
// detached buffers will always have zero byteLength
return false;
}
try {
new Uint8Array(ab);
return false;
} catch {
// Uint8Array throws if using a detached buffer
return true;
}
}

async function view(input: Buffer): Promise<View.Readable> {
const header = Header.parse(input)
Expand All @@ -38,13 +58,14 @@ async function view(input: Buffer): Promise<View.Readable> {
const schema = Format.create(header)
const corePointSize = Schema.pointSize(schema)
const point = Buffer.from(Module.HEAPU8.buffer, dataPointer, corePointSize)

const length = corePointSize * pointCount
const output = Buffer.alloc(length)
for (let pos = 0; pos < length; pos += corePointSize) {
// Decompress each point and copy it from the Module heap to our buffer.
laszip.getPoint(dataPointer)
point.copy(output, pos, 0, corePointSize)
if (!isDetached(point)) {
point.copy(output, pos, 0, corePointSize)
}
}

return View.Readable.create(output, schema)
Expand Down
21 changes: 0 additions & 21 deletions src/lib/laz-perf.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/laz-perf.js

This file was deleted.

Binary file removed src/lib/laz-perf.wasm
Binary file not shown.
69 changes: 44 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2129,10 +2129,10 @@ fsevents@^2.1.2:
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c"
integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==

gaxios@^4.0.0:
version "4.3.0"
Expand Down Expand Up @@ -2329,18 +2329,18 @@ has-values@^1.0.0:
is-number "^3.0.0"
kind-of "^4.0.0"

has@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
dependencies:
function-bind "^1.1.1"

hash-stream-validation@^0.2.2:
version "0.2.4"
resolved "https://registry.yarnpkg.com/hash-stream-validation/-/hash-stream-validation-0.2.4.tgz#ee68b41bf822f7f44db1142ec28ba9ee7ccb7512"
integrity sha512-Gjzu0Xn7IagXVkSu9cSFuK1fqzwtLwFhNhVL8IFJijRNMgUttFbBSIAzKuSIrsFMO1+g1RlsoN49zPIbwPDMGQ==

hasown@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c"
integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==
dependencies:
function-bind "^1.1.2"

hosted-git-info@^2.1.4:
version "2.8.8"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
Expand Down Expand Up @@ -2513,12 +2513,12 @@ is-ci@^2.0.0:
dependencies:
ci-info "^2.0.0"

is-core-module@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a"
integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==
is-core-module@^2.13.0, is-core-module@^2.2.0:
version "2.13.1"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384"
integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==
dependencies:
has "^1.0.3"
hasown "^2.0.0"

is-data-descriptor@^0.1.4:
version "0.1.4"
Expand Down Expand Up @@ -3323,6 +3323,11 @@ koa@^2.13.1:
type-is "^1.6.16"
vary "^1.1.2"

laz-perf@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/laz-perf/-/laz-perf-0.0.6.tgz#a8bfad45f7f02695af631ca374d080528da4ba51"
integrity sha512-ZBqC+BBlofznDIY3SfjXDBVdIhYfz7bq8HAHztlw4XOnu++nHiWtCGPgzpdeAhPkByc68DaKNy3E3rY4XrdRtQ==

leven@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2"
Expand Down Expand Up @@ -3817,10 +3822,10 @@ path-key@^3.0.0, path-key@^3.1.0:
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==

path-parse@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
path-parse@^1.0.6, path-parse@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==

path-to-regexp@^6.1.0:
version "6.2.0"
Expand Down Expand Up @@ -4114,7 +4119,16 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=

resolve@>=1.9.0, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.18.1:
resolve@>=1.9.0:
version "1.22.8"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d"
integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==
dependencies:
is-core-module "^2.13.0"
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

resolve@^1.10.0, resolve@^1.12.0, resolve@^1.18.1:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
Expand Down Expand Up @@ -4546,6 +4560,11 @@ supports-hyperlinks@^2.0.0:
has-flag "^4.0.0"
supports-color "^7.0.0"

supports-preserve-symlinks-flag@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

symbol-tree@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
Expand Down Expand Up @@ -4707,10 +4726,10 @@ tsscmp@1.0.6:
resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.6.tgz#85b99583ac3589ec4bfef825b5000aa911d605eb"
integrity sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==

ttypescript@^1.5.12:
version "1.5.12"
resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.12.tgz#27a8356d7d4e719d0075a8feb4df14b52384f044"
integrity sha512-1ojRyJvpnmgN9kIHmUnQPlEV1gq+VVsxVYjk/NfvMlHSmYxjK5hEvOOU2MQASrbekTUiUM7pR/nXeCc8bzvMOQ==
ttypescript@^1.5.13:
version "1.5.15"
resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.15.tgz#e45550ad69289d06d3bc3fd4a3c87e7c1ef3eba7"
integrity sha512-48ykDNHzFnPMnv4hYX1P8Q84TvCZyL1QlFxeuxsuZ48X2+ameBgPenvmCkHJtoOSxpoWTWi8NcgNrRnVDOmfSg==
dependencies:
resolve ">=1.9.0"

Expand Down