Skip to content

Instantly share code, notes, and snippets.

@rastermanden
Created June 20, 2023 06:22
Show Gist options
  • Save rastermanden/48ac956e10564264565389776cf800fc to your computer and use it in GitHub Desktop.
Save rastermanden/48ac956e10564264565389776cf800fc to your computer and use it in GitHub Desktop.
/**
* @module
*/
import DetailsHandlerDef from '@septima/septima-search/details/DetailsHandlerDef.js'
import icons from "@septima/septima-search/resources/icons.js"
import DetailItemsList from "@septima/septima-search/details/DetailItemsList.js"
import { transform } from 'ol/proj.js'
import * as reproject from "@septima/septima-search/util/reproject.js"
import GeoJSON from 'ol/format/GeoJSON.js'
import { getCenter } from 'ol/extent.js'
import { getSize } from 'ol/extent.js'
class skraafotoForAdresse extends DetailsHandlerDef {
constructor(options) {
super({
buttonText: options.header,
buttonImage: icons.details.moreHeader,
more: true
})
this.isApplicableFunction = this.isApplicable
this.handlerFunction = this.myhandler
}
isApplicable(result) {
return ((result.typeId === "adresse") || (result.source === "Kortforsyningen" && result.typeId === "matrikelnumre") || (result.typeId === "stednavne") || (result.typeId === "bbr_bygning"))
}
async myhandler(result) {
let geometry = result.geometry
if (typeof result.data.geometry !== 'undefined') {
geometry = result.data.geometry
}
let resgeom = new GeoJSON()
let g = resgeom.readGeometry(result.geometry, { dataProjection: 'epsg:25832' })
let extent = g.getExtent()
let center = getCenter(extent)
let reprojectGeometry = reproject.reproject(result.geometry, "EPSG:25832", "EPSG:4326")
var detailItems = []
let detailItemsList = new DetailItemsList({})
const coordinates = center;
const x = `${coordinates[0]}`
const y = `${coordinates[1]}`
console.log(reprojectGeometry)
const lon = `${reprojectGeometry.coordinates[0]}`
const lat = `${reprojectGeometry.coordinates[1]}`
const u = "Furesoe_Kommune_WMS"
const p = "28DF6FE9"
const project = "DDG+Furesø+Kommune"
const title = "Se skråfoto fra COWI (2018)"
const url_append = "username[]=aje1&username[]=fur1ksw1&username[]=fwc1&panos=true&dateFrom=2018-01-01&z=18&mapStyle=mapillary_streets"
detailItemsList.append({
type: 'link',
link: `https://www.mapillary.com/app/?lat=${lat}&lng=${lon}&z=20&${url_append}`,
linkTitle: `Se gadefoto fra Mapillary`,
})
detailItemsList.append({
type: 'link',
link: `http://www5.kb.dk/danmarksetfraluften/#zoom=18&lat=${lat}&lng=${lon}`,
linkTitle: `Se "Furesø set fra luften" (historiske flyfotos)`,
})
detailItemsList.append({
type: 'link',
icon: icons.details.link,
link: `https://mv.services.hxgncontent.com/?&u=${u}&p=${p}&origin=desktop&project=${project}&x=${x}&y=${y}&srid=25832&maximize=DDS2018+Furesø+Kommune&assLayers=DDS2018+Furesø+Kommune&dssLayers=SDFE2017+Furesø+Kommune&hLayers=SDFE2017+Furesø+Kommune;DDS2018+Furesø+Kommune&ssTrigger=SINGLE_CLICK`,
linkTitle: `${title}`,
})
detailItems.push(detailItemsList.asItem())
return detailItems
}
}
export default skraafotoForAdresse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment