Skip to content

Commit

Permalink
start remove wfs provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Jul 19, 2018
1 parent eab0d23 commit 86a4f54
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 126 deletions.
258 changes: 133 additions & 125 deletions examples/globe_wfs_extruded.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,67 +53,67 @@

// 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/WORLD_DTM.json').then(addLayerCb));
// promises.push(itowns.Fetcher.json('./layers/JSONLayers/IGN_MNT_HIGHRES.json').then(addLayerCb));

function altitudeLine(properties, contour) {
var altitudes = [];
var i = 0;
var result;
var tile;
var layer = globeView.wgs84TileLayer;
if (contour.length && contour.length > 0) {
for (; i < contour.length; i++) {
result = itowns.DEMUtils.getElevationValueAt(layer, contour[i], 0, tile);
if (!result) {
result = itowns.DEMUtils.getElevationValueAt(layer, contour[i], 0);
}
tile = [result.tile];
altitudes.push(result.z + 2);
}
return altitudes;
}
return 0;
}
// function altitudeLine(properties, contour) {
// var altitudes = [];
// var i = 0;
// var result;
// var tile;
// var layer = globeView.wgs84TileLayer;
// if (contour.length && contour.length > 0) {
// for (; i < contour.length; i++) {
// result = itowns.DEMUtils.getElevationValueAt(layer, contour[i], 0, tile);
// if (!result) {
// result = itowns.DEMUtils.getElevationValueAt(layer, contour[i], 0);
// }
// tile = [result.tile];
// altitudes.push(result.z + 2);
// }
// return altitudes;
// }
// return 0;
// }

function colorLine(properties) {
var rgb = properties.couleur.split(' ');
return new itowns.THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
}
// function colorLine(properties) {
// var rgb = properties.couleur.split(' ');
// return new itowns.THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
// }

function acceptFeatureBus(properties) {
var line = properties.ligne + properties.sens;
if (linesBus.indexOf(line) === -1) {
linesBus.push(line);
return true;
}
return false;
}
// function acceptFeatureBus(properties) {
// var line = properties.ligne + properties.sens;
// if (linesBus.indexOf(line) === -1) {
// linesBus.push(line);
// return true;
// }
// return false;
// }

globeView.addLayer({
name: 'lyon_tcl_bus',
type: 'geometry',
update: itowns.FeatureProcessing.update,
convert: itowns.Feature2Mesh.convert({
color: colorLine,
altitude: altitudeLine }),
linewidth: 5,
filter: acceptFeatureBus,
url: 'https://download.data.grandlyon.com/wfs/rdata?',
protocol: 'wfs',
version: '2.0.0',
id: 'WFS Bus lines',
typeName: 'tcl_sytral.tcllignebus',
level: 9,
projection: 'EPSG:3946',
extent: {
west: 1822174.60,
east: 1868247.07,
south: 5138876.75,
north: 5205890.19,
},
format: 'geojson',
});
// globeView.addLayer({
// name: 'lyon_tcl_bus',
// type: 'geometry',
// update: itowns.FeatureProcessing.update,
// convert: itowns.Feature2Mesh.convert({
// color: colorLine,
// altitude: altitudeLine }),
// linewidth: 5,
// filter: acceptFeatureBus,
// url: 'https://download.data.grandlyon.com/wfs/rdata?',
// protocol: 'wfs',
// version: '2.0.0',
// id: 'WFS Bus lines',
// typeName: 'tcl_sytral.tcllignebus',
// level: 9,
// projection: 'EPSG:3946',
// extent: {
// west: 1822174.60,
// east: 1868247.07,
// south: 5138876.75,
// north: 5205890.19,
// },
// format: 'geojson',
// });

