import { LatLng } from 'leaflet'

import { OsmAddressResponse } from './types'

const initialOsmAddress = ''

const composeOsmAddressURL = (addressPosition: LatLng) => (
    `${location.protocol}//nominatim.openstreetmap.org/reverse?format=json&accept-language=ru&lat=${addressPosition.lat}&lon=${addressPosition.lng}`
)

const processOsmAddress = (data: OsmAddressResponse): string => (
    data.display_name
)

export { initialOsmAddress, composeOsmAddressURL, processOsmAddress }
