Skip to content

Commit

Permalink
Ajout du widget ElevationPath (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
IGNFhc authored Oct 22, 2024
1 parent 1d5eb02 commit 7938a17
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ declare module 'vue' {
DsfrSideMenu: typeof import('@gouvminint/vue-dsfr')['DsfrSideMenu']
DsfrTabContent: typeof import('@gouvminint/vue-dsfr')['DsfrTabContent']
DsfrTabs: typeof import('@gouvminint/vue-dsfr')['DsfrTabs']
ElevationPath: typeof import('./components/carte/control/ElevationPath.vue')['default']
FullScreen: typeof import('./components/carte/control/FullScreen.vue')['default']
GetFeatureInfo: typeof import('./components/carte/control/GetFeatureInfo.vue')['default']
Isocurve: typeof import('./components/carte/control/Isocurve.vue')['default']
Expand Down
18 changes: 14 additions & 4 deletions src/components/carte/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import MeasureLength from './control/MeasureLength.vue'
import MeasureArea from './control/MeasureArea.vue'
import MeasureAzimuth from './control/MeasureAzimuth.vue'
import MousePosition from './control/MousePosition.vue'
import ElevationPath from './control/ElevationPath.vue'
import Territories from './control/Territories.vue';
import GetFeatureInfo from './control/GetFeatureInfo.vue'
import LayerImport from './control/LayerImport.vue'
Expand Down Expand Up @@ -152,6 +153,9 @@ const measureAreaOptions = {
const measureAzimuthOptions = {
position: 'top-left'
}
const elevationPathOptions = {
position: 'bottom-left'
}
const layerImportOptions = {
position: 'bottom-left'
Expand Down Expand Up @@ -408,11 +412,17 @@ const mousePositionOptions = {
:analytic="useControls.MousePosition.analytic"
:mouse-position-options="mousePositionOptions"
/>
<ElevationPath
v-if="controlOptions"
:visibility="props.controlOptions.includes(useControls.ElevationPath.id)"
:analytic="useControls.ElevationPath.analytic"
:elevation-path-options="elevationPathOptions"
/>
<LayerImport
v-if="controlOptions"
:visibility="props.controlOptions.includes(useControls.LayerImport.id)"
:analytic="useControls.LayerImport.analytic"
:layer-import-options="layerImportOptions"
v-if="controlOptions"
:visibility="props.controlOptions.includes(useControls.LayerImport.id)"
:analytic="useControls.LayerImport.analytic"
:layer-import-options="layerImportOptions"
/>
</template>

Expand Down
72 changes: 72 additions & 0 deletions src/components/carte/control/ElevationPath.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup lang="js">
import { useActionButtonEulerian } from '@/composables/actionEulerian.js';
import { useLogger } from 'vue-logger-plugin'
import {
ElevationPath
} from 'geopf-extensions-openlayers'
const props = defineProps({
visibility: Boolean,
analytic: Boolean,
elevationPathOptions: Object
})
const log = useLogger()
const map = inject('map')
const elevationPath = ref(new ElevationPath(props.elevationPathOptions))
onMounted(() => {
if (props.visibility) {
map.addControl(elevationPath.value);
/* abonnement au widget
* @fires elevationpath:drawstart
* @fires elevationpath:drawend
* @fires elevationpath:compute
*/
elevationPath.value.on("elevationpath:drawstart", onDrawStart);
elevationPath.value.on("elevationpath:drawend", onDrawEnd);
elevationPath.value.on("elevationpath:compute", onCompute);
if (props.analytic) {
var el = elevationPath.value.element.querySelector("button[id^=GPshowElevationPathPicto-]");
useActionButtonEulerian(el);
}
}
})
onBeforeUpdate(() => {
if (!props.visibility) {
map.removeControl(elevationPath.value);
}
})
onUpdated(() => {
if (props.visibility) {
map.addControl(elevationPath.value);
if (props.analytic) {
var el = elevationPath.value.element.querySelector("button[id^=GPshowElevationPathPicto-]");
useActionButtonEulerian(el);
}
}
})
/**
* gestionnaire d'evenement sur les abonnements
*/
const onDrawStart = (e) => {
log.debug(e);
}
const onDrawEnd = (e) => {
log.debug(e);
}
const onCompute = (e) => {
log.debug(e);
}
</script>

<template>
<!-- TODO ajouter l'emprise du widget pour la gestion des collisions -->
</template>

<style scoped></style>
2 changes: 1 addition & 1 deletion src/components/carte/control/Share.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ onBeforeMount(() => {
<DsfrInput
v-model="iframe"
placeholder=""
isTextarea="true"
isTextarea
label-visible
readonly
descriptionId=""
Expand Down
1 change: 1 addition & 0 deletions src/components/menu/LeftMenuTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function tabIsActive(componentName) {
<MenuLateralWrapper
:side="side"
:visibility="true"
id="MenuCatalogueContentClose"
v-model="is_expanded"
ref="wrapper">
<template #content>
Expand Down
13 changes: 7 additions & 6 deletions src/components/menu/MenuLateralNavButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ const tabClicked = () => {


<template>
<DsfrButton :id="id"
secondary
:class="`${active ? 'active': ''} 'navBarIcon'` && 'navButton'"
:icon="icon"
:iconOnly="true"
@click="tabClicked">
<DsfrButton
:id="id"
secondary
:class="`${active ? 'active': ''} 'navBarIcon'` && 'navButton'"
:icon="icon"
:iconOnly="true"
@click="tabClicked">
</DsfrButton>
</template>

Expand Down
9 changes: 5 additions & 4 deletions src/components/menu/MenuLateralWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { OhVueIcon as VIcon } from 'oh-vue-icons'
const props = defineProps({
side: String,
visibility: Boolean
visibility: Boolean,
id: String
})
const icon = "io-close"
Expand Down Expand Up @@ -60,14 +61,14 @@ defineExpose({
<div class="menu-content-list"
v-show="is_expanded">
<div class="menu-collapse-icon-wrapper">
<DsfrButton :id="id"
<DsfrButton
:id="props.id"
tertiary
no-outline
class="menu-collapse-icon"
@click="closeMenu">
Fermer
<VIcon
v-bind="iconProps"/>
<VIcon v-bind="iconProps"/>
</DsfrButton>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/components/menu/RightMenuTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function tabIsActive(componentName) {
<MenuLateralWrapper
:side="side"
:visibility="true"
id="MenuControlContentClose"
v-model="is_expanded"
ref="wrapper">
<template #content>
Expand Down
13 changes: 13 additions & 0 deletions src/composables/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ export const useControls = {
disable: false,
analytic: true
},
ElevationPath: {
id: 'ElevationPath',
active: true,
disable: false,
analytic: false
},
LayerImport: {
id: 'LayerImport',
active: true,
Expand Down Expand Up @@ -288,6 +294,13 @@ export function useControlsMenuOptions() {
hint: 'Territoires',
disabled: useControls.Territories.disable
},
{
label: 'Profil altimétrique',
id: 'elevationPath',
name: useControls.ElevationPath.id,
hint: 'Profil altimétrique',
disabled: useControls.ElevationPath.disable
},
{
label: 'Importer des données',
id: 'layerImport',
Expand Down

0 comments on commit 7938a17

Please sign in to comment.