progress on high zoom levels

This commit is contained in:
Chris Whong 2015-09-03 01:09:32 -04:00
parent d56b403cfe
commit a6022516aa
6 changed files with 222 additions and 189 deletions

12
dist/torque.full.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3948,6 +3948,17 @@ var Profiler = require('../profiler');
splunk.prototype = {
setManager: function (PostProcessManager, managerId) {
this.searchManagerId = managerId;
this.managerClass = PostProcessManager;
this.managers = [];
},
setMap: function(map,rectsLayer) {
this.map=map;
this.rectsLayer=rectsLayer;
},
/**
* return the torque tile encoded in an efficient javascript
* structure:
@ -4192,9 +4203,12 @@ var Profiler = require('../profiler');
//parseData converts splunk results into a valid torque tile
var tile = parseData(data);
if (tile) {
var rows = tile;
console.log(rows,coord,zoom);
callback(self.proccessTile(rows, coord, zoom));
@ -4212,7 +4226,7 @@ var Profiler = require('../profiler');
//console.log(tileBounds);
//validate bounds
// //validate bounds
if(
tileBounds.minLat > -86 &&
tileBounds.maxLat < 86 &&
@ -4220,40 +4234,20 @@ var Profiler = require('../profiler');
tileBounds.maxLng <= 180
) {
var options = {
host: 'localhost',
port: '8000',
sid: '1439866488.13',
bounds: tileBounds
if (!self.managers[coord.zoom + "_" + coord.x + "_" + coord.y]) {
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y] = new self.managerClass({
id: self.searchManagerId + '::' + coord.zoom + "_" + coord.x + "_" + coord.y,
managerid: self.searchManagerId,
search: "geofilter south=" + tileBounds.minLat + " west=" + tileBounds.minLng + " north=" + tileBounds.maxLat + " east=" + tileBounds.maxLng + " maxclusters=65536"
});
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].data("results", {count: 0, output_mode: 'json_rows'}).on("data", function (results) {
console.log("Got " + (results.data().rows.length) + " bins for this tile");
console.log(results.data());
callback(results.data());
});
}
var template = 'http://{{host}}:{{port}}/en-US/splunkd/__raw/services/search/jobs/{{sid}}/results_preview?output_mode=json_rows&count=65536&show_metadata=false&search=geofilter+south={{bounds.minLat}}+west={{bounds.minLng}}+north={{bounds.maxLat}}+east={{bounds.maxLng}}+maxclusters%3D65536';
var queryString = Mustache.render(template,options);
console.log(queryString);
$.getJSON(queryString,function(data) {
console.log("Got " + (data.rows.length-8) + " bins for this tile");
callback(data);
});
// $.ajax({
// type: "POST",
// crossDomain: true,
// url: "https://localhost:8089/servicesNS/admin/search/search/jobs/export",
// username: 'admin',
// password: 'cartodb',
// dataType: 'text',
// data: queryString,
// success: callback,
// beforeSend: function(xhr) {
// xhr.setRequestHeader(
// 'Authorization',
// 'Basic ' + window.btoa(unescape(encodeURIComponent('admin' + ':' + 'cartodb')))
// )
// }
// });
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].startSearch();
}
}
@ -4307,38 +4301,53 @@ var Profiler = require('../profiler');
// data = JSON.parse(data);
//get indices of boundfields (for some reason they like to move around)
var f=data.fields;
var boundFields = {
south: f.indexOf("_geo_bounds_south"),
north: f.indexOf("_geo_bounds_north"),
east: f.indexOf("_geo_bounds_east"),
west: f.indexOf("_geo_bounds_west"),
}
console.log(boundFields);
var torqueTile = [];
//iterate over bounding boxes
data.rows.forEach(function(bin) {
//console.log(bin);
//console.log("bin", bin);
torqueTile.push(torqueTransform(bin));
function torqueTransform(bin){
//var binSpan = 1010384; //hard coded to figure out step from unixtimestamp, TODO figure out how we will deal with the time range and bin span
// [[y1, x1], [y2, x2]];
var b = boundFields;
var bounds = [[bin[b.south],bin[b.west]],[bin[b.north],bin[b.east]]];
console.log('binbounds',bounds);
var bounds = [[bin[bin.length-4],bin[bin.length-3]],[bin[bin.length-5],bin[bin.length-6]]];
//console.log(bounds);
//create an orange rectangle
// L.rectangle(bounds, {color: "#ff7800", weight: 1})
// .addTo(map);
//draw an orange rectangle using the tile bounds to see what we're getting back
// L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(self.rectsLayer);
var torqueBin = {};
var lat = bin[0],
lng = bin[1];
var lat = parseFloat(bin[0]),
lng = parseFloat(bin[1]);
//convert bin lat/lng to tile x/y
var point = latLngToTileXY(parseInt(lat),parseInt(lng),zoom)
var point = latLngToTileXY(lat,lng,zoom)
//console.log('tileXY', point)
@ -4360,7 +4369,7 @@ var Profiler = require('../profiler');
torqueBin.vals__uint8 = vals;
torqueBin.dates__uint16 = dates;
//console.log(torqueBin);
console.log(torqueBin);
return torqueBin;
}
@ -4581,11 +4590,6 @@ var Profiler = require('../profiler');
for(var k in opt) {
self.options[k] = opt[k];
}
//in Windshaft, this was happening after an ajax call. Calling self._setReady() too early causes the viz to fail, so it is delayed here. We should fix this
setTimeout(function(){
self._setReady(true);
},500)
}
};

4
dist/torque.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3948,6 +3948,17 @@ var Profiler = require('../profiler');
splunk.prototype = {
setManager: function (PostProcessManager, managerId) {
this.searchManagerId = managerId;
this.managerClass = PostProcessManager;
this.managers = [];
},
setMap: function(map,rectsLayer) {
this.map=map;
this.rectsLayer=rectsLayer;
},
/**
* return the torque tile encoded in an efficient javascript
* structure:
@ -4192,9 +4203,12 @@ var Profiler = require('../profiler');
//parseData converts splunk results into a valid torque tile
var tile = parseData(data);
if (tile) {
var rows = tile;
console.log(rows,coord,zoom);
callback(self.proccessTile(rows, coord, zoom));
@ -4212,7 +4226,7 @@ var Profiler = require('../profiler');
//console.log(tileBounds);
//validate bounds
// //validate bounds
if(
tileBounds.minLat > -86 &&
tileBounds.maxLat < 86 &&
@ -4220,40 +4234,20 @@ var Profiler = require('../profiler');
tileBounds.maxLng <= 180
) {
var options = {
host: 'localhost',
port: '8000',
sid: '1439866488.13',
bounds: tileBounds
if (!self.managers[coord.zoom + "_" + coord.x + "_" + coord.y]) {
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y] = new self.managerClass({
id: self.searchManagerId + '::' + coord.zoom + "_" + coord.x + "_" + coord.y,
managerid: self.searchManagerId,
search: "geofilter south=" + tileBounds.minLat + " west=" + tileBounds.minLng + " north=" + tileBounds.maxLat + " east=" + tileBounds.maxLng + " maxclusters=65536"
});
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].data("results", {count: 0, output_mode: 'json_rows'}).on("data", function (results) {
console.log("Got " + (results.data().rows.length) + " bins for this tile");
console.log(results.data());
callback(results.data());
});
}
var template = 'http://{{host}}:{{port}}/en-US/splunkd/__raw/services/search/jobs/{{sid}}/results_preview?output_mode=json_rows&count=65536&show_metadata=false&search=geofilter+south={{bounds.minLat}}+west={{bounds.minLng}}+north={{bounds.maxLat}}+east={{bounds.maxLng}}+maxclusters%3D65536';
var queryString = Mustache.render(template,options);
console.log(queryString);
$.getJSON(queryString,function(data) {
console.log("Got " + (data.rows.length-8) + " bins for this tile");
callback(data);
});
// $.ajax({
// type: "POST",
// crossDomain: true,
// url: "https://localhost:8089/servicesNS/admin/search/search/jobs/export",
// username: 'admin',
// password: 'cartodb',
// dataType: 'text',
// data: queryString,
// success: callback,
// beforeSend: function(xhr) {
// xhr.setRequestHeader(
// 'Authorization',
// 'Basic ' + window.btoa(unescape(encodeURIComponent('admin' + ':' + 'cartodb')))
// )
// }
// });
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].startSearch();
}
}
@ -4307,38 +4301,53 @@ var Profiler = require('../profiler');
// data = JSON.parse(data);
//get indices of boundfields (for some reason they like to move around)
var f=data.fields;
var boundFields = {
south: f.indexOf("_geo_bounds_south"),
north: f.indexOf("_geo_bounds_north"),
east: f.indexOf("_geo_bounds_east"),
west: f.indexOf("_geo_bounds_west"),
}
console.log(boundFields);
var torqueTile = [];
//iterate over bounding boxes
data.rows.forEach(function(bin) {
//console.log(bin);
//console.log("bin", bin);
torqueTile.push(torqueTransform(bin));
function torqueTransform(bin){
//var binSpan = 1010384; //hard coded to figure out step from unixtimestamp, TODO figure out how we will deal with the time range and bin span
// [[y1, x1], [y2, x2]];
var b = boundFields;
var bounds = [[bin[b.south],bin[b.west]],[bin[b.north],bin[b.east]]];
console.log('binbounds',bounds);
var bounds = [[bin[bin.length-4],bin[bin.length-3]],[bin[bin.length-5],bin[bin.length-6]]];
//console.log(bounds);
//create an orange rectangle
// L.rectangle(bounds, {color: "#ff7800", weight: 1})
// .addTo(map);
//draw an orange rectangle using the tile bounds to see what we're getting back
// L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(self.rectsLayer);
var torqueBin = {};
var lat = bin[0],
lng = bin[1];
var lat = parseFloat(bin[0]),
lng = parseFloat(bin[1]);
//convert bin lat/lng to tile x/y
var point = latLngToTileXY(parseInt(lat),parseInt(lng),zoom)
var point = latLngToTileXY(lat,lng,zoom)
//console.log('tileXY', point)
@ -4360,7 +4369,7 @@ var Profiler = require('../profiler');
torqueBin.vals__uint8 = vals;
torqueBin.dates__uint16 = dates;
//console.log(torqueBin);
console.log(torqueBin);
return torqueBin;
}
@ -4581,11 +4590,6 @@ var Profiler = require('../profiler');
for(var k in opt) {
self.options[k] = opt[k];
}
//in Windshaft, this was happening after an ajax call. Calling self._setReady() too early causes the viz to fail, so it is delayed here. We should fix this
setTimeout(function(){
self._setReady(true);
},500)
}
};

View File

@ -120,6 +120,7 @@
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&v=3.12"></script>
<script src="examples/vendor/leaflet.js"></script>
<script src="examples/vendor/leaflet.select-layers.min.js"></script>
<script src="examples/vendor/carto.js"></script>
<script src="examples/vendor/codemirror.js"></script>
<script src="examples/vendor/css.js"></script>

View File

@ -64,6 +64,11 @@
this.managers = [];
},
setMap: function(map,rectsLayer) {
this.map=map;
this.rectsLayer=rectsLayer;
},
/**
* return the torque tile encoded in an efficient javascript
* structure:
@ -308,9 +313,12 @@
//parseData converts splunk results into a valid torque tile
var tile = parseData(data);
if (tile) {
var rows = tile;
console.log(rows,coord,zoom);
callback(self.proccessTile(rows, coord, zoom));
@ -328,7 +336,7 @@
//console.log(tileBounds);
//validate bounds
// //validate bounds
if(
tileBounds.minLat > -86 &&
tileBounds.maxLat < 86 &&
@ -338,12 +346,13 @@
if (!self.managers[coord.zoom + "_" + coord.x + "_" + coord.y]) {
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y] = new self.managerClass({
id: coord.zoom + "_" + coord.x + "_" + coord.y,
id: self.searchManagerId + '::' + coord.zoom + "_" + coord.x + "_" + coord.y,
managerid: self.searchManagerId,
search: "geofilter south=" + tileBounds.minLat + " west=" + tileBounds.minLng + " north=" + tileBounds.maxLat + " east=" + tileBounds.maxLng + " maxclusters=65536"
});
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].data("results", {count: 0, output_mode: 'json_rows'}).on("data", function (results) {
console.log("Got " + (results.data().rows.length - 8) + " bins for this tile");
console.log("Got " + (results.data().rows.length) + " bins for this tile");
console.log(results.data());
callback(results.data());
});
}
@ -402,38 +411,53 @@
// data = JSON.parse(data);
//get indices of boundfields (for some reason they like to move around)
var f=data.fields;
var boundFields = {
south: f.indexOf("_geo_bounds_south"),
north: f.indexOf("_geo_bounds_north"),
east: f.indexOf("_geo_bounds_east"),
west: f.indexOf("_geo_bounds_west"),
}
console.log(boundFields);
var torqueTile = [];
//iterate over bounding boxes
data.rows.forEach(function(bin) {
//console.log(bin);
//console.log("bin", bin);
torqueTile.push(torqueTransform(bin));
function torqueTransform(bin){
//var binSpan = 1010384; //hard coded to figure out step from unixtimestamp, TODO figure out how we will deal with the time range and bin span
// [[y1, x1], [y2, x2]];
var b = boundFields;
var bounds = [[bin[b.south],bin[b.west]],[bin[b.north],bin[b.east]]];
console.log('binbounds',bounds);
var bounds = [[bin[bin.length-4],bin[bin.length-3]],[bin[bin.length-5],bin[bin.length-6]]];
//console.log(bounds);
//create an orange rectangle
// L.rectangle(bounds, {color: "#ff7800", weight: 1})
// .addTo(map);
//draw an orange rectangle using the tile bounds to see what we're getting back
// L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(self.rectsLayer);
var torqueBin = {};
var lat = bin[0],
lng = bin[1];
var lat = parseFloat(bin[0]),
lng = parseFloat(bin[1]);
//convert bin lat/lng to tile x/y
var point = latLngToTileXY(parseInt(lat),parseInt(lng),zoom)
var point = latLngToTileXY(lat,lng,zoom)
//console.log('tileXY', point)
@ -455,7 +479,7 @@
torqueBin.vals__uint8 = vals;
torqueBin.dates__uint16 = dates;
//console.log(torqueBin);
console.log(torqueBin);
return torqueBin;
}