Skip to content

Commit

Permalink
fix(Protocol): in TMS/VectorTile, wrong projection convert for globe
Browse files Browse the repository at this point in the history
Because, vector tile's projection is 'EPSG:4326' and texture's projection is 'EPSG:3857'
  • Loading branch information
gchoqueux committed Aug 1, 2018
1 parent 6bf0d8e commit f04805d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Parser/VectorTileParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ function readPBF(file, options) {
}
});

let crsOut;
switch (options.coords.crs()) {
case 'WMTS:PM':
crsOut = 'EPSG:3857';
break;
default:
crsOut = options.extent.crs();
}

return GeoJsonParser.parse(geojson, {
crsOut: options.extent.crs(),
crsOut,
filteringExtent: options.filteringExtent,
filter: options.filter,
buildExtent: true,
Expand Down
15 changes: 14 additions & 1 deletion src/Provider/VectorTileHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,22 @@ export default {
const backgroundColor = (layer.backgroundLayer && layer.backgroundLayer.paint) ?
new THREE.Color(layer.backgroundLayer.paint['background-color']) :
undefined;

let extentTexture;
switch (coords.crs()) {
case 'TMS':
extentTexture = tile.extent;
break;
case 'WMTS:PM':
extentTexture = coords.as('EPSG:3857');
break;
default:
extentTexture = coords.as(tile.extent.crs());
}

const texture = Feature2Texture.createTextureFromFeature(
features,
coords.crs() == 'TMS' ? tile.extent : coords.as(tile.extent.crs()),
extentTexture,
256,
layer.style,
backgroundColor);
Expand Down

0 comments on commit f04805d

Please sign in to comment.