Skip to content

Commit

Permalink
Refacto replace provider WMTS, wms and rasteriser by extendedDataProv…
Browse files Browse the repository at this point in the history
…ider

add TMS source and remove StaticProvider
remove wfs provider and  tile Provider
  • Loading branch information
gchoqueux committed Aug 2, 2018
1 parent 528aa69 commit 7592921
Show file tree
Hide file tree
Showing 56 changed files with 1,506 additions and 1,326 deletions.
38 changes: 22 additions & 16 deletions examples/cubic_planar.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,34 @@
view.addLayer(tileLayer);

view.addLayer({
url: 'https://download.data.grandlyon.com/wms/grandlyon',
networkOptions: { crossOrigin: 'anonymous' },
type: 'color',
protocol: 'wms',
version: '1.3.0',
id: 'wms_imagery' + wms + index,
name: wms,
projection: 'EPSG:3946',
format: 'image/jpeg',
source: {
url: 'https://download.data.grandlyon.com/wms/grandlyon',
extent,
networkOptions: { crossOrigin: 'anonymous' },
protocol: 'wms',
version: '1.3.0',
name: wms,
projection: 'EPSG:3946',
format: 'image/jpeg',
},
}, tileLayer);

view.addLayer({
url: 'https://download.data.grandlyon.com/wms/grandlyon',
type: 'elevation',
protocol: 'wms',
networkOptions: { crossOrigin: 'anonymous' },
version: '1.3.0',
id: 'wms_elevation' + wms + index,
name: 'MNT2012_Altitude_10m_CC46',
projection: 'EPSG:3946',
heightMapWidth: 256,
format: 'image/jpeg',
type: 'elevation',
source: {
protocol: 'wms',
extent,
networkOptions: { crossOrigin: 'anonymous' },
version: '1.3.0',
name: 'MNT2012_Altitude_10m_CC46',
projection: 'EPSG:3946',
heightMapWidth: 256,
format: 'image/jpeg',
url: 'https://download.data.grandlyon.com/wms/grandlyon',
},
}, tileLayer);

// Since the elevation layer use color textures, specify min/max z
Expand Down
23 changes: 15 additions & 8 deletions examples/globe_vector.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
// # Simple Globe viewer

// Define initial camera position
var positionOnGlobe = { longitude: 3.5, latitude: 44, altitude: 1000000 };
var positionOnGlobe = { longitude: 4.6, latitude: 45.6, altitude: 1000000 };
var promises = [];

// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
var viewerDiv = document.getElementById('viewerDiv');

// Instanciate iTowns GlobeView*
var globeView = new itowns.GlobeView(viewerDiv, positionOnGlobe);
setupLoadingScreen(viewerDiv, globeView);
// setupLoadingScreen(viewerDiv, globeView);
function addLayerCb(layer) {
return globeView.addLayer(layer);
}
Expand All @@ -62,33 +62,36 @@
// This layer is defined in a json file but it could be defined as a plain js
// object. See Layer* for more info.
promises.push(itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb));
promises.push(itowns.Fetcher.json('./layers/JSONLayers/Region.json').then(addLayerCb));
// Add two elevation layers.
// These will deform iTowns globe geometry to represent terrain elevation.
promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));

promises.push(globeView.addLayer({
type: 'color',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',
protocol: 'rasterizer',
id: 'Kml',
name: 'kml',
transparent: true,
source: {
protocol: 'file',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',
},
}));

promises.push(globeView.addLayer({
type: 'color',
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx',
protocol: 'rasterizer',
id: 'Gpx',
name: 'Ultra 2009',
transparent: true,
source: {
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx',
protocol: 'file',
},
}));

promises.push(globeView.addLayer({
type: 'color',
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson',
protocol: 'rasterizer',
id: 'ariege',
name: 'ariege',
transparent: true,
Expand All @@ -97,6 +100,10 @@
fillOpacity: 0.5,
stroke: 'white',
},
source: {
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson',
protocol: 'file',
},
}));

var menuGlobe = new GuiTools('menuDiv', globeView);
Expand Down
25 changes: 14 additions & 11 deletions examples/globe_vector_tiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@
// define pole texture
view.wgs84TileLayer.noTextureColor = new itowns.THREE.Color(0x95c1e1);

view.atmosphere.visible = false;

setupLoadingScreen(viewerDiv, view);
function addLayerCb(layer) {
return view.addLayer(layer);
}

// Add two elevation layers.
// These will deform iTowns globe geometry to represent terrain elevation.
promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb));
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));

