Skip to content
Snippets Groups Projects
Commit 84ed4610 authored by Olabarrieta Palacios, Ignacio's avatar Olabarrieta Palacios, Ignacio
Browse files
parents 317f55f7 8c457db4
No related branches found
No related tags found
No related merge requests found
...@@ -132,6 +132,7 @@ export class ExistingSimulationsComponent implements OnInit { ...@@ -132,6 +132,7 @@ export class ExistingSimulationsComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.resetButtonsAndStatuses(); this.resetButtonsAndStatuses();
this.calculateKPISBtnDisabled = true;
this.simulationService this.simulationService
.getSimulationsAll() .getSimulationsAll()
...@@ -203,6 +204,7 @@ export class ExistingSimulationsComponent implements OnInit { ...@@ -203,6 +204,7 @@ export class ExistingSimulationsComponent implements OnInit {
this.selectedSimulation = simulation; this.selectedSimulation = simulation;
this.selectedSimulationToEmit.emit(simulation); this.selectedSimulationToEmit.emit(simulation);
this.compareWithSimulations = []; this.compareWithSimulations = [];
this.calculateKPISBtnDisabled = false;
this.simulations.forEach((sim) => { this.simulations.forEach((sim) => {
if (simulation.city.cityId == sim.city["cityId"]) { if (simulation.city.cityId == sim.city["cityId"]) {
......
...@@ -48,7 +48,7 @@ export class OurSpiderChartComponent implements OnChanges { ...@@ -48,7 +48,7 @@ export class OurSpiderChartComponent implements OnChanges {
}, },
ticks: { ticks: {
beginAtZero: true, beginAtZero: true,
max: 4, max: 5,
min: 0, min: 0,
stepSize: 1, stepSize: 1,
}, },
...@@ -91,7 +91,7 @@ export class OurSpiderChartComponent implements OnChanges { ...@@ -91,7 +91,7 @@ export class OurSpiderChartComponent implements OnChanges {
for (let i = 0; i < tmpLabels.length; i++) { for (let i = 0; i < tmpLabels.length; i++) {
if (tmpLabels[i] == entry[0]) { if (tmpLabels[i] == entry[0]) {
if (/^[0-4]$/.test(entry[1] as string)) { if (/^[0-5]$/.test(entry[1] as string)) {
if (j == 0) { if (j == 0) {
values_A.push(entry[1] as string); values_A.push(entry[1] as string);
} else if (j == 1) { } else if (j == 1) {
...@@ -212,7 +212,7 @@ export class OurSpiderChartComponent implements OnChanges { ...@@ -212,7 +212,7 @@ export class OurSpiderChartComponent implements OnChanges {
entries.forEach((entry) => { entries.forEach((entry) => {
for (let i = 0; i < tmpLabels.length; i++) { for (let i = 0; i < tmpLabels.length; i++) {
if (tmpLabels[i] == entry[0]) { if (tmpLabels[i] == entry[0]) {
if (/^[0-4]$/.test(entry[1] as string)) { if (/^[0-5]$/.test(entry[1] as string)) {
if (j == 0) { if (j == 0) {
values_A.push(entry[1] as string); values_A.push(entry[1] as string);
} else if (j == 1) { } else if (j == 1) {
......
...@@ -14,18 +14,20 @@ ...@@ -14,18 +14,20 @@
<div id="loadGeojsonButtonsContainer"> <div id="loadGeojsonButtonsContainer">
<button <button
nbButton nbButton
size="small" size="medium"
(click)="onLoadClick(l.buttonLabel)" (click)="onLoadClick(l.buttonValue)"
nbTooltip="Select a simulation in order to use this button. GET http://localhost:8083/dss/geojson/{id}/selectedKpi" nbTooltip="Select a simulation in order to use this button. GET http://localhost:8083/dss/geojson/{id}/selectedKpi"
[disabled]="selectedSimulation == undefined" [disabled]="selectedSimulation == undefined"
[nbSpinner]="geojsonLoading" [nbSpinner]="geojsonLoading"
[status]="selectedGeojson == l.buttonLabel ? 'control' : 'primary'" [status]="selectedGeojson == l.buttonValue ? 'control' : 'primary'"
*ngFor="let l of loadGeojsons" *ngFor="let l of loadGeojsons"
> >
load {{ l.buttonLabel }} geojson {{ l.buttonLabel }}
</button> </button>
<span class="flex-grow-1"></span>
<button <button
nbButton nbButton
size="medium"
(click)="openOverviewOfIndicators(dialog)" (click)="openOverviewOfIndicators(dialog)"
nbTooltip="click for overview of indicators" nbTooltip="click for overview of indicators"
[disabled]="selectedSimulation == undefined" [disabled]="selectedSimulation == undefined"
......
...@@ -35,10 +35,11 @@ ...@@ -35,10 +35,11 @@
width: calc(100% - 114px); width: calc(100% - 114px);
border-radius: 0.25rem; border-radius: 0.25rem;
display: flex; display: flex;
justify-content: space-around; justify-content: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
button { button {
margin: 2px; margin: 2px 5px;
text-transform: capitalize;
} }
} }
} }
......
...@@ -25,24 +25,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -25,24 +25,7 @@ export class ResultsMapComponent implements OnChanges {
}; };
mapLegend = new L.Control({ position: "bottomright" }); mapLegend = new L.Control({ position: "bottomright" });
radioButtonLayersControl: any; radioButtonLayersControl: any;
loadGeojsons: Object[] = [ loadGeojsons: Object[] = [];
{
response: undefined,
buttonLabel: "bikeability",
},
{
response: undefined,
buttonLabel: "bikeIntensity",
},
{
response: undefined,
buttonLabel: "bikeSafety",
},
{
response: undefined,
buttonLabel: "pollution",
},
];
checkedRadioButton: string = ""; checkedRadioButton: string = "";
geoJsonStyleWeight: number = 5; geoJsonStyleWeight: number = 5;
geoJsonStyleOpacity: number = 0.8; geoJsonStyleOpacity: number = 0.8;
...@@ -51,6 +34,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -51,6 +34,7 @@ export class ResultsMapComponent implements OnChanges {
geojsonLoading: boolean = false; geojsonLoading: boolean = false;
@Input() selectedSimulation: Simulation; @Input() selectedSimulation: Simulation;
selectedGeojson: string = ""; selectedGeojson: string = "";
extractingKeysLoopLimit: number = 3498;
constructor( constructor(
private simulationService: SimulationService, private simulationService: SimulationService,
...@@ -88,13 +72,13 @@ export class ResultsMapComponent implements OnChanges { ...@@ -88,13 +72,13 @@ export class ResultsMapComponent implements OnChanges {
onLoadClick(selectedKpi: string) { onLoadClick(selectedKpi: string) {
this.selectedGeojson = selectedKpi; this.selectedGeojson = selectedKpi;
this.resetLayersAndButton(); this.resetLayersAndButton();
this.setMapZoom(); this.setMapZoomAndLoadGeojsons();
if (this.radioButtonLayersControl) if (this.radioButtonLayersControl)
this.radioButtonLayersControl.remove(this.map); this.radioButtonLayersControl.remove(this.map);
this.loadGeojsons.forEach((geojson, index) => { this.loadGeojsons.forEach((geojson, index) => {
if (geojson["buttonLabel"] == selectedKpi) { if (geojson["buttonValue"] == selectedKpi) {
if (this.loadGeojsons[index]["response"] == undefined) { if (this.loadGeojsons[index]["response"] == undefined) {
this.toastrService.show("This might take a while", "Info", { this.toastrService.show("This might take a while", "Info", {
status: "info", status: "info",
...@@ -131,7 +115,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -131,7 +115,7 @@ export class ResultsMapComponent implements OnChanges {
handleResponse(selectedKpi, res) { handleResponse(selectedKpi, res) {
this.loadGeojsons.forEach((geojson, index) => { this.loadGeojsons.forEach((geojson, index) => {
if (geojson["buttonLabel"] == selectedKpi) { if (geojson["buttonValue"] == selectedKpi) {
this.loadGeojsons[index]["response"] = res; this.loadGeojsons[index]["response"] = res;
} }
}); });
...@@ -329,10 +313,11 @@ export class ResultsMapComponent implements OnChanges { ...@@ -329,10 +313,11 @@ export class ResultsMapComponent implements OnChanges {
} }
Object.entries(feature).forEach((element) => { Object.entries(feature).forEach((element) => {
const tmp = this.limitMyDigits(element[1] as number).toString();
if (element[0] == this.checkedRadioButton) { if (element[0] == this.checkedRadioButton) {
text += `<u><strong>${element[0]}:</strong> ${element[1]}</u><br>`; text += `<u><strong>${element[0]}:</strong> ${tmp}</u><br>`;
} else { } else {
text += `<strong>${element[0]}:</strong> ${element[1]}<br>`; text += `<strong>${element[0]}:</strong> ${tmp}<br>`;
} }
text += `<span style='display: inline-block; margin-bottom: 7px; color: #666'>(unrounded) ${element[1]}</span><br>`; text += `<span style='display: inline-block; margin-bottom: 7px; color: #666'>(unrounded) ${element[1]}</span><br>`;
}); });
...@@ -357,7 +342,11 @@ export class ResultsMapComponent implements OnChanges { ...@@ -357,7 +342,11 @@ export class ResultsMapComponent implements OnChanges {
public extractKeys(jsonFile) { public extractKeys(jsonFile) {
let allKeys = []; let allKeys = [];
for (let f = 0; f < jsonFile["features"].length && f < 3498; f++) { for (
let f = 0;
f < jsonFile["features"].length && f < this.extractingKeysLoopLimit;
f++
) {
let iterator; let iterator;
Object.keys(jsonFile["features"][f]["properties"]).forEach((element) => { Object.keys(jsonFile["features"][f]["properties"]).forEach((element) => {
if (!allKeys.includes(element)) { if (!allKeys.includes(element)) {
...@@ -624,19 +613,118 @@ export class ResultsMapComponent implements OnChanges { ...@@ -624,19 +613,118 @@ export class ResultsMapComponent implements OnChanges {
el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)"; el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)";
} }
setMapZoom() { setMapZoomAndLoadGeojsons() {
if (this.selectedSimulation != undefined) { if (this.selectedSimulation != undefined) {
if (this.selectedSimulation["city"]["cityId"] == "amsterdam") { if (this.selectedSimulation["city"]["cityId"] == "amsterdam") {
this.map.setView(new L.LatLng(52.4, 4.9), 9); this.map.setView(new L.LatLng(52.4, 4.9), 9);
this.loadGeojsons = [
{
response: undefined,
buttonValue: "bikeability",
buttonLabel: "bikeability",
},
{
response: undefined,
buttonValue: "bikeIntensity",
buttonLabel: "bike Intensity",
},
{
response: undefined,
buttonValue: "bikeSafety",
buttonLabel: "bike Safety",
},
{
response: undefined,
buttonValue: "pollution",
buttonLabel: "pollution",
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "bilbao") { } else if (this.selectedSimulation["city"]["cityId"] == "bilbao") {
this.map.setView(new L.LatLng(43.3, -2.9), 9); this.map.setView(new L.LatLng(43.3, -2.9), 9);
console.log(
"%c buttons set might not be the right ones for bilbao",
"background: indianred; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
);
this.loadGeojsons = [
{
response: undefined,
buttonValue: "bikeability",
buttonLabel: "bikeability",
},
{
response: undefined,
buttonValue: "bikeIntensity",
buttonLabel: "bike Intensity",
},
{
response: undefined,
buttonValue: "bikeSafety",
buttonLabel: "bike Safety",
},
{
response: undefined,
buttonValue: "pollution",
buttonLabel: "pollution",
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "helsinki") { } else if (this.selectedSimulation["city"]["cityId"] == "helsinki") {
this.map.setView( this.map.setView(
new L.LatLng(60.16005488265436, 24.920971999284017), new L.LatLng(60.16005488265436, 24.920971999284017),
13 13
); );
this.loadGeojsons = [
{
response: undefined,
buttonValue: "congestionsAndBottlenecks",
buttonLabel: "congestions And Bottlenecks",
},
{
response: undefined,
buttonValue: "harbourAreaTrafficFlow",
buttonLabel: "harbour Area Traffic Flow",
},
{
response: undefined,
buttonValue: "accousticPollution",
buttonLabel: "accoustic Pollution",
},
{
response: undefined,
buttonValue: "pollution",
buttonLabel: "pollution",
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "messina") { } else if (this.selectedSimulation["city"]["cityId"] == "messina") {
this.map.setView(new L.LatLng(38.2, 15.6), 9); this.map.setView(
new L.LatLng(38.10119097299323, 15.491646372349038),
9
);
console.log(
"%c buttons set might not be the right ones for messina",
"background: magenta; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
);
this.loadGeojsons = [
{
response: undefined,
buttonValue: "bikeability",
buttonLabel: "bikeability",
},
{
response: undefined,
buttonValue: "bikeIntensity",
buttonLabel: "bike Intensity",
},
{
response: undefined,
buttonValue: "bikeSafety",
buttonLabel: "bike Safety",
},
{
response: undefined,
buttonValue: "pollution",
buttonLabel: "pollution",
},
];
} else { } else {
this.toastrService.show("Unexpected value for city name.", "Error", { this.toastrService.show("Unexpected value for city name.", "Error", {
status: "danger", status: "danger",
...@@ -677,6 +765,6 @@ export class ResultsMapComponent implements OnChanges { ...@@ -677,6 +765,6 @@ export class ResultsMapComponent implements OnChanges {
entry[1]["response"] = undefined; entry[1]["response"] = undefined;
}); });
this.setMapZoom(); this.setMapZoomAndLoadGeojsons();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment