Skip to content

BGDIINF_SB-2890: Get rid of some default projection and fixed a bug in the import tool #497

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

Merged
merged 6 commits into from
Oct 30, 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
13 changes: 6 additions & 7 deletions src/api/layers/AbstractLayer.class.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { WEBMERCATOR } from '@/utils/coordinates/coordinateSystems'
import LayerTypes from './LayerTypes.enum'

/** Name (or description) of a data holder for a layer, with the possibility to define a URL */
Expand Down Expand Up @@ -56,14 +55,14 @@ export default class AbstractLayer {

/**
* @abstract
* @param {String} timestamp A timestamp to be used, instead of the one define in the time
* config of the layer. Is used to preview a specific timestamp without having to change the
* layer's config (very useful for the time slider for instance)
* @param {Number} epsgNumber The EPSG number of the projection system to use (for instance,
* EPSG:2056 will require an input of 2056)
* @param {Number | null} epsgNumber The EPSG number of the projection system to use if needed
* for the layer
* @param {String | null} timestamp A timestamp to be used, instead of the one define in the
* time config of the layer. Is used to preview a specific timestamp without having to change
* the layer's config (very useful for the time slider for instance)
* @returns {String} The URL to use to request tile/image/data for this layer
*/
getURL(timestamp = null, epsgNumber = WEBMERCATOR.epsgNumber) {
getURL(epsgNumber = null, timestamp = null) {
throw new Error('You have to implement the method getURL!')
}

Expand Down
12 changes: 7 additions & 5 deletions src/api/layers/GeoAdminWMTSLayer.class.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import GeoAdminLayer from '@/api/layers/GeoAdminLayer.class'
import { CURRENT_YEAR_WMTS_TIMESTAMP } from '@/api/layers/LayerTimeConfigEntry.class'
import LayerTypes from '@/api/layers/LayerTypes.enum'
import { WEBMERCATOR } from '@/utils/coordinates/coordinateSystems'

/** Metadata for a tiled image layers (WMTS stands for Web Map Tile Service) */
export default class GeoAdminWMTSLayer extends GeoAdminLayer {
Expand Down Expand Up @@ -56,14 +55,17 @@ export default class GeoAdminWMTSLayer extends GeoAdminLayer {
}

/**
* @param {String} timestamp A timestamp to be used, instead of the one define in the time
* config of the layer. Is used to preview a specific timestamp without having to change the
* layer's config (very useful for the time slider for instance)
* @param {Number} epsgNumber The EPSG number of the projection system to use (for instance,
* EPSG:2056 will require an input of 2056)
* @param {String | null} timestamp A timestamp to be used, instead of the one define in the
* time config of the layer. Is used to preview a specific timestamp without having to change
* the layer's config (very useful for the time slider for instance)
* @returns {String} A XYZ type URL to request this WMTS layer's tiles
*/
getURL(timestamp = null, epsgNumber = WEBMERCATOR.epsgNumber) {
getURL(epsgNumber, timestamp = null) {
if (!epsgNumber) {
throw Error('epsgNumber is required')
}
let timestampToUse = timestamp
if (!timestampToUse || !this.timeConfig.hasTimestamp(timestampToUse)) {
// if no timestamp was given as param, or if the given timestamp is not part of the possible timestamps
Expand Down
4 changes: 2 additions & 2 deletions src/modules/map/components/cesium/CesiumWMTSLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default {
},
url() {
return this.wmtsLayerConfig.getURL(
this.timestampForPreviewYear,
this.projection.epsgNumber
this.projection.epsgNumber,
this.timestampForPreviewYear
)
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<script>
import ExternalWMTSLayer from '@/api/layers/ExternalWMTSLayer.class'
import { DEFAULT_PROJECTION } from '@/config'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import log from '@/utils/logging'
import WMTSCapabilities from 'ol/format/WMTSCapabilities'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</template>

<script>
import { DEFAULT_PROJECTION } from '@/config'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import allCoordinateSystems from '@/utils/coordinates/coordinateSystems'
import reprojectGeoJsonData from '@/utils/geoJsonUtils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@

<script>
import { SelectableFeature } from '@/api/features.api'
import { DEFAULT_PROJECTION } from '@/config'
import OpenLayersMarker, {
highlightedFill,
highlightedStroke,
highlightPointStyle,
markerStyles,
} from '@/modules/map/components/openlayers/OpenLayersMarker.vue'
import addLayerToMapMixin from '@/modules/map/components/openlayers/utils/addLayerToMap-mixins'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import OpenLayersFeature from 'ol/Feature'
import GeoJSON from 'ol/format/GeoJSON'
import VectorLayer from 'ol/layer/Vector'
import { Vector as VectorSource } from 'ol/source'
import Style from 'ol/style/Style'
import { mapState } from 'vuex'

const geoJsonStyleFunction = (olFeature) => {
const geoJsonType = olFeature.get('geometry').getType()
Expand Down Expand Up @@ -60,10 +59,6 @@ export default {
type: SelectableFeature,
required: true,
},
projection: {
type: CoordinateSystem,
required: true,
},
zIndex: {
type: Number,
default: -1,
Expand All @@ -76,6 +71,9 @@ export default {
}
},
computed: {
...mapState({
projection: (state) => state.position.projection,
}),
doesFeatureHaveAGeometry() {
return this.feature?.geometry
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
:z-index="zIndex"
/>
<div v-if="layerConfig.type === LayerTypes.GROUP">
<open-layers-internal-layer
<OpenLayersInternalLayer
v-for="(layer, index) in layerConfig.layers"
:key="`${layer.getID()}-${index}`"
:layer-config="layer"
Expand All @@ -68,7 +68,7 @@
v-for="aggregateSubLayer in layerConfig.subLayers"
:key="aggregateSubLayer.subLayerId"
>
<open-layers-internal-layer
<OpenLayersInternalLayer
v-if="shouldAggregateSubLayerBeVisible(aggregateSubLayer)"
:layer-config="aggregateSubLayer.layer"
:projection="projection"
Expand All @@ -91,15 +91,14 @@
<script>
import AbstractLayer from '@/api/layers/AbstractLayer.class'
import LayerTypes from '@/api/layers/LayerTypes.enum'
import { DEFAULT_PROJECTION } from '@/config'
import OpenLayersExternalWMTSLayer from '@/modules/map/components/openlayers/OpenLayersExternalWMTSLayer.vue'
import OpenLayersKMLLayer from '@/modules/map/components/openlayers/OpenLayersKMLLayer.vue'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import { LV95, WEBMERCATOR } from '@/utils/coordinates/coordinateSystems'
import OpenLayersGeoJSONLayer from './OpenLayersGeoJSONLayer.vue'
import OpenLayersVectorLayer from './OpenLayersVectorLayer.vue'
import OpenLayersWMSLayer from './OpenLayersWMSLayer.vue'
import OpenLayersWMTSLayer from './OpenLayersWMTSLayer.vue'
import { mapState } from 'vuex'

/**
* Transforms a layer config (metadata, structures can be found in api/layers/** files) into the
Expand Down Expand Up @@ -130,10 +129,6 @@ export default {
type: Number,
default: null,
},
projection: {
type: CoordinateSystem,
required: true,
},
zIndex: {
type: Number,
default: -1,
Expand All @@ -146,6 +141,11 @@ export default {
WEBMERCATOR,
}
},
computed: {
...mapState({
projection: (state) => state.position.projection,
}),
},
methods: {
shouldAggregateSubLayerBeVisible(subLayer) {
// min and max resolution are set in the API file to the lowest/highest possible value if undefined, so we don't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script>
import { getKmlFromUrl } from '@/api/files.api'
import { DEFAULT_PROJECTION, IS_TESTING_WITH_CYPRESS } from '@/config'
import { IS_TESTING_WITH_CYPRESS } from '@/config'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import log from '@/utils/logging'
import VectorLayer from 'ol/layer/Vector'
Expand Down
3 changes: 0 additions & 3 deletions src/modules/map/components/openlayers/OpenLayersMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<OpenLayersInternalLayer
v-if="currentBackgroundLayer"
:layer-config="currentBackgroundLayer"
:projection="mappingProjection"
:z-index="lightBaseMapConfigUnderMainBackgroundLayer ? 1 : 0"
/>
<!-- Adding all other layers -->
Expand All @@ -37,7 +36,6 @@
:layer-config="layer"
:preview-year="previewYear"
:current-map-resolution="resolution"
:projection="mappingProjection"
:z-index="zIndexForVisibleLayer(layer)"
/>
<!-- Adding pinned location -->
Expand Down Expand Up @@ -65,7 +63,6 @@
v-for="(feature, index) in selectedFeatures"
:key="feature.id"
:feature="feature"
:projection="mappingProjection"
:z-index="index + startingZIndexForHighlightedFeatures"
/>
<OpenLayersPopover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script>
import ExternalWMSLayer from '@/api/layers/ExternalWMSLayer.class'
import GeoAdminWMSLayer from '@/api/layers/GeoAdminWMSLayer.class'
import { DEFAULT_PROJECTION, WMS_TILE_SIZE } from '@/config'
import { WMS_TILE_SIZE } from '@/config'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import CustomCoordinateSystem from '@/utils/coordinates/CustomCoordinateSystem.class'
import { getTimestampFromConfig } from '@/utils/layerUtils'
Expand Down
5 changes: 2 additions & 3 deletions src/modules/map/components/openlayers/OpenLayersWMTSLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<script>
import GeoAdminWMTSLayer from '@/api/layers/GeoAdminWMTSLayer.class'
import { DEFAULT_PROJECTION } from '@/config'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import CustomCoordinateSystem from '@/utils/coordinates/CustomCoordinateSystem.class'
import { getTimestampFromConfig } from '@/utils/layerUtils'
Expand Down Expand Up @@ -48,8 +47,8 @@ export default {
},
url() {
return this.wmtsLayerConfig.getURL(
this.timestampForPreviewYear,
this.projection.epsgNumber
this.projection.epsgNumber,
this.timestampForPreviewYear
)
},
},
Expand Down
3 changes: 1 addition & 2 deletions src/store/plugins/click-on-map-management.plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { identify } from '@/api/features.api'
import LayerTypes from '@/api/layers/LayerTypes.enum'
import { ClickType } from '@/store/modules/map.store'
import { WEBMERCATOR } from '@/utils/coordinates/coordinateSystems'
import log from '@/utils/logging'

/**
Expand All @@ -13,7 +12,7 @@ import log from '@/utils/logging'
* @param {String} lang
* @param {CoordinateSystem} projection
*/
const runIdentify = async (store, clickInfo, visibleLayers, lang, projection = WEBMERCATOR) => {
const runIdentify = async (store, clickInfo, visibleLayers, lang, projection) => {
// we run identify only if there are visible layers (other than background)
if (visibleLayers.length > 0) {
const allRequests = []
Expand Down