// Add a vector tile layer
itowns.Fetcher.json('https://raw.githubusercontent.com/Oslandia/postile-openmaptiles/master/style.json').then(function (style) {
Expand All @@ -58,12 +61,14 @@

promises.push(view.addLayer({
type: 'color',
protocol: 'xyz',
id: 'MVT',
// eslint-disable-next-line no-template-curly-in-string
url: 'https://osm.oslandia.io/data/v3/${z}/${x}/${y}.pbf',
format: 'application/x-protobuf;type=mapbox-vector',
options: {
source: {
protocol: 'xyz',
// eslint-disable-next-line no-template-curly-in-string
url: 'https://osm.oslandia.io/data/v3/${z}/${x}/${y}.pbf',
format: 'application/x-protobuf;type=mapbox-vector',
projection: 'EPSG:4326',
origin: 'top',
attribution: {
name: 'OpenStreetMap',
url: 'http://www.openstreetmap.org/',
Expand All @@ -72,14 +77,11 @@
min: 2,
max: 14,
},
opacity: 0.5,
},
updateStrategy: {
type: itowns.STRATEGY_DICHOTOMY,
},
style: mapboxStyle,
filter: mapboxFilter(supportedLayers),
backgroundLayer,
projection: 'EPSG:4326',
}));
});

Expand All @@ -89,6 +91,7 @@
Promise.all(promises).then(function () {
menuGlobe.addImageryLayersGUI(view.getLayers(function (l) { return l.type === 'color'; }));
menuGlobe.addElevationLayersGUI(view.getLayers(function (l) { return l.type === 'elevation'; }));
// itowns.ColorLayersOrdering.moveLayerToIndex(view, 'Ortho', 0);
}).catch(console.error);
});
</script>
Expand Down
101 changes: 101 additions & 0 deletions examples/globe_wfs_color.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<html>
<head>
<title>Itowns - Globe WFS color</title>

<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/example.css">
<link rel="stylesheet" type="text/css" href="css/loading_screen.css">

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/GUI/dat.gui/dat.gui.min.js"></script>
</head>
<body>
<div id="viewerDiv"></div>
<script src="js/GUI/GuiTools.js"></script>
<script src="../dist/itowns.js"></script>
<script src="js/loading_screen.js"></script>
<script src="../dist/debug.js"></script>
<div class="help" style="left: unset; right: 0;">
<p><b>Information Batiment</b></p>
<ul id="info">
</ul>
</div>
<script type="text/javascript">
// # Simple Globe viewer

// Define initial camera position
var positionOnGlobe = { longitude: 4.818, latitude: 45.7354, altitude: 3000 };
var promises = [];
var meshes = [];
var linesBus = [];
var scaler;

// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
var viewerDiv = document.getElementById('viewerDiv');

// Instanciate iTowns GlobeView*
var globeView = new itowns.GlobeView(viewerDiv, positionOnGlobe);
setupLoadingScreen(viewerDiv, globeView);
function addLayerCb(layer) {
return globeView.addLayer(layer);
}

// Define projection that we will use (taken from https://epsg.io/3946, Proj4js section)
itowns.proj4.defs('EPSG:3946',
'+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');

// Add one imagery layer to the scene
// This layer is defined in a json file but it could be defined as a plain js
// object. See Layer* for more info.
promises.push(itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb));

// Add two elevation layers.
// These will deform iTowns globe geometry to represent terrain elevation.
promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));

promises.push(globeView.addLayer({
type: 'color',
id: 'wfsBuilding',
transparent: true,
style: {
fill: 'red',
fillOpacity: 0.5,
stroke: 'white',
},
projection: 'EPSG:4326',
source: {
url: 'http://wxs.ign.fr/72hpsel8j8nhb5qgdh07gcyp/geoportail/wfs?',
networkOptions: { crossOrigin: 'anonymous' },
protocol: 'wfs',
version: '2.0.0',
typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable,BDTOPO_BDD_WLD_WGS84G:bati_indifferencie,BDTOPO_BDD_WLD_WGS84G:bati_industriel',
zoom: { max: 20, min: 15 },
projection: 'EPSG:4326',
extent: {
west: 4.568,
east: 5.18,
south: 45.437,
north: 46.03,
},
ipr: 'IGN',
format: 'application/json',
},
}));

var menuGlobe = new GuiTools('menuDiv', globeView);
// Listen for globe full initialisation event
globeView.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function () {
// eslint-disable-next-line no-console
console.info('Globe initialized');
Promise.all(promises).then(function () {
menuGlobe.addImageryLayersGUI(globeView.getLayers(function (l) { return l.type === 'color'; }));
menuGlobe.addElevationLayersGUI(globeView.getLayers(function (l) { return l.type === 'elevation'; }));
itowns.ColorLayersOrdering.moveLayerToIndex(globeView, 'Ortho', 0);
}).catch(console.error);
});
var d = new debug.Debug(globeView, menuGlobe.gui);
debug.createTileDebugUI(menuGlobe.gui, globeView, globeView.wgs84TileLayer, d);
</script>
</body>
</html>
Loading

0 comments on commit 7592921

Please sign in to comment.