Commit b2181b39 authored by Anne Blankert's avatar Anne Blankert

update api usage

parent 27e7ce4c
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
return result; return result;
} }
function showMapLayer(fullTableName, geomType, attrName, attrType, classLabels) { function showMapLayer(fullTableName, geomColumn, geomType, attrName, attrType, classLabels) {
let layerType, paint; let layerType, paint;
const classLabelAndColors = classLabels.reduce((result, key, index)=>{ const classLabelAndColors = classLabels.reduce((result, key, index)=>{
result.push(key); result.push(key);
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
} }
if (layerType){ if (layerType){
const baseUrl = new URL(`/data`, window.location.href).href; const baseUrl = new URL(`/data`, window.location.href).href;
const url = `${baseUrl}/${fullTableName}/mvt/{z}/{x}/{y}?columns="${attrName}"` const url = `${baseUrl}/${fullTableName}/mvt/{z}/{x}/{y}?columns="${attrName}"${geomColumn?`&geom_column=${geomColumn}`:''}`
console.log(`url: ${url}`); console.log(`url: ${url}`);
const layer = { const layer = {
"id": "attrlayer", "id": "attrlayer",
...@@ -236,6 +236,7 @@ ...@@ -236,6 +236,7 @@
const attrName = urlParams.get("column"); const attrName = urlParams.get("column");
const attrType = urlParams.get("columntype"); const attrType = urlParams.get("columntype");
const geomType = urlParams.get('geomtype'); const geomType = urlParams.get('geomtype');
const geomColumn = urlParams.get('geom_column');
document.querySelector('#tablename').innerHTML = fullTableName; document.querySelector('#tablename').innerHTML = fullTableName;
document.querySelector('#columnname').innerHTML = `${attrName} (${attrType})`; document.querySelector('#columnname').innerHTML = `${attrName} (${attrType})`;
document.querySelector('#back').innerHTML = `<a href="tableinfo.html?table=${fullTableName}">Terug naar layer informatie</a>` document.querySelector('#back').innerHTML = `<a href="tableinfo.html?table=${fullTableName}">Terug naar layer informatie</a>`
...@@ -374,7 +375,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear ...@@ -374,7 +375,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
} }
} }
}); });
showMapLayer(fullTableName, geomType, attrName, attrType, classBorders); showMapLayer(fullTableName, geomColumn, geomType, attrName, attrType, classBorders);
} }
if (verdeling) { if (verdeling) {
const values = Array.from(verdeling.values()); const values = Array.from(verdeling.values());
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const fullTableName = urlParams.get('table'); const fullTableName = urlParams.get('table');
const geomType = urlParams.get('geomtype'); const geomType = urlParams.get('geomtype');
const geomcolumn = urlParams.get('geom_column')
document.querySelector('#tablename').innerHTML = fullTableName; document.querySelector('#tablename').innerHTML = fullTableName;
const parts = fullTableName.split('.'); const parts = fullTableName.split('.');
const tableName = (parts.length > 1) ? parts[1] : parts[0]; const tableName = (parts.length > 1) ? parts[1] : parts[0];
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
response.json().then(json=> { response.json().then(json=> {
for (item of json) { for (item of json) {
const li = document.createElement('li'); const li = document.createElement('li');
li.innerHTML = `<a href="./attrinfo.html?table=${fullTableName}&column=${item.field_name}&columntype=${item.field_type}&geomtype=${geomType}"><b>${item.field_name}</b></a> (${item.field_type})` li.innerHTML = `<a href="./attrinfo.html?table=${fullTableName}&geom_column=${geomcolumn?geomcolumn:''}&column=${item.field_name}&columntype=${item.field_type}&geomtype=${geomType}"><b>${item.field_name}</b></a> (${item.field_type})`
list.appendChild(li); list.appendChild(li);
} }
}) })
...@@ -30,14 +31,16 @@ ...@@ -30,14 +31,16 @@
list.appendChild(li); list.appendChild(li);
} }
}) })
fetch(`api/bbox/${fullTableName}`).then(response=>{ fetch(`api/bbox/${fullTableName}${geomcolumn?`?geom_column=${geomcolumn}`:''}`).then(response=>{
const bbox = document.querySelector('#bbox'); const bbox = document.querySelector('#bbox');
if (response.ok) { if (response.ok) {
response.json().then(json=> { response.json().then(json=> {
bbox.innerHTML = ""; bbox.innerHTML = `number of rows: ${json.allrows}<br>
for (item of json) { number of geometries: ${json.geomrows}<br>
bbox.innerHTML += item.bbox; srid: EPSG:${json.srid}<br>
} bbox lon/lat: sw: ${json.bboxll[0][0]},${json.bboxll[0][1]}, ne: ${json.bboxll[1][0]},${json.bboxll[1][1]}<br>
bbox (EPSG:${json.srid}): ll: ${json.bboxsrid[0][0]},${json.bboxsrid[0][1]}, tr: ${json.bboxsrid[1][0]},${json.bboxsrid[1][1]}<br>
`
}) })
} else { } else {
bbox.innerHTML = `Error getting bbox, response: response: ${response.status} ${response.statusText?response.statusText:''} ${response.url}` bbox.innerHTML = `Error getting bbox, response: response: ${response.status} ${response.statusText?response.statusText:''} ${response.url}`
...@@ -47,10 +50,10 @@ ...@@ -47,10 +50,10 @@
</script> </script>
</head> </head>
<body onload="init()"> <body onload="init()">
<h1>Layer informatie</h1> <h1>Layer info</h1>
<h2 id="tablename"></h2> <h2 id="tablename"></h2>
<div id="bbox">waiting for bbox...</div> <div id="bbox">waiting for table stats...</div>
<ul id="columns"></ul> <ul id="columns"></ul>
<a href="info.html">Terug naar layer overzicht</a> <a href="info.html">Back to layer overviewe</a>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment