Skip to content

Commit

Permalink
refactor(test): entwine
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Feb 28, 2024
1 parent ba13bf3 commit 8cf1e5d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
12 changes: 7 additions & 5 deletions src/Layer/EntwinePointTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,32 @@ class EntwinePointTileLayer extends PointCloudLayer {

const resolve = this.addInitializationStep();
this.whenReady = this.source.whenReady.then(() => {
const crs = this.crs || 'EPSG:4326';
if (this.crs !== config.crs) { console.warn('layer.crs is different from View.crs'); }
this.root = new EntwinePointTileNode(0, 0, 0, 0, this, -1);

const coord = new Coordinates(this.source.crs, 0, 0, 0);
const coordBoundsMin = new Coordinates(config.crs, 0, 0, 0);
const coordBoundsMax = new Coordinates(config.crs, 0, 0, 0);
const coordBoundsMin = new Coordinates(crs, 0, 0, 0);
const coordBoundsMax = new Coordinates(crs, 0, 0, 0);
coord.setFromValues(
this.source.boundsConforming[0],
this.source.boundsConforming[1],
this.source.boundsConforming[2],
);
coord.as(config.crs, coordBoundsMin);
coord.as(crs, coordBoundsMin);
coord.setFromValues(
this.source.boundsConforming[3],
this.source.boundsConforming[4],
this.source.boundsConforming[5],
);
coord.as(config.crs, coordBoundsMax);
coord.as(crs, coordBoundsMax);

this.root.bbox.setFromPoints([coordBoundsMin.toVector3(), coordBoundsMax.toVector3()]);

this.minElevationRange = this.source.boundsConforming[2];
this.maxElevationRange = this.source.boundsConforming[5];

this.extent = Extent.fromBox3(config.crs || 'EPSG:4326', this.root.bbox);
this.extent = Extent.fromBox3(crs, this.root.bbox);

// NOTE: this spacing is kinda arbitrary here, we take the width and
// length (height can be ignored), and we divide by the specified
Expand Down
8 changes: 6 additions & 2 deletions src/Parser/LASParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default {
* @param { 8 | 16 } [options.in.colorDepth] - Color depth (in bits).
* Defaults to 8 bits for LAS 1.2 and 16 bits for later versions
* (as mandatory by the specification)
* @param {String} [options.in.crs = 'EPSG:3857'] - Crs of the source if any.
* @param {String} [options.out.crs = options.in.crs] - Crs of the view if any.
*
* @return {Promise} A promise resolving with a `THREE.BufferGeometry`. The
* header of the file is contained in `userData`.
Expand All @@ -40,10 +42,12 @@ export default {
if (options.out?.skip) {
console.warn("Warning: options 'skip' not supported anymore");
}
const crsIn = options.in?.crs || 'EPSG:3857';
const crsOut = options.out?.crs || crsIn;
return lasLoader.parseFile(data, {
colorDepth: options.in?.colorDepth,
crsIn: options.in.crs,
crsOut: options.out.crs,
crsIn,
crsOut,
}).then((parsedData) => {
const geometry = new THREE.BufferGeometry();
const attributes = parsedData.attributes;
Expand Down
14 changes: 6 additions & 8 deletions test/unit/entwine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from 'assert';
import { HttpsProxyAgent } from 'https-proxy-agent';
import View from 'Core/View';
import GlobeView from 'Core/Prefab/GlobeView';
import Coordinates from 'Core/Geographic/Coordinates';
import EntwinePointTileSource from 'Source/EntwinePointTileSource';
import EntwinePointTileLayer from 'Layer/EntwinePointTileLayer';
import EntwinePointTileNode from 'Core/EntwinePointTileNode';
Expand All @@ -21,18 +20,16 @@ describe('Entwine Point Tile', function () {
}).catch(done);
});

describe('Layer', function () {
describe('Entwine Point Tile Layer', function () {
let renderer;
let placement;
let view;
let layer;
let context;

before(function (done) {
renderer = new Renderer();
placement = { coord: new Coordinates('EPSG:4326', 0, 0), range: 250 };
view = new GlobeView(renderer.domElement, placement, { renderer });
layer = new EntwinePointTileLayer('test', { source }, view);
view = new GlobeView(renderer.domElement, {}, { renderer });
layer = new EntwinePointTileLayer('test', { source });

context = {
camera: view.camera,
Expand Down Expand Up @@ -60,8 +57,9 @@ describe('Entwine Point Tile', function () {
});

it('tries to update on the root and succeeds', function (done) {
const coord = layer.extent.center();
view.controls.lookAtCoordinate({
coord: source.center,
coord,
range: 250,
}, false)
.then(() => {
Expand All @@ -78,7 +76,7 @@ describe('Entwine Point Tile', function () {
});
});

describe('Node', function () {
describe('Entwine Point Tile Node', function () {
const layer = { source: { url: 'http://server.geo', extension: 'laz' } };
const root = new EntwinePointTileNode(0, 0, 0, 0, layer, 4000);
root.bbox.setFromArray([1000, 1000, 1000, 0, 0, 0]);
Expand Down

0 comments on commit 8cf1e5d

Please sign in to comment.