Skip to content

Commit 7592921

Browse files
committed
Refacto replace provider WMTS, wms and rasteriser by extendedDataProvider
add TMS source and remove StaticProvider remove wfs provider and tile Provider
1 parent 528aa69 commit 7592921

56 files changed

Lines changed: 1506 additions & 1326 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/cubic_planar.html

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,34 @@
114114
view.addLayer(tileLayer);
115115

116116
view.addLayer({
117-
url: 'https://download.data.grandlyon.com/wms/grandlyon',
118-
networkOptions: { crossOrigin: 'anonymous' },
119117
type: 'color',
120-
protocol: 'wms',
121-
version: '1.3.0',
122118
id: 'wms_imagery' + wms + index,
123-
name: wms,
124-
projection: 'EPSG:3946',
125-
format: 'image/jpeg',
119+
source: {
120+
url: 'https://download.data.grandlyon.com/wms/grandlyon',
121+
extent,
122+
networkOptions: { crossOrigin: 'anonymous' },
123+
protocol: 'wms',
124+
version: '1.3.0',
125+
name: wms,
126+
projection: 'EPSG:3946',
127+
format: 'image/jpeg',
128+
},
126129
}, tileLayer);
127130

128131
view.addLayer({
129-
url: 'https://download.data.grandlyon.com/wms/grandlyon',
130-
type: 'elevation',
131-
protocol: 'wms',
132-
networkOptions: { crossOrigin: 'anonymous' },
133-
version: '1.3.0',
134132
id: 'wms_elevation' + wms + index,
135-
name: 'MNT2012_Altitude_10m_CC46',
136-
projection: 'EPSG:3946',
137-
heightMapWidth: 256,
138-
format: 'image/jpeg',
133+
type: 'elevation',
134+
source: {
135+
protocol: 'wms',
136+
extent,
137+
networkOptions: { crossOrigin: 'anonymous' },
138+
version: '1.3.0',
139+
name: 'MNT2012_Altitude_10m_CC46',
140+
projection: 'EPSG:3946',
141+
heightMapWidth: 256,
142+
format: 'image/jpeg',
143+
url: 'https://download.data.grandlyon.com/wms/grandlyon',
144+
},
139145
}, tileLayer);
140146

141147
// Since the elevation layer use color textures, specify min/max z

examples/globe_vector.html

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545
// # Simple Globe viewer
4646

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

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

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

7071
promises.push(globeView.addLayer({
7172
type: 'color',
72-
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',
73-
protocol: 'rasterizer',
7473
id: 'Kml',
7574
name: 'kml',
7675
transparent: true,
76+
source: {
77+
protocol: 'file',
78+
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/croquis.kml',
79+
},
7780
}));
7881

7982
promises.push(globeView.addLayer({
8083
type: 'color',
81-
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx',
82-
protocol: 'rasterizer',
8384
id: 'Gpx',
8485
name: 'Ultra 2009',
8586
transparent: true,
87+
source: {
88+
url: 'https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/ULTRA2009.gpx',
89+
protocol: 'file',
90+
},
8691
}));
8792

8893
promises.push(globeView.addLayer({
8994
type: 'color',
90-
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson',
91-
protocol: 'rasterizer',
9295
id: 'ariege',
9396
name: 'ariege',
9497
transparent: true,
@@ -97,6 +100,10 @@
97100
fillOpacity: 0.5,
98101
stroke: 'white',
99102
},
103+
source: {
104+
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson',
105+
protocol: 'file',
106+
},
100107
}));
101108

102109
var menuGlobe = new GuiTools('menuDiv', globeView);

examples/globe_vector_tiles.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@
3333
// define pole texture
3434
view.wgs84TileLayer.noTextureColor = new itowns.THREE.Color(0x95c1e1);
3535

36+
view.atmosphere.visible = false;
37+
3638
setupLoadingScreen(viewerDiv, view);
3739
function addLayerCb(layer) {
3840
return view.addLayer(layer);
3941
}
4042

4143
// Add two elevation layers.
4244
// These will deform iTowns globe geometry to represent terrain elevation.
43-
promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
44-
promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));
45+
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb));
46+
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
47+
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));
4548

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

5962
promises.push(view.addLayer({
6063
type: 'color',
61-
protocol: 'xyz',
6264
id: 'MVT',
63-
// eslint-disable-next-line no-template-curly-in-string
64-
url: 'https://osm.oslandia.io/data/v3/${z}/${x}/${y}.pbf',
65-
format: 'application/x-protobuf;type=mapbox-vector',
66-
options: {
65+
source: {
66+
protocol: 'xyz',
67+
// eslint-disable-next-line no-template-curly-in-string
68+
url: 'https://osm.oslandia.io/data/v3/${z}/${x}/${y}.pbf',
69+
format: 'application/x-protobuf;type=mapbox-vector',
70+
projection: 'EPSG:4326',
71+
origin: 'top',
6772
attribution: {
6873
name: 'OpenStreetMap',
6974
url: 'http://www.openstreetmap.org/',
@@ -72,14 +77,11 @@
7277
min: 2,
7378
max: 14,
7479
},
75-
opacity: 0.5,
76-
},
77-
updateStrategy: {
78-
type: itowns.STRATEGY_DICHOTOMY,
7980
},
8081
style: mapboxStyle,
8182
filter: mapboxFilter(supportedLayers),
8283
backgroundLayer,
84+
projection: 'EPSG:4326',
8385
}));
8486
});
8587

