Skip to content
Snippets Groups Projects
Commit 95f6939a authored by Olabarrieta Palacios, Ignacio's avatar Olabarrieta Palacios, Ignacio
Browse files
parents ce997253 c085ef05
No related branches found
No related tags found
No related merge requests found
...@@ -422,7 +422,7 @@ export class ExistingSimulationsComponent implements OnInit { ...@@ -422,7 +422,7 @@ export class ExistingSimulationsComponent implements OnInit {
); );
this.runDss.status = ""; this.runDss.status = "";
// rudimentary way of concincing our-spider-chart to redownload evaluated json // rudimentary way of convincing our-spider-chart to redownload evaluated json
this.selectedSimulationToEmit.emit(undefined); this.selectedSimulationToEmit.emit(undefined);
setTimeout(() => { setTimeout(() => {
this.selectedSimulationToEmit.emit(this.selectedSimulation); this.selectedSimulationToEmit.emit(this.selectedSimulation);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
padding: 4px 3px 0 3px; padding: 4px 3px 0 3px;
} }
#loadGeojsonButtonsContainer { #loadGeojsonButtonsContainer {
z-index: 1003; z-index: 997;
position: absolute; position: absolute;
top: 5px; top: 5px;
left: 57px; left: 57px;
......
...@@ -5,6 +5,7 @@ import * as MapColors from "./map-colors-local"; ...@@ -5,6 +5,7 @@ import * as MapColors from "./map-colors-local";
import { legendInverted, ratiosBetweenGrades } from "./results-map-settings"; import { legendInverted, ratiosBetweenGrades } from "./results-map-settings";
import { NbToastrService, NbDialogService } from "@nebular/theme"; import { NbToastrService, NbDialogService } from "@nebular/theme";
import { Simulation } from "../utils/data/simulation"; import { Simulation } from "../utils/data/simulation";
import { NetworkService } from "../utils/services/network.service";
@Component({ @Component({
selector: "ngx-results-map", selector: "ngx-results-map",
...@@ -39,13 +40,17 @@ export class ResultsMapComponent implements OnChanges { ...@@ -39,13 +40,17 @@ export class ResultsMapComponent implements OnChanges {
constructor( constructor(
private simulationService: SimulationService, private simulationService: SimulationService,
private toastrService: NbToastrService, private toastrService: NbToastrService,
private dialogService: NbDialogService private dialogService: NbDialogService,
private networkService: NetworkService
) {} ) {}
onMapReady(map: L.Map) { onMapReady(map: L.Map) {
this.map = map; this.map = map;
this.grayscaleChange(); this.grayscaleChange();
setTimeout(() => { setTimeout(() => {
this.map.invalidateSize(); this.map.invalidateSize();
this.networkService.getMapInfo().subscribe((res) => {
this.setMapPositionAndZoom(res);
});
}, 50); }, 50);
// setTimeout(() => { // setTimeout(() => {
// console.log( // console.log(
...@@ -53,7 +58,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -53,7 +58,7 @@ export class ResultsMapComponent implements OnChanges {
// "background: crimson; font-weight: bold; color: black; font-family: serif; padding: 0 10px;" // "background: crimson; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
// ); // );
// const celkomplet: HTMLElement = document.querySelectorAll( // const celkomplet: HTMLElement = document.querySelectorAll(
// ".ng-tns-c441-0.appearance-filled.size-medium.shape-rectangle.status-primary.ng-star-inserted.nb-transition" // ".appearance-filled.size-medium.shape-rectangle.status-primary.ng-star-inserted.nb-transition"
// )[1] as HTMLElement; // )[1] as HTMLElement;
// celkomplet.click(); // celkomplet.click();
// }, 995); // }, 995);
...@@ -63,7 +68,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -63,7 +68,7 @@ export class ResultsMapComponent implements OnChanges {
// "background: peru; font-weight: bold; color: black; font-family: serif; padding: 0 10px;" // "background: peru; font-weight: bold; color: black; font-family: serif; padding: 0 10px;"
// ); // );
// const celkomplet: HTMLElement = document.querySelectorAll( // const celkomplet: HTMLElement = document.querySelectorAll(
// ".buttons.ng-tns-c441-0" // ".buttons"
// )[0] as HTMLElement; // )[0] as HTMLElement;
// celkomplet.style.display = "none"; // celkomplet.style.display = "none";
// }, 1000); // }, 1000);
...@@ -72,7 +77,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -72,7 +77,7 @@ export class ResultsMapComponent implements OnChanges {
onLoadClick(selectedKpi: string) { onLoadClick(selectedKpi: string) {
this.selectedGeojson = selectedKpi; this.selectedGeojson = selectedKpi;
this.resetLayersAndButton(); this.resetLayersAndButton();
this.setMapZoomAndLoadGeojsons(); this.setLoadGeojsons();
if (this.radioButtonLayersControl) if (this.radioButtonLayersControl)
this.radioButtonLayersControl.remove(this.map); this.radioButtonLayersControl.remove(this.map);
...@@ -122,7 +127,7 @@ export class ResultsMapComponent implements OnChanges { ...@@ -122,7 +127,7 @@ export class ResultsMapComponent implements OnChanges {
if (res["message"] == "Calculating...") { if (res["message"] == "Calculating...") {
this.toastrService.show( this.toastrService.show(
"Server says: Calculating the KPI visualization. GEOJSON loading will not be completed.", "Server says: Calculating the KPI visualization. GEOJSON loading will not be completed. When it will be ready, you will need to refresh the page.",
"Geojson not ready", "Geojson not ready",
{ {
status: "danger", status: "danger",
...@@ -175,9 +180,12 @@ export class ResultsMapComponent implements OnChanges { ...@@ -175,9 +180,12 @@ export class ResultsMapComponent implements OnChanges {
if ( if (
propertyGeojsons[i].myKey == "link_id" || propertyGeojsons[i].myKey == "link_id" ||
propertyGeojsons[i].myKey == "modes" || propertyGeojsons[i].myKey == "modes" ||
propertyGeojsons[i].myKey == "internal_travel_by_mode" propertyGeojsons[i].myKey == "internal_travel_by_mode" ||
) propertyGeojsons[i].myKey == "pt_vehicles"
) {
console.log("Ignoring key ", propertyGeojsons[i].myKey);
continue; continue;
}
obj[`${keys[i]}`] = propertyGeojsons[i]; obj[`${keys[i]}`] = propertyGeojsons[i];
} }
this.radioButtonLayersControl = new L.Control.Layers(obj, null, { this.radioButtonLayersControl = new L.Control.Layers(obj, null, {
...@@ -613,124 +621,17 @@ export class ResultsMapComponent implements OnChanges { ...@@ -613,124 +621,17 @@ export class ResultsMapComponent implements OnChanges {
el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)"; el.style.filter = "grayscale(" + (100 - this.grayscale) + "%)";
} }
setMapZoomAndLoadGeojsons() { setLoadGeojsons() {
if (this.selectedSimulation != undefined) { this.networkService.getKpiVisInfo().subscribe((res) => {
if (this.selectedSimulation["city"]["cityId"] == "amsterdam") { this.loadGeojsons = [];
this.map.setView(new L.LatLng(52.4, 4.9), 9); res.forEach((but) => {
this.loadGeojsons = [ this.loadGeojsons.push({
{
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") {
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") {
this.map.setView(
new L.LatLng(60.16005488265436, 24.920971999284017),
13
);
this.loadGeojsons = [
{
response: undefined,
buttonValue: "congestionsAndBottlenecks",
buttonLabel: "congestions And Bottlenecks",
},
{
response: undefined, response: undefined,
buttonValue: "harbourAreaTrafficFlow", buttonValue: but["buttonValue"],
buttonLabel: "harbour Area Traffic Flow", buttonLabel: but["buttonLabel"],
}, });
{ });
response: undefined,
buttonValue: "accousticPollution",
buttonLabel: "accoustic Pollution",
},
{
response: undefined,
buttonValue: "pollution",
buttonLabel: "pollution",
},
];
} else if (this.selectedSimulation["city"]["cityId"] == "messina") {
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 {
this.toastrService.show("Unexpected value for city name.", "Error", {
status: "danger",
}); });
}
}
} }
openOverviewOfIndicators(dialog: TemplateRef<any>) { openOverviewOfIndicators(dialog: TemplateRef<any>) {
...@@ -765,6 +666,13 @@ export class ResultsMapComponent implements OnChanges { ...@@ -765,6 +666,13 @@ export class ResultsMapComponent implements OnChanges {
entry[1]["response"] = undefined; entry[1]["response"] = undefined;
}); });
this.setMapZoomAndLoadGeojsons(); this.setLoadGeojsons();
}
setMapPositionAndZoom(res: Object) {
this.map.setView(
new L.LatLng(res["coordinates"]["lat"], res["coordinates"]["lon"]),
res["zoom"]
);
} }
} }
...@@ -81,4 +81,24 @@ export class NetworkService { ...@@ -81,4 +81,24 @@ export class NetworkService {
}) })
); );
} }
getMapInfo(): Observable<any> {
return this.httpClient.get(`${this.dssUrl}/map-info`).pipe(
map((res) => {
return res;
}),
tapDebugApi,
catchError(this.handleError)
);
}
getKpiVisInfo(): Observable<any> {
return this.httpClient.get(`${this.dssUrl}/kpi-vis-info`).pipe(
map((res) => {
return res;
}),
tapDebugApi,
catchError(this.handleError)
);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment