Commit b28f2442 authored by Caillat Michel's avatar Caillat Michel
Browse files

Uses the measurements defined as dicts value, unit and format the result

parent 21d5fa36
......@@ -559,10 +559,18 @@ var _marker_styles_f = function(feature) {
let selectedFeature = _selected_features_1.item(0);
let featureType = selectedFeature.getGeometry().getType();
let format = function(floatValue) {
let result = floatValue;
if (typeof result === "number" && !Number.isInteger(result)){
result = result.toExponential(4);
}
return result;
};
let populateInfosBlock = function(title, collection) {
infos_block.innerHTML = "<b>"+title+" <br><br>";
for (var k in collection) {
infos_block.innerHTML += k + ":" + collection[k] + "<br>";
infos_block.innerHTML += k + ":" + format(collection[k]["value"]) + " " + collection[k]["unit"] + "<br>";
}
}
......@@ -573,9 +581,9 @@ var _marker_styles_f = function(feature) {
case 'LineString':
var coordinates = selectedFeature.getGeometry().getCoordinates();
let properties = selectedFeature.get("properties");
let level = properties["level"].toExponential(3)
let levelUnit = properties["levelUnit"]
let title = 'Contour level ' + level + ' ' + levelUnit;
let level = properties["level"]["value"].toExponential(3);
let levelUnit = properties["level"]["unit"];
let title = 'Contour level at ' + level + ' ' + levelUnit;
infos_line.innerHTML = title;
if ("measurements" in properties) {
populateInfosBlock(title, properties["measurements"]);
......@@ -595,7 +603,7 @@ var _marker_styles_f = function(feature) {
console.log(resp["result"]);
properties["measurements"]=resp["result"];
selectedFeature.set("properties",properties);
populateInfosBlock("Contour at level "+level, properties["measurements"]);
populateInfosBlock(title, properties["measurements"]);
infos_line.innerHTML += ' <button type="button" class="btn btn-outline-link btn-sm" data-toggle="modal" data-target="#ModalInfosBlock">etc.</button>';
yAFITSContoursViewer.highlight(selectedFeature);
}
......
......@@ -95,7 +95,7 @@ class ContoursViewer {
box(feature) {
console.log("box : entering");
let br = feature.get("properties")["measurements"]["boundingRect"];
let br = feature.get("properties")["measurements"]["boundingRect"]["value"];
let corners=[[br[0], br[1]],
[br[0]+br[2]-1, br[1]],
[br[0]+br[2]-1, br[1]+br[3]-1],
......@@ -109,7 +109,7 @@ class ContoursViewer {
grid(feature) {
console.log("grid : entering");
let br = feature.get("properties")["measurements"]["boundingRect"];
let br = feature.get("properties")["measurements"]["boundingRect"]["value"];
let segments = new Array();
for (i=0; i < br[2]; i++) {
segments.push(new ol.Feature ({geometry : new ol.geom.LineString([[br[0]+i, br[1]], [br[0]+i, br[1]+br[3]-1]])}));
......@@ -122,7 +122,7 @@ class ContoursViewer {
}
importYAFITSContours(yAFITSContours) {
console.log("importYAFITSContours: entering"); console.trace();
console.log("importYAFITSContours: entering");
this.clear();
var features = new Array();
yAFITSContours.forEach((contour) => {
......@@ -133,7 +133,7 @@ class ContoursViewer {
console.log("Number of features " + features.length);
this.source.addFeatures(features);
this.show();
console.log("importYAFITSContours: exiting"); console.trace();
console.log("importYAFITSContours: exiting");
}
hide() {
......
Supports Markdown
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