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

Refacto provider and add Sources #798

Merged
merged 5 commits into from
Aug 23, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 33 additions & 25 deletions examples/cubic_planar.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
var obj;
var offset;
var tileLayer;
var config;

var wmsLayers = [
'fpc_fond_plan_communaut.fpcilot',
Expand Down Expand Up @@ -108,42 +109,49 @@
parent.add(obj);
obj.updateMatrixWorld(true);

tileLayer = itowns.createPlanarLayer('planar' + wms + index, extent, { object3d: obj });
tileLayer.disableSkirt = true;
config = {
object3d: obj,
// Since the elevation layer use color textures, specify min/max z
materialOptions: {
useColorTextureElevation: true,
colorTextureElevationMinZ: -600,
colorTextureElevationMaxZ: 400,
},
disableSkirt: true,
};

tileLayer = itowns.createPlanarLayer('planar' + wms + index, extent, config);

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: {
protocol: 'wms',
url: 'https://download.data.grandlyon.com/wms/grandlyon',
version: '1.3.0',
name: wms,
projection: 'EPSG:3946',
format: 'image/jpeg',
extent,
},
}, 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,
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
tileLayer.materialOptions = {
useColorTextureElevation: true,
colorTextureElevationMinZ: -600,
colorTextureElevationMaxZ: 400,
};
}

// Since PlanarView doesn't create default controls, we manipulate directly three.js camera
Expand Down
80 changes: 80 additions & 0 deletions examples/globe_geojson_to3D.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<html>
<head>
<title>Itowns - Globe + geoson to 3d</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" class="viewer">
<span id="tooltipDiv" class="tooltip"></span>
</div>
<script src="js/GUI/GuiTools.js"></script>
<script src="../dist/itowns.js"></script>
<script src="../dist/debug.js"></script>
<script type="text/javascript">
/* global itowns,document,GuiTools, window, debug */
var ariege;
var menuGlobe;

// Define initial camera position
var positionOnGlobe = { longitude: 1.5, latitude: 43, altitude: 300000 };

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

// Instanciate iTowns GlobeView*
var globeView = new itowns.GlobeView(viewerDiv, positionOnGlobe);

function addLayerCb(layer) {
globeView.addLayer(layer).then(menuGlobe.addLayerGUI.bind(menuGlobe));
}

// 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.
itowns.Fetcher.json('./layers/JSONLayers/Ortho.json').then(addLayerCb)

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

function extrude() {
return 5000;
}

function color() {
return new itowns.THREE.Color(0xffcc00);
}

ariege = new itowns.GeometryLayer('ariege', new itowns.THREE.Group());
ariege.update = itowns.FeatureProcessing.update;
ariege.convert = itowns.Feature2Mesh.convert({
color: color,
extrude: extrude });

ariege.source = {
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson',
protocol: 'file',
projection: 'EPSG:4326',
format: 'application/json',
zoom: { min: 7, max: 7 },
};

globeView.addLayer(ariege).then(function menue(layer) {
var gui = debug.GeometryDebug
.createGeometryDebugUI(menuGlobe.gui, globeView, layer);
debug.GeometryDebug.addWireFrameCheckbox(gui, globeView, layer);
});

menuGlobe = new GuiTools('menuDiv', globeView);
</script>
</body>
</html>



51 changes: 28 additions & 23 deletions examples/globe_vector.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<script src="js/FeatureToolTip.js"></script>
<script type="text/javascript">
// # Simple Globe viewer
/* global itowns, setupLoadingScreen, GuiTools, ToolTip */

// Define initial camera position
var positionOnGlobe = { longitude: 3.5, latitude: 44, altitude: 1000000 };
Expand All @@ -63,34 +64,38 @@
// 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));
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));
itowns.Fetcher.json('./layers/JSONLayers/WORLD_DTM.json').then(addLayerCb);
itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb);

promises.push(globeView.addLayer({
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',
projection: 'EPSG:4326',
},
});

promises.push(globeView.addLayer({
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',
projection: 'EPSG:4326',
},
});

promises.push(globeView.addLayer({
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 @@ -99,19 +104,19 @@
fillOpacity: 0.5,
stroke: 'white',
},
}));
source: {
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson',
protocol: 'file',
projection: 'EPSG:4326',
},
});

// Listen for globe full initialisation event
globeView.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function () {
globeView.addEventListener(itowns.GLOBE_VIEW_EVENTS.GLOBE_INITIALIZED, function _() {
// eslint-disable-next-line no-console
console.info('Globe initialized');
Promise.all(promises).then(function () {
itowns.ColorLayersOrdering.moveLayerToIndex(globeView, 'Ortho', 0);

new ToolTip(globeView, document.getElementById('viewerDiv'), document.getElementById('tooltipDiv'));
}).catch(console.error);


itowns.ColorLayersOrdering.moveLayerToIndex(globeView, 'Ortho', 0);
new ToolTip(globeView, document.getElementById('viewerDiv'), document.getElementById('tooltipDiv'));
});
</script>
</body>
Expand Down
30 changes: 19 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 @@ -56,14 +59,21 @@
}
});

function isValidData(data, extentDestination) {
return extentDestination.zoom - data.extent.zoom < 4;
}

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: {
isValidData: isValidData,
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,10 +82,7 @@
min: 2,
max: 14,
},
opacity: 0.5,
},
updateStrategy: {
type: itowns.STRATEGY_DICHOTOMY,
tileMatrixSet: 'PM',
},
style: mapboxStyle,
filter: mapboxFilter(supportedLayers),
Expand All @@ -89,6 +96,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
Loading