Use geoScaleToZoom to calculate zoom in Mapillary, OpenStreetCam

This commit is contained in:
Bryan Housel
2018-07-21 21:59:35 -04:00
parent c0b77d8226
commit 7be9439c35
3 changed files with 9 additions and 14 deletions
+2 -3
View File
@@ -17,7 +17,7 @@ import {
import rbush from 'rbush';
import { geoExtent } from '../geo';
import { geoExtent, geoScaleToZoom } from '../geo';
import { svgDefs } from '../svg';
import { utilQsString, utilRebind, utilTiler } from '../util';
@@ -53,8 +53,7 @@ function maxPageAtZoom(z) {
function loadTiles(which, url, projection) {
var s = projection.scale() * 2 * Math.PI;
var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var currZoom = Math.floor(geoScaleToZoom(projection.scale()));
var tiles = tiler.getTiles(projection, tileZoom);
// abort inflight requests that are no longer needed
+4 -6
View File
@@ -21,15 +21,14 @@ import {
import rbush from 'rbush';
import { geoExtent } from '../geo';
import { utilTiler } from '../util';
import { geoExtent, geoScaleToZoom } from '../geo';
import { utilDetect } from '../util/detect';
import {
utilQsString,
utilRebind,
utilSetTransform
utilSetTransform,
utilTiler
} from '../util';
@@ -63,8 +62,7 @@ function maxPageAtZoom(z) {
function loadTiles(which, url, projection) {
var s = projection.scale() * 2 * Math.PI;
var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var currZoom = Math.floor(geoScaleToZoom(projection.scale()));
var tiles = tiler.getTiles(projection, tileZoom);
// abort inflight requests that are no longer needed
+3 -5
View File
@@ -81,8 +81,6 @@ function localeTimestamp(s) {
* loadTiles() wraps the process of generating tiles and then fetching image points for each tile.
*/
function loadTiles(which, url, projection, margin) {
var s = projection.scale() * 2 * Math.PI;
var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var tiles = tiler.margin(margin).getTiles(projection, tileZoom);
// abort inflight requests that are no longer needed
@@ -97,14 +95,14 @@ function loadTiles(which, url, projection, margin) {
});
tiles.forEach(function (tile) {
loadNextTilePage(which, currZoom, url, tile);
loadNextTilePage(which, url, tile);
});
}
/**
* loadNextTilePage() load data for the next tile page in line.
*/
function loadNextTilePage(which, currZoom, url, tile) {
function loadNextTilePage(which, url, tile) {
var cache = _ssCache[which];
var nextPage = cache.nextPage[tile.id] || 0;
var id = tile.id + ',' + String(nextPage);
@@ -118,7 +116,7 @@ function loadNextTilePage(which, currZoom, url, tile) {
// [].shift() removes the first element, some statistics info, not a bubble point
bubbles.shift();
var features = bubbles.map(function (bubble) {
var features = bubbles.map(function(bubble) {
if (cache.points[bubble.id]) return null; // skip duplicates
var loc = [bubble.lo, bubble.la];