2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../../support/test-helper');
|
2016-06-29 22:08:38 +08:00
|
|
|
|
|
|
|
var assert = require('../../support/assert');
|
|
|
|
var TestClient = require('../../support/test-client');
|
|
|
|
|
2016-07-03 16:47:53 +08:00
|
|
|
describe('analysis-layers regressions', function() {
|
|
|
|
it('should return a complete list of nodes from analysis', function(done) {
|
2016-06-29 22:08:38 +08:00
|
|
|
var mapConfig = {
|
|
|
|
"version": "1.5.0",
|
|
|
|
"layers": [
|
|
|
|
{
|
|
|
|
"type": "cartodb",
|
|
|
|
"options": {
|
|
|
|
"cartocss": TestClient.CARTOCSS.POINTS,
|
|
|
|
"cartocss_version": "2.1.1",
|
|
|
|
"interactivity": [],
|
|
|
|
"source": {
|
|
|
|
"id": "a4"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "cartodb",
|
|
|
|
"options": {
|
|
|
|
"cartocss": TestClient.CARTOCSS.POINTS,
|
|
|
|
"cartocss_version": "2.1.0",
|
|
|
|
"interactivity": [],
|
|
|
|
"source": {
|
|
|
|
"id": "b1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"dataviews": {
|
|
|
|
"74493a30-4679-4b72-a60c-b6f808b57c98": {
|
|
|
|
"type": "histogram",
|
|
|
|
"source": {
|
|
|
|
"id": "b0"
|
|
|
|
},
|
|
|
|
"options": {
|
|
|
|
"column": "customer_value",
|
|
|
|
"bins": 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"analyses": [
|
|
|
|
{
|
|
|
|
"id": "a4",
|
2016-07-07 00:11:01 +08:00
|
|
|
"type": "point-in-polygon",
|
2016-06-29 22:08:38 +08:00
|
|
|
"params": {
|
2016-07-07 00:11:01 +08:00
|
|
|
"polygons_source": {
|
2016-06-29 22:08:38 +08:00
|
|
|
"id": "a3",
|
|
|
|
"type": "buffer",
|
|
|
|
"params": {
|
|
|
|
"source": {
|
|
|
|
"id": "a2",
|
|
|
|
"type": "centroid",
|
|
|
|
"params": {
|
|
|
|
"source": {
|
|
|
|
"id": "b1",
|
|
|
|
"type": "kmeans",
|
|
|
|
"params": {
|
|
|
|
"source": {
|
|
|
|
"id": "b0",
|
|
|
|
"type": "source",
|
|
|
|
"params": {
|
|
|
|
"query": "SELECT * FROM populated_places_simple_reduced"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"clusters": 5
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"category_column": "cluster_no"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"radius": 200000
|
|
|
|
}
|
|
|
|
},
|
2016-07-07 00:11:01 +08:00
|
|
|
"points_source": {
|
2016-06-29 22:08:38 +08:00
|
|
|
"id": "customer_home_locations",
|
|
|
|
"type": "source",
|
|
|
|
"params": {
|
|
|
|
"query": "SELECT * FROM populated_places_simple_reduced"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
var testClient = new TestClient(mapConfig, 1234);
|
|
|
|
|
|
|
|
testClient.getLayergroup(function(err, layergroupResult) {
|
|
|
|
assert.ok(!err, err);
|
|
|
|
|
|
|
|
assert.ok(layergroupResult);
|
|
|
|
assert.ok(layergroupResult.metadata);
|
|
|
|
var analyses = layergroupResult.metadata.analyses;
|
|
|
|
assert.ok(analyses);
|
|
|
|
assert.equal(analyses.length, 1);
|
2016-07-03 16:47:53 +08:00
|
|
|
|
|
|
|
var expectedIds = ['customer_home_locations', 'b0', 'b1', 'a2', 'a3', 'a4'];
|
|
|
|
expectedIds.forEach(function(expectedId) {
|
2016-07-05 17:26:52 +08:00
|
|
|
assert.ok(
|
|
|
|
analyses[0].nodes.hasOwnProperty(expectedId),
|
|
|
|
'Missing "' + expectedId + '" from node list.'
|
|
|
|
);
|
2016-07-03 16:47:53 +08:00
|
|
|
});
|
2016-07-05 17:26:52 +08:00
|
|
|
assert.equal(Object.keys(analyses[0].nodes).length, expectedIds.length, Object.keys(analyses[0].nodes));
|
2016-06-29 22:08:38 +08:00
|
|
|
|
|
|
|
testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|