merged from 'master'

This commit is contained in:
Thomas Hervey
2018-07-21 12:12:36 -04:00
7 changed files with 103 additions and 92 deletions

View File

@@ -1,4 +1,5 @@
/* global Mapillary:false */
import _find from 'lodash-es/find';
import _flatten from 'lodash-es/flatten';
import _forEach from 'lodash-es/forEach';
import _isEmpty from 'lodash-es/isEmpty';
@@ -19,9 +20,9 @@ import rbush from 'rbush';
import { geoExtent } from '../geo';
import { svgDefs } from '../svg';
import { utilDetect } from '../util/detect';
import { utilQsString, utilRebind, utilTile } from '../util';
import { utilQsString, utilRebind, utilTiler } from '../util';
var geoTile = utilTile();
var geoTile = utilTiler().skipNullIsland(true);
var apibase = 'https://a.mapillary.com/v3/';
var viewercss = 'mapillary-js/mapillary.min.css';
@@ -57,10 +58,18 @@ function loadTiles(which, url, projection) {
var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var dimension = projection.clipExtent()[1];
var tiles = geoTile.getTiles(projection, dimension, tileZoom, 0);
tiles = geoTile.filterNullIsland(tiles);
var tiles = geoTile.getTiles(projection, dimension, tileZoom);
geoTile.removeInflightRequests(which, tiles, abortRequest, ',0');
// abort inflight requests that are no longer needed
var cache = _mlyCache[which];
_forEach(cache.inflight, function(v, k) {
var wanted = _find(tiles, function(tile) { return k.indexOf(tile.id + ',') === 0; });
if (!wanted) {
abortRequest(v);
delete cache.inflight[k];
}
});
tiles.forEach(function(tile) {
loadNextTilePage(which, currZoom, url, tile);

View File

@@ -1,3 +1,4 @@
import _find from 'lodash-es/find';
import _flatten from 'lodash-es/flatten';
import _forEach from 'lodash-es/forEach';
import _map from 'lodash-es/map';
@@ -22,7 +23,7 @@ import rbush from 'rbush';
import { geoExtent } from '../geo';
import { utilTile } from '../util';
import { utilTiler } from '../util';
import { utilDetect } from '../util/detect';
import {
@@ -31,7 +32,7 @@ import {
utilSetTransform
} from '../util';
var geoTile = utilTile();
var geoTile = utilTiler().skipNullIsland(true);
var apibase = 'https://openstreetcam.org';
var maxResults = 1000;
@@ -62,14 +63,22 @@ function maxPageAtZoom(z) {
function loadTiles(which, url, projection) {
var s = projection.scale() * 2 * Math.PI,
currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var s = projection.scale() * 2 * Math.PI;
var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var dimension = projection.clipExtent()[1];
var tiles = geoTile.getTiles(projection, dimension, tileZoom, 0);
tiles = geoTile.filterNullIsland(tiles);
var tiles = geoTile.getTiles(projection, dimension, tileZoom);
geoTile.removeInflightRequests(which, tiles, abortRequest, ',0');
// abort inflight requests that are no longer needed
var cache = _oscCache[which];
_forEach(cache.inflight, function(v, k) {
var wanted = _find(tiles, function(tile) { return k.indexOf(tile.id + ',') === 0; });
if (!wanted) {
abortRequest(v);
delete cache.inflight[k];
}
});
tiles.forEach(function(tile) {
loadNextTilePage(which, currZoom, url, tile);

View File

@@ -2,6 +2,7 @@ import _chunk from 'lodash-es/chunk';
import _cloneDeep from 'lodash-es/cloneDeep';
import _extend from 'lodash-es/extend';
import _forEach from 'lodash-es/forEach';
import _find from 'lodash-es/find';
import _groupBy from 'lodash-es/groupBy';
import _isEmpty from 'lodash-es/isEmpty';
import _map from 'lodash-es/map';
@@ -28,11 +29,11 @@ import {
import {
utilRebind,
utilIdleWorker,
utilTile,
utilTiler,
utilQsString
} from '../util';
var geoTile = utilTile();
var geoTile = utilTiler();
var dispatch = d3_dispatch('authLoading', 'authDone', 'change', 'loading', 'loaded', 'loadedNotes');
var urlroot = 'https://www.openstreetmap.org';
@@ -802,13 +803,19 @@ export default {
tilezoom = _tileZoom;
}
// get tiles
var tiles = geoTile.getTiles(projection, dimensions, tilezoom, 0);
tiles = geoTile.filterNullIsland(tiles);
// determine the needed tiles to cover the view
var tiles = geoTile.getTiles(projection, dimensions, tilezoom);
// remove inflight requests that no longer cover the view..
// abort inflight requests that are no longer needed
var hadRequests = !_isEmpty(cache.inflight);
geoTile.removeInflightRequests(cache, tiles, abortRequest);
_forEach(cache.inflight, function(v, k) {
var wanted = _find(tiles, function(tile) { return k === tile.id; });
if (!wanted) {
abortRequest(v);
delete cache.inflight[k];
}
});
if (hadRequests && !loadingNotes && _isEmpty(cache.inflight)) {
dispatch.call('loaded'); // stop the spinner
}

View File

@@ -1,4 +1,5 @@
import _extend from 'lodash-es/extend';
import _find from 'lodash-es/find';
import _flatten from 'lodash-es/flatten';
import _forEach from 'lodash-es/forEach';
import _map from 'lodash-es/map';
@@ -28,11 +29,11 @@ import {
} from '../geo';
import { utilDetect } from '../util/detect';
import { utilQsString, utilRebind, utilTile } from '../util';
import { utilQsString, utilRebind, utilTiler } from '../util';
import Q from 'q';
var geoTile = utilTile();
var geoTile = utilTiler().skipNullIsland(true);
var bubbleApi = 'https://dev.virtualearth.net/mapcontrol/HumanScaleServices/GetBubbles.ashx?';
var streetsideImagesApi = 'https://t.ssl.ak.tiles.virtualearth.net/tiles/';
@@ -53,6 +54,7 @@ var _pannellumViewer;
var _sceneOptions;
var _dataUrlArray = [];
/**
* abortRequest().
*/
@@ -60,19 +62,6 @@ function abortRequest(i) {
i.abort();
}
/**
* nearNullIsland().
*/
function nearNullIsland(x, y, z) {
if (z >= 7) {
var center = Math.pow(2, z - 1);
var width = Math.pow(2, z - 6);
var min = center - (width / 2);
var max = center + (width / 2) - 1;
return x >= min && x <= max && y >= min && y <= max;
}
return false;
}
/**
* localeTimeStamp().
@@ -95,8 +84,20 @@ function loadTiles(which, url, projection, margin) {
var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0));
var dimension = projection.clipExtent()[1];
var tiles = geoTile.getTiles(projection, dimension, tileZoom, margin);
tiles = geoTile.filterNullIsland(tiles);
var tiles = geoTile
.margin(margin)
.getTiles(projection, dimension, tileZoom);
// abort inflight requests that are no longer needed
var cache = _ssCache[which];
_forEach(cache.inflight, function(v, k) {
var wanted = _find(tiles, function(tile) { return k.indexOf(tile.id + ',') === 0; });
if (!wanted) {
abortRequest(v);
delete cache.inflight[k];
}
});
tiles.forEach(function (tile) {
loadNextTilePage(which, currZoom, url, tile);