Skip to content

Commit

Permalink
Get features for multiple blocks when axis brush.
Browse files Browse the repository at this point in the history
axis-tracks.js : layoutWidth() :  use trackBlocksR in place of trackBlocks.

paths-progressive.js : requestBlockFeaturesInterval() : call getBlockFeaturesInterval() once for each blockId; see comments for background;  previously the results were limited to a single block.
backend/common/utilities/ :
 69591ee  1288 Sep  8 13:59  block-features.js
 62b68d1 28235 Sep  8 16:39  paths-aggr.js
frontend/app/ :
 202df14 24528 Sep  6 17:52  components/axis-tracks.js
 515fde4 22795 Sep  8 16:08  services/data/paths-progressive.js
  • Loading branch information
Don-Isdale committed Sep 8, 2019
1 parent a12cc20 commit 2bf1414
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/common/utilities/block-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports.blockFeaturesCount = function(db, blockIds) {
pipeline = matchBlock;

if (trace_block)
console.log('blockFeaturesInterval', pipeline);
console.log('blockFeaturesCount', pipeline);
if (trace_block > 1)
console.dir(pipeline, { depth: null });

Expand Down
12 changes: 12 additions & 0 deletions backend/common/utilities/paths-aggr.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ function pipelineLimits(featureCollection, intervals, pipeline) {
*
* @param blockCollection dataSource collection
* @param blockIds ids of data blocks
*
* As commented in requestBlockFeaturesInterval(), using $sample will result in
* only 1 blockId in the result, so this function is called once for each
* blockId.
*
* @param intervals domain and range of axis of block, to limit the number of features in result.
* @return cursor : features
Expand All @@ -612,6 +617,13 @@ exports.blockFeaturesInterval = function(db, blockIds, intervals) {
console.log('blockFeaturesInterval', /*featureCollection,*/ blockIds, intervals);
let ObjectId = ObjectID;

/** When called from axis-brush:features(), the blocks being looked up are
* on the same axis, and hence interval domain is the same; blockFilters will
* repeat the domain constraint for each block, but instead matchBlock could
* be used, in combination with a single domain constraint; but this is a
* moot point because blockIds[] is only called with a single element - see
* comment above.
*/
let
matchBlock =
[
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/components/axis-tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ export default InAxis.extend({
}),
layoutWidth : Ember.computed('trackBlocks.[]', function () {
let
trackBlocks = this.get('trackBlocks'),
blockIds = trackBlocks.map(function (block) { return block.axisName; }),
trackBlocksR = this.get('trackBlocksR'),
blockIds = trackBlocksR.mapBy('id'),
/** Add 50 on the right to avoid clashing with the right axis ticks text,
* which may later be switched off with CSS.
* this includes xOffset from blockTransform(blockIds.length-1)
Expand Down
16 changes: 14 additions & 2 deletions frontend/app/services/data/paths-progressive.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,21 @@ export default Service.extend({
let dataBlockIds = axis.dataBlocks(true)
// equiv : blockS.block.get('id')
.map(function (blockS) { return blockS.axisName; });
/** The result of passing multiple blockIds to getBlockFeaturesInterval()
* has an unevenly distributed result : all the results come from just 1 of
* the blockIds. This is because of the implementation of $sample
* (https://stackoverflow.com/a/46881483).
* So instead getBlockFeaturesInterval() is called once for each blockId;
* requestBlockIds is used in place of dataBlockIds.
*/
let promises =
dataBlockIds.map(function (blockId) {
let requestBlockIds = [blockId];
let promise =
// streaming version not added yet
// pathsViaStream ?
// this.get('auth').getPathsViaStream(blockA, blockB, intervalParams, /*options*/{dataEvent : receivedData}) :
this.get('auth').getBlockFeaturesInterval(dataBlockIds, intervalParams, /*options*/{});
me.get('auth').getBlockFeaturesInterval(requestBlockIds, intervalParams, /*options*/{});
function receivedData(res){
if (trace_pathsP > 1)
console.log(apiName, ' request then', res.length);
Expand All @@ -586,7 +596,7 @@ export default Service.extend({

Ember.run.throttle(
me, me.blocksUpdateDomain,
dataBlockIds, domainCalc, axisEvents,
requestBlockIds, domainCalc, axisEvents,
200, false);
};
promise
Expand All @@ -598,6 +608,8 @@ export default Service.extend({
// else
console.log(apiName, ' request', blockA, me, err.responseJSON[status] /* .error.message*/, status);
});
});
let promise = Ember.RSVP.allSettled(promises);
return promise;

}
Expand Down

0 comments on commit 2bf1414

Please sign in to comment.