Skip to content

Commit

Permalink
feat(feature-info): display basic feature info in default template
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Nov 18, 2024
1 parent 921e184 commit d6e106f
Show file tree
Hide file tree
Showing 14 changed files with 927 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="/ogcproxywms"
VITE_PROXYURL_REMOTE="/httpsproxy"

# Urls for metadata, metadata links and legends
# Urls for metadata, metadata links, legends, feature info
VITE_GEONETWORK_URL="https://geocatalogue.geoportail.lu/geonetwork/srv"
VITE_GET_LEGENDS_URL="/legends/get_html"
VITE_GET_METADATA_URL="/getMetadata"
VITE_GET_INFO_SERVICE_URL="/getfeatureinfo"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="/mymaps"
Expand Down
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="https://migration.geoportail.lu/ogcproxywms"
VITE_PROXYURL_REMOTE="https://migration.geoportail.lu/httpsproxy"

# Urls for metadata, metadata links and legends
# Urls for metadata, metadata links, legends, feature info
VITE_GEONETWORK_URL="https://geocatalogue.geoportail.lu/geonetwork/srv"
VITE_GET_LEGENDS_URL="https://migration.geoportail.lu/legends/get_html"
VITE_GET_METADATA_URL="https://migration.geoportail.lu/getMetadata"
VITE_GET_INFO_SERVICE_URL="https://migration.geoportail.lu/getfeatureinfo"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="https://map.geoportail.lu/mymaps" # !!! use prod because of CORS
Expand Down
3 changes: 2 additions & 1 deletion .env.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="https://map.geoportail.lu/ogcproxywms"
VITE_PROXYURL_REMOTE="https://map.geoportail.lu/httpsproxy"

# Urls for metadata, metadata links and legends
# Urls for metadata, metadata links, legends, feature info
VITE_GEONETWORK_URL="https://geocatalogue.geoportail.lu/geonetwork/srv"
VITE_GET_LEGENDS_URL="https://migration.geoportail.lu/legends/get_html"
VITE_GET_METADATA_URL="https://migration.geoportail.lu/getMetadata"
VITE_GET_INFO_SERVICE_URL="https://migration.geoportail.lu/getfeatureinfo"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="https://map.geoportail.lu/mymaps" # !!! use prod because of CORS
Expand Down
3 changes: 2 additions & 1 deletion .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="https://migration.geoportail.lu/ogcproxywms"
VITE_PROXYURL_REMOTE="https://migration.geoportail.lu/httpsproxy"

# Urls for metadata, metadata links and legends
# Urls for metadata, metadata links, legends, feature info
VITE_GEONETWORK_URL="https://geocatalogue.geoportail.lu/geonetwork/srv"
VITE_GET_LEGENDS_URL="https://migration.geoportail.lu/legends/get_html"
VITE_GET_METADATA_URL="https://migration.geoportail.lu/getMetadata"
VITE_GET_INFO_SERVICE_URL="https://migration.geoportail.lu/getfeatureinfo"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="https://migration.geoportail.lu/mymaps"
Expand Down
31 changes: 31 additions & 0 deletions src/components/info/feature-info.composable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useAppStore } from '@/stores/app.store'
import useMap from '@/composables/map/map.composable'
import { listen } from 'ol/events'
import { FeatureInfoService } from './feature-info.service'
import { useFeatureInfoStore } from '@/stores/feature-info.store'
import { FeatureInfo } from './feature-info.model'
import { MapBrowserEvent } from 'ol'

export default function useFeatureInfo() {
const map = useMap().getOlMap()
const { toggleInfoOpen } = useAppStore()
const { setContent } = useFeatureInfoStore()

function init() {
const featureInfoService = new FeatureInfoService(map)

listen(map, 'pointerup', event => {
;(async () => {
const mapBrowserEvent = event as MapBrowserEvent<any>
const content: FeatureInfo[] | undefined =
await featureInfoService.singleclickEvent(mapBrowserEvent, false)
if (content) {
setContent(content)
toggleInfoOpen(true)
}
})()
})
}

return { init }
}
38 changes: 38 additions & 0 deletions src/components/info/feature-info.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Geometry } from 'ol/geom'

export interface Feature {
type: string
geometry: Geometry
fid: string
id: string
attributes: Attributes
alias: Record<string, unknown>
}

// interface Geometry {
// type: string
// coordinates: number[][][]
// }

export interface Attributes {
name: string
canton: string
district: string
showProfile: { active: boolean }
profile: any
label: string
[key: string]: any
value: string
}

export interface FeatureInfo {
features: Feature[]
remote_template: boolean
template: string
layer: string
ordered: boolean
has_profile: boolean
total_features_count: number
features_count: number
layerLabel: string
}
Loading

0 comments on commit d6e106f

Please sign in to comment.