function colorBuildings(properties) {
if (properties.id.indexOf('bati_remarquable') === 0) {
Expand Down Expand Up @@ -155,6 +155,7 @@

globeView.addFrameRequester(itowns.MAIN_LOOP_EVENTS.BEFORE_RENDER, scaler);
globeView.addLayer({
id: 'WFS Buildings',
type: 'geometry',
update: itowns.FeatureProcessing.update,
convert: itowns.Feature2Mesh.convert({
Expand All @@ -166,69 +167,76 @@
meshes.push(mesh);
},
filter: acceptFeature,
url: 'http://wxs.ign.fr/72hpsel8j8nhb5qgdh07gcyp/geoportail/wfs?',
networkOptions: { crossOrigin: 'anonymous' },
protocol: 'wfs',
version: '2.0.0',
id: 'WFS Buildings',
typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable,BDTOPO_BDD_WLD_WGS84G:bati_indifferencie,BDTOPO_BDD_WLD_WGS84G:bati_industriel',
level: 14,
projection: 'EPSG:4326',
ipr: 'IGN',
format: 'application/json',
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: { min: 14, max: 14 },
projection: 'EPSG:4326',
ipr: 'IGN',
format: 'application/json',
extent: {
west: 4.568,
east: 5.18,
south: 45.437,
north: 46.03,
},
}
});

function configPointMaterial(result) {
var i = 0;
var mesh;
for (; i < result.children.length; i++) {
mesh = result.children[i];
// function configPointMaterial(result) {
// var i = 0;
// var mesh;
// for (; i < result.children.length; i++) {
// mesh = result.children[i];

mesh.material.sizeAttenuation = false;
}
}
// mesh.material.sizeAttenuation = false;
// }
// }

function colorPoint(/* properties */) {
return new itowns.THREE.Color(0x7F180D);
}
// function colorPoint(/* properties */) {
// return new itowns.THREE.Color(0x7F180D);
// }

function selectRoad(properties) {
return properties.gestion === 'CEREMA';
}
// function selectRoad(properties) {
// return properties.gestion === 'CEREMA';
// }

function altitudePoint(properties, contour) {
var result;
var z = 0;
if (contour.length && contour.length > 0) {
result = itowns.DEMUtils.getElevationValueAt(globeView.wgs84TileLayer, contour[0]);
if (result) {
z = result.z;
}
return z + 5;
}
return 0;
}
// function altitudePoint(properties, contour) {
// var result;
// var z = 0;
// if (contour.length && contour.length > 0) {
// result = itowns.DEMUtils.getElevationValueAt(globeView.wgs84TileLayer, contour[0]);
// if (result) {
// z = result.z;
// }
// return z + 5;
// }
// return 0;
// }

globeView.addLayer({
type: 'geometry',
update: itowns.FeatureProcessing.update,
convert: itowns.Feature2Mesh.convert({
altitude: altitudePoint,
color: colorPoint }),
size: 5,
onMeshCreated: configPointMaterial,
filter: selectRoad,
url: 'http://wxs.ign.fr/72hpsel8j8nhb5qgdh07gcyp/geoportail/wfs?',
networkOptions: { crossOrigin: 'anonymous' },
protocol: 'wfs',
version: '2.0.0',
id: 'WFS Route points',
typeName: 'BDPR_BDD_FXX_LAMB93_20170911:pr',
level: 12,
projection: 'EPSG:2154',
ipr: 'IGN',
format: 'application/json',
});
// globeView.addLayer({
// type: 'geometry',
// update: itowns.FeatureProcessing.update,
// convert: itowns.Feature2Mesh.convert({
// altitude: altitudePoint,
// color: colorPoint }),
// size: 5,
// onMeshCreated: configPointMaterial,
// filter: selectRoad,
// url: 'http://wxs.ign.fr/72hpsel8j8nhb5qgdh07gcyp/geoportail/wfs?',
// networkOptions: { crossOrigin: 'anonymous' },
// protocol: 'wfs',
// version: '2.0.0',
// id: 'WFS Route points',
// typeName: 'BDPR_BDD_FXX_LAMB93_20170911:pr',
// level: 12,
// projection: 'EPSG:2154',
// ipr: 'IGN',
// format: 'application/json',
// });

var menuGlobe = new GuiTools('menuDiv', globeView);
// Listen for globe full initialisation event
Expand Down Expand Up @@ -266,25 +274,25 @@
}

for (let layer of globeView.getLayers()) {
if (layer.id === 'WFS Bus lines') {
layer.whenReady.then( function _(layer) {
var gui = debug.GeometryDebug.createGeometryDebugUI(menuGlobe.gui, globeView, layer);
debug.GeometryDebug.addMaterialLineWidth(gui, globeView, layer, 1, 10);
});
}
// if (layer.id === 'WFS Bus lines') {
// layer.whenReady.then( function _(layer) {
// var gui = debug.GeometryDebug.createGeometryDebugUI(menuGlobe.gui, globeView, layer);
// debug.GeometryDebug.addMaterialLineWidth(gui, globeView, layer, 1, 10);
// });
// }
if (layer.id === 'WFS Buildings') {
layer.whenReady.then( function _(layer) {
var gui = debug.GeometryDebug.createGeometryDebugUI(menuGlobe.gui, globeView, layer);
debug.GeometryDebug.addWireFrameCheckbox(gui, globeView, layer);
window.addEventListener('mousemove', picking, false);
});
}
if (layer.id === 'WFS Route points') {
layer.whenReady.then( function _(layer) {
var gui = debug.GeometryDebug.createGeometryDebugUI(menuGlobe.gui, globeView, layer);
debug.GeometryDebug.addMaterialSize(gui, globeView, layer, 1, 50);
});
}
// if (layer.id === 'WFS Route points') {
// layer.whenReady.then( function _(layer) {
// var gui = debug.GeometryDebug.createGeometryDebugUI(menuGlobe.gui, globeView, layer);
// debug.GeometryDebug.addMaterialSize(gui, globeView, layer, 1, 50);
// });
// }
}
</script>
</body>
Expand Down
8 changes: 7 additions & 1 deletion src/Process/FeatureProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function applyOffset(obj, offset, quaternion, offsetAltitude) {
obj.children.forEach(c => applyOffset(c, offset, quaternion, offsetAltitude));
}

const tileInsideLimit = (node, source, parent, pitch) =>
source.extentInsideLimit(node.getCoordsForLayer(source), node.level, node.level, parent, pitch);

const quaternion = new THREE.Quaternion();
export default {
update(context, layer, node) {
Expand Down Expand Up @@ -64,7 +67,9 @@ export default {
return features;
}

if (!layer.tileInsideLimit(node, layer)) {
const extents = [];
const pitchs = [];
if (!tileInsideLimit(node, layer.source, extents, pitchs)) {
return;
}

Expand All @@ -82,6 +87,7 @@ export default {

const command = {
layer,
extents,
view: context.view,
threejsLayer: layer.threejsLayer,
requester: node,
Expand Down

0 comments on commit 86a4f54

Please sign in to comment.