-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pointcloud): use 'changeSource' mechanism to avoid useless work
Implements a simple logic to avoid updating the full layer if we already know that the result won't change. This feature is already implemented for tile based layers (see 3f340b9).
- Loading branch information
Showing
3 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import PointCloudProcessing from '../src/Process/PointCloudProcessing'; | ||
/* global describe, it */ | ||
|
||
const assert = require('assert'); | ||
|
||
describe('preUpdate', function () { | ||
it('should return root if no change source', () => { | ||
const layer = { root: {} }; | ||
const sources = new Set(); | ||
assert.equal( | ||
layer.root, | ||
PointCloudProcessing.preUpdate(null, layer, sources)[0]); | ||
}); | ||
|
||
it('should return root if no common ancestors', () => { | ||
const layer = { root: {}, id: 'a' }; | ||
const elt1 = { name: '12', obj: { layer: 'a', isPoints: true } }; | ||
const elt2 = { name: '345', obj: { layer: 'a', isPoints: true } }; | ||
const sources = new Set(); | ||
sources.add(elt1); | ||
sources.add(elt2); | ||
assert.equal( | ||
layer.root, | ||
PointCloudProcessing.preUpdate(null, layer, sources)[0]); | ||
}); | ||
|
||
it('should return common ancestor', () => { | ||
const layer = { root: {}, id: 'a' }; | ||
const elt1 = { name: '123', obj: { layer: 'a', isPoints: true } }; | ||
const elt2 = { name: '12567', obj: { layer: 'a', isPoints: true } }; | ||
const elt3 = { name: '122', obj: { layer: 'a', isPoints: true } }; | ||
const sources = new Set(); | ||
sources.add(elt1); | ||
sources.add(elt2); | ||
sources.add(elt3); | ||
layer.root.findChildrenByName = (name) => { | ||
assert.equal('12', name); | ||
}; | ||
PointCloudProcessing.preUpdate(null, layer, sources); | ||
}); | ||
|
||
it('should not search ancestors if layer are different root if no common ancestors', () => { | ||
const layer = { root: {}, id: 'a' }; | ||
const elt1 = { name: '12', obj: { layer: 'a', isPoints: true } }; | ||
const elt2 = { name: '13', obj: { layer: 'b', isPoints: true } }; | ||
const sources = new Set(); | ||
sources.add(elt1); | ||
sources.add(elt2); | ||
layer.root.findChildrenByName = (name) => { | ||
assert.equal('12', name); | ||
}; | ||
PointCloudProcessing.preUpdate(null, layer, sources); | ||
}); | ||
}); |