Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tile creation and update #71

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Core/Commander/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define('Core/Commander/Command', [], function() {
this.inParallel = null;
this.inBuffers = null;
this.outBuffers = null;
this.paramsFunction = {};
this.parameters = {};
this.processFunction = null;
this.async = null;
this.force = null;
Expand Down
24 changes: 20 additions & 4 deletions src/Core/Commander/InterfaceCommander.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define('Core/Commander/InterfaceCommander', ['Core/Commander/ManagerCommands', '

this.managerCommands = ManagerCommands();
this.type = type;
this.pendingRequests = {};

}

Expand All @@ -24,13 +25,28 @@ define('Core/Commander/InterfaceCommander', ['Core/Commander/ManagerCommands', '
this._builderCommand();
};

InterfaceCommander.prototype.request = function(parameters, requester) {
InterfaceCommander.prototype.request = function(type, requester, layer, parameters) {

if(type === undefined) return;

var key = requester.id + "." + type;
if(this.pendingRequests[key] !== undefined) return;

var command = new Command();
command.type = this.type;
command.type = type;
command.requester = requester;
command.paramsFunction = parameters;
command.layer = parameters.layer;
command.parameters = parameters;
command.layer = layer;

var that = this;
command.callback = function() {
if(parameters.callback) {
parameters.callback();
}
that.pendingRequests[key] = undefined;
};

this.pendingRequests[key] = command;

//command.priority = parent.sse === undefined ? 1 : Math.floor(parent.visible ? parent.sse * 10000 : 1.0) * (parent.visible ? Math.abs(19 - parent.level) : Math.abs(parent.level) ) *10000;

Expand Down
2 changes: 0 additions & 2 deletions src/Core/Commander/Interfaces/ApiInterface/ApiGlobe.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ define('Core/Commander/Interfaces/ApiInterface/ApiGlobe', [
var providerWMTS = manager.getProvider(map.tiles).providerWMTS;

providerWMTS.addLayer(layer);
manager.addLayer(map.colorTerrain,providerWMTS);
map.colorTerrain.services.push(layer.id);

};
Expand All @@ -77,7 +76,6 @@ define('Core/Commander/Interfaces/ApiInterface/ApiGlobe', [
var providerWMTS = manager.getProvider(map.tiles).providerWMTS;

providerWMTS.addLayer(layer);
manager.addLayer(map.elevationTerrain,providerWMTS);
map.elevationTerrain.services.push(layer.id);

};
Expand Down
34 changes: 16 additions & 18 deletions src/Core/Commander/ManagerCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ define('Core/Commander/ManagerCommands', [

while (this.queueAsync.length > 0 && arrayTasks.length < nT) {
var command = this.deQueue();
if(command)
arrayTasks.push(this.providerMap[command.layer.id].executeCommand(command));
if(command) {
var task = this.providerMap[command.layer.id].executeCommand(command);
task = task.then(command.callback);
arrayTasks.push(task);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one liner ?

arrayTasks.push(this.providerMap[command.layer.id].executeCommand(command).then(command.callback));

}
}

return arrayTasks;
Expand All @@ -122,22 +125,17 @@ define('Core/Commander/ManagerCommands', [
ManagerCommands.prototype.deQueue = function() {

while (this.queueAsync.length > 0) {
var com = this.queueAsync.peek();
var parent = com.requester;

if (parent.visible === false && parent.level >= 2) {

while (parent.children.length > 0) {
var child = parent.children[0];
child.dispose();
parent.remove(child);
}
parent.wait = false;
parent.false = false;
this.queueAsync.dequeue();
} else
return this.queueAsync.dequeue();

var com = this.queueAsync.dequeue();
var node = com.requester;

if(!node || node.disposed) {
return;
} else if(node.parent.visible === false) {
com.callback();
return;
} else {
return com;
}
}

return undefined;
Expand Down
81 changes: 41 additions & 40 deletions src/Core/Commander/Providers/TileProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ define('Core/Commander/Providers/TileProvider', [
'when',
'Core/Geographic/Projection',
'Core/Commander/Providers/WMTS_Provider',
'Core/Commander/Providers/WMS_Provider',
'Core/Commander/Providers/KML_Provider',
'Globe/TileGeometry',
'Core/Geographic/CoordWMTS',
Expand All @@ -31,6 +32,7 @@ define('Core/Commander/Providers/TileProvider', [
when,
Projection,
WMTS_Provider,
WMS_Provider,
KML_Provider,
TileGeometry,
CoordWMTS,
Expand Down Expand Up @@ -105,59 +107,58 @@ define('Core/Commander/Providers/TileProvider', [

TileProvider.prototype.executeCommand = function(command) {

var bbox = command.paramsFunction.bbox;
var tile = command.requester;//new command.type(params,this.builder);
if(command.type === "geometry") {
var bbox = tile.bbox;

// TODO not generic
var tileCoord = this.projection.WGS84toWMTS(bbox);
var parent = command.requester;
// TODO not generic
var tileCoord = this.projection.WGS84toWMTS(bbox);
var parent = tile.parent;

// build tile
var geometry = undefined; //getGeometry(bbox,tileCoord);
// build tile
var geometry; // = getGeometry(bbox,tileCoord);

var params = {bbox:bbox,zoom:tileCoord.zoom,segment:16,center:null,projected:null}
var params = {bbox:bbox,zoom:tileCoord.zoom,segment:16,center:null,projected:null};

var tile = new command.type(params,this.builder);

tile.tileCoord = tileCoord;
tile.material.setUuid(this.nNode++);
tile.link = parent.link;
tile.geometricError = Math.pow(2, (18 - tileCoord.zoom));
tile.setGeometry(new TileGeometry(params, this.builder)); //TODO: use cache?
// set material too ?

if (geometry) {
tile.rotation.set(0, (tileCoord.col % 2) * (Math.PI * 2.0 / Math.pow(2, tileCoord.zoom + 1)), 0);
}

parent.worldToLocal(params.center);

tile.position.copy(params.center);
tile.setVisibility(false);

parent.add(tile);
tile.updateMatrix();
tile.updateMatrixWorld();
tile.tileCoord = tileCoord;
tile.material.setUuid(this.nNode++);
tile.link = parent.link;
tile.geometricError = Math.pow(2, (18 - tileCoord.zoom));

// PROBLEM is not generic : elevationTerrain ,colorTerrain
var elevationlayerId = command.paramsFunction.layer.parent.elevationTerrain.services[tileCoord.zoom > 11 ? 1 : 0];
var colorlayerId = command.paramsFunction.layer.parent.colorTerrain.services[0];
if (geometry) {
tile.rotation.set(0, (tileCoord.col % 2) * (Math.PI * 2.0 / Math.pow(2, tileCoord.zoom + 1)), 0);
}

if(tileCoord.zoom > 3 )
tileCoord = undefined;
parent.worldToLocal(params.center);

tile.texturesNeeded =+ 1;
tile.position.copy(params.center);
tile.setVisibility(false);

return when.all([
tile.updateMatrix();
tile.updateMatrixWorld();

this.providerElevationTexture.getElevationTexture(tileCoord,elevationlayerId).then(function(terrain){
tile.texturesNeeded =+ 1;

this.setTextureElevation(terrain);}.bind(tile)),
return when();
} else if(command.type === "elevation") {
// TODO: remove hard-written values
var elevationlayerId = tile.tileCoord.zoom > 11 ? 'IGN_MNT_HIGHRES' : 'IGN_MNT';
return this.providerElevationTexture.getElevationTexture(tile.tileCoord, elevationlayerId).then(function(terrain) {
if(this.disposed) return;
this.setTextureElevation(terrain);
}.bind(tile));

this.providerColorTexture.getColorTextures(tile,colorlayerId).then(function(colorTextures){

this.setTexturesLayer(colorTextures,1);}.bind(tile))

//,this.getKML(tile)

]);
} else if(command.type === "imagery") {
return this.providerWMTS.getColorTextures(tile,"IGNPO").then(function(result)
{
if(this.disposed) return;
this.setTexturesLayer(result,1);
}.bind(tile));
}
};

return TileProvider;
Expand Down
6 changes: 5 additions & 1 deletion src/Core/Commander/Providers/WMS_Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ define('Core/Commander/Providers/WMS_Provider', [

this.baseUrl = options.url || "";
this.layer = options.layer || "";
this.style = options.style || "";
this.format = defaultValue(options.format, "image/jpeg");
this.srs = options.srs || "";
this.width = defaultValue(options.width, 256);
Expand All @@ -63,7 +64,8 @@ define('Core/Commander/Providers/WMS_Provider', [
"&SERVICE=WMS&VERSION=1.1.1" + "&REQUEST=GetMap&BBOX=" +
bbox.minCarto.longitude + "," + bbox.minCarto.latitude + "," +
bbox.maxCarto.longitude + "," + bbox.maxCarto.latitude +
"&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&SRS=" + this.srs;
"&WIDTH=" + this.width + "&HEIGHT=" + this.height + "&SRS=" + this.srs +
"&STYLES=";
return url;
};

Expand Down Expand Up @@ -121,6 +123,8 @@ define('Core/Commander/Providers/WMS_Provider', [
result.texture.magFilter = THREE.LinearFilter;
result.texture.minFilter = THREE.LinearFilter;
result.texture.anisotropy = 16;
result.texture.needsUpdate = true;
result.texture.url = url;

this.cache.addRessource(url, result.texture);
return result.texture;
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Commander/Providers/WMTS_Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ define('Core/Commander/Providers/WMTS_Provider', [
else
tile.material.nbTextures -= colorTexturesNeeded;

// TODO: temporarily disabled texture upscaling
lookAtAncestor = false;

for (var row = box[0].row; row < box[1].row + 1; row++) {

var cooWMTS = new CoordWMTS(box[0].zoom, row, col);
Expand Down
Loading