@@ -89,6 +91,7 @@
8991
Promise.all(promises).then(function () {
9092
menuGlobe.addImageryLayersGUI(view.getLayers(function (l) { return l.type === 'color'; }));
9193
menuGlobe.addElevationLayersGUI(view.getLayers(function (l) { return l.type === 'elevation'; }));
94+
// itowns.ColorLayersOrdering.moveLayerToIndex(view, 'Ortho', 0);
9295
}).catch(console.error);
9396
});
9497
</script>

examples/globe_wfs_color.html

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<html>
2+
<head>
3+
<title>Itowns - Globe WFS color</title>
4+
5+
<meta charset="UTF-8">
6+
<link rel="stylesheet" type="text/css" href="css/example.css">
7+
<link rel="stylesheet" type="text/css" href="css/loading_screen.css">
8+
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
10+
<script src="js/GUI/dat.gui/dat.gui.min.js"></script>
11+
</head>
12+
<body>
13+
<div id="viewerDiv"></div>
14+
<script src="js/GUI/GuiTools.js"></script>
15+
<script src="../dist/itowns.js"></script>
16+
<script src="js/loading_screen.js"></script>
17+
<script src="../dist/debug.js"></script>
18+
<div class="help" style="left: unset; right: 0;">
19+
<p><b>Information Batiment</b></p>
20+
<ul id="info">
21+
</ul>
22+
</div>
23+
<script type="text/javascript">
24+
// # Simple Globe viewer
25+
26+
// Define initial camera position
27+
var positionOnGlobe = { longitude: 4.818, latitude: 45.7354, altitude: 3000 };
28+
var promises = [];
29+
var meshes = [];
30+
var linesBus = [];
31+
var scaler;
32+
33+
// `viewerDiv` will contain iTowns' rendering area (`<canvas>`)
34+
var viewerDiv = document.getElementById('viewerDiv');
35+
36+
// Instanciate iTowns GlobeView*
37+
var globeView = new itowns.GlobeView(viewerDiv, positionOnGlobe);
38+
setupLoadingScreen(viewerDiv, globeView);
39+
function addLayerCb(layer) {
40+
return globeView.addLayer(layer);
41+
}
42+
43+
// Define projection that we will use (taken from https://epsg.io/3946, Proj4js section)
44+
itowns.proj4.defs('EPSG:3946',
45+
'+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');
46+
47+
// Add one imagery layer to the scene
48+
// This layer is defined in a json file but it could be defined as a plain js
49+
// object. See Layer* for more info.
50+
promises.push(itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb));
51+
52+
// Add two elevation layers.
53+
// These will deform iTowns globe geometry to represent terrain elevation.
54+
promises.push(itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb));
55+
promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));
56+
57+
promises.push(globeView.addLayer({
58+
type: 'color',
59+
id: 'wfsBuilding',
60+
transparent: true,
61+
style: {
62+
fill: 'red',
63+
fillOpacity: 0.5,
64+
stroke: 'white',
65+
},
66+
projection: 'EPSG:4326',
67+
source: {
68+
url: 'http://wxs.ign.fr/72hpsel8j8nhb5qgdh07gcyp/geoportail/wfs?',
69+
networkOptions: { crossOrigin: 'anonymous' },
70+
protocol: 'wfs',
71+
version: '2.0.0',
72+
typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable,BDTOPO_BDD_WLD_WGS84G:bati_indifferencie,BDTOPO_BDD_WLD_WGS84G:bati_industriel',
73+
zoom: { max: 20, min: 15 },
74+
projection: 'EPSG:4326',
75+
extent: {
76+
west: 4.568,
77+
east: 5.18,
78+
south: 45.437,
79+
north: 46.03,
80+
},
81+
ipr: 'IGN',
82+
format: 'application/json',
83+
},
84+
}));
85+
86+
var menuGlobe = new GuiTools('menuDiv', globeView);
87+
// Listen for globe full initialisation event
88+
globeView.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function () {
89+
// eslint-disable-next-line no-console
90+
console.info('Globe initialized');
91+
Promise.all(promises).then(function () {
92+
menuGlobe.addImageryLayersGUI(globeView.getLayers(function (l) { return l.type === 'color'; }));
93+
menuGlobe.addElevationLayersGUI(globeView.getLayers(function (l) { return l.type === 'elevation'; }));
94+
itowns.ColorLayersOrdering.moveLayerToIndex(globeView, 'Ortho', 0);
95+
}).catch(console.error);
96+
});
97+
var d = new debug.Debug(globeView, menuGlobe.gui);
98+
debug.createTileDebugUI(menuGlobe.gui, globeView, globeView.wgs84TileLayer, d);
99+
</script>
100+
</body>
101+
</html>

0 commit comments

Comments
 (0)