Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]: Fixed some bugs in the client #2193

Merged
merged 2 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/client/src/components/indicators/Indicators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ export default {
EventBus.$on("updateStyleDialogStatusForLayerOrder", value => {
this.styleDialogStatus = value;
});

this.updateLayerMaxResolution();
},
computed: {
...mapGetters("app", {
Expand All @@ -222,7 +224,8 @@ export default {
unCalculatedDataUploadIds: "unCalculatedDataUploadIds"
}),
...mapGetters("poisaois", {
selectedPoisOnlyKeys: "selectedPoisOnlyKeys"
selectedPoisOnlyKeys: "selectedPoisOnlyKeys",
selectedAoisOnlyKeys: "selectedAoisOnlyKeys"
}),
...mapGetters("scenarios", {
activeScenario: "activeScenario"
Expand Down Expand Up @@ -314,7 +317,7 @@ export default {
this.indicatorCancelToken = null;
}
layer.getSource().refresh();
this.checkIfIndicatorNeedsPois(layer);
this.checkIfIndicatorNeedsPoisAois(layer);
layer.set("showOptions", true);
}
if (
Expand All @@ -335,7 +338,7 @@ export default {
}
indicatorLayers.forEach(layer => {
if (layer.getVisible()) {
this.checkIfIndicatorNeedsPois(layer);
this.checkIfIndicatorNeedsPoisAois(layer);
if (this.indicatorCancelToken instanceof Function) {
this.indicatorCancelToken("cancelled");
this.indicatorCancelToken = null;
Expand All @@ -354,7 +357,7 @@ export default {
this.updateIndicators[group].forEach(indicatorName => {
this.indicatorLayers.forEach(layer => {
if (layer.get("name") === indicatorName && layer.getVisible()) {
this.checkIfIndicatorNeedsPois(layer);
this.checkIfIndicatorNeedsPoisAois(layer);
if (this.indicatorCancelToken instanceof Function) {
this.indicatorCancelToken("cancelled");
this.indicatorCancelToken = null;
Expand Down Expand Up @@ -398,10 +401,11 @@ export default {
this.isRecomputingIndicator = false;
});
},
checkIfIndicatorNeedsPois(layer) {
checkIfIndicatorNeedsPoisAois(layer) {
this.toggleSnackbar({ state: false });
if (
this.selectedPoisOnlyKeys.length === 0 &&
this.selectedAoisOnlyKeys.length === 0 &&
this.indicatorsWithAmenities.includes(layer.get("name"))
) {
this.toggleSnackbar({
Expand Down
53 changes: 53 additions & 0 deletions app/client/src/components/layers/layerTree/LayerTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ import { EventBus } from "../../../EventBus";
import InLegend from "../../viewer/ol/controls/InLegend";
import LayerOrder from "../layerOrder/LayerOrder";
import StyleDialog from "../../styling/StyleDialog";
// import { Style, Fill } from "ol/style";
import { Feature } from "ol";
import Legend from "../../viewer/ol/controls/Legend";
import ImportExternalLayers from "../importLayers/ImportExternalLayers.vue";

Expand Down Expand Up @@ -487,7 +489,58 @@ export default {
}
this.currentItem = item;
},
opacityToHex(opacity, hexpart) {
// Convert the opacity to a 8-bit integer between 0 and 255
const alpha = Math.round(opacity * 255);
// Convert the alpha value to a hex string
const hex = alpha.toString(16).padStart(2, "0");
// Return the hex string with an alpha channel
return `#${hexpart}${hex}`;
},
setFillOpacity(style, opacity) {
// Get the fill style from the style
// style[0].getImage().setOpacity(opacity);
style[0].setFill("#000000");
// console.log(
// style[0],
//
// );
style[0]
.getImage()
.getFill()
.setColor(
this.opacityToHex(
opacity,
style[0]
.getImage()
.getFill()
.getColor()
.slice(1)
)
);
console.log(style[0]);
// if (fill instanceof Fill) {
// // Get the color of the fill style and split it into RGBA components
// const color = fill.getColor();
// // eslint-disable-next-line
// const [r, g, b, a] = color;
// // Set the new opacity value
// const newColor = [r, g, b, opacity];
// // Update the fill color with the new opacity value
// fill.setColor(newColor);
// }
return style[0];
},
changeLayerOpacity(value, layer) {
if (layer.get("type") == "MVT") {
const layerStyleFn = layer.getStyle();
const feature = new Feature();
const resolution = 10;
const layerStyle = layerStyleFn(feature, resolution);

let new_style = this.setFillOpacity(layerStyle, value);
layer.setStyle(new_style);
}
layer.setOpacity(value);
},
// Importing built in layers from a local js file
Expand Down
56 changes: 40 additions & 16 deletions app/client/src/components/viewer/ol/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,28 @@
'trip_cnt'
)"
:key="idx"
style="display: flex; align-items: center; margin: 5px 0;"
>
<div
v-if="transitRouteTypesByNr[routeType].color"
:style="
`width:45px;height:23px;margin-right: 20px;background-color: ${transitRouteTypesByNr[routeType].color};`
"
></div>
<p style="margin: 0">
{{
$t(
`indicators.ptRouteTypes.${transitRouteTypesByNr[routeType].name}`
)
}}:
{{
tripCnt && timeDelta > 0 ? Math.round(tripCnt / timeDelta) : 0
}}
</p>
v-if="routeType in transitRouteTypesByNr"
style="display: flex; align-items: center; margin: 5px 0;"
>
<div
v-if="transitRouteTypesByNr[routeType].color"
:style="
`width:45px;height:23px;margin-right: 20px;background-color: ${transitRouteTypesByNr[routeType].color};`
"
></div>
<p style="margin: 0">
{{
$t(
`indicators.ptRouteTypes.${transitRouteTypesByNr[routeType].name}`
)
}}:
{{
tripCnt && timeDelta > 0 ? Math.round(tripCnt / timeDelta) : 0
}}
</p>
</div>
</div>
</template>
<!-- INDICATOR: ÖV-Güteklassen -->
Expand Down Expand Up @@ -410,6 +414,15 @@ export default {
me.createWmsWmtsPopup();
EventBus.$on("toggleLayerVisiblity", this.showNonVisibleLayersInfo);
}, 200);

// this.updateMapZoomLevel()

//event to check for page zoom level changes
// window
// .matchMedia("(resolution: 1dppx)")
// .addListener(this.updateMapZoomLevel);

// this.updateMapZoomLevel(window.matchMedia("(resolution: 1dppx)"));
},
created() {
var me = this;
Expand Down Expand Up @@ -672,6 +685,17 @@ export default {
}
},

/**
* Change view level of map based in the page zoom level
*/
// updateMapZoomLevel(e) {
// const pageZoomLevel = e.matches ? 100 : 200; // calculate the page zoom level based on the devicePixelRatio
// console.log(e.matches);
// this.mapZoomLevel = this.map
// .getView()
// .setZoom(this.map.getView().getZoom() / (pageZoomLevel / 100)); // calculate the new map zoom level
// },

/**
* Show popup for the get info module.
*/
Expand Down
5 changes: 1 addition & 4 deletions app/client/src/store/modules/isochrones.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ const getters = {
r => r.type === "transit"
);
if (routing.length > 0) {
const transitModes = [
...routing[0].transit_modes,
...state.transitRouteTypeExtensions
];
const transitModes = [...routing[0].transit_modes];
transitModes.forEach(t => {
const typeNr = state.transitRouteTypes[t.type];
obj[typeNr] = {
Expand Down