Skip to content

Commit

Permalink
Merge pull request #175 from Geoportail-Luxembourg/GSLUX-755-location…
Browse files Browse the repository at this point in the history
…_info

Gslux 755 location info
  • Loading branch information
mki-c2c authored Dec 17, 2024
2 parents 19aa9fa + ce754fa commit aea4b4b
Show file tree
Hide file tree
Showing 59 changed files with 1,630 additions and 26 deletions.
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_V3_API_HOST="https://map.geoportail.lu/"

# Proxy urls
VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="/ogcproxywms"
Expand All @@ -9,6 +11,15 @@ VITE_GET_LEGENDS_URL="/legends/get_html"
VITE_GET_METADATA_URL="/getMetadata"
VITE_GET_INFO_SERVICE_URL="/getfeatureinfo"

# Urls for location info
VITE_FORAGE_URL="/getRapportForageVirtuel"
VITE_LIDAR_URL="https://lidar.geoportail.lu"
VITE_CYCLOMEDIA_URL="http://streetsmart.cyclomedia.com/streetsmart"
VITE_OBLIQUE_URL="https://oblique.geoportail.lu/publication/viewer"
VITE_SHORT_URL="/short/create"
VITE_QR_URL="/qr"
VITE_ADDRESS_URL="/geocode/reverse"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="/mymaps"
VITE_SYMBOLS_URL="/mymaps/symbols"
Expand Down
11 changes: 11 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_V3_API_HOST="http://localhost:8080/"

# Proxy urls
VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="https://migration.geoportail.lu/ogcproxywms"
Expand All @@ -9,6 +11,15 @@ 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"

# Urls for location info
VITE_FORAGE_URL="http://localhost:8080/getRapportForageVirtuel"
VITE_LIDAR_URL="https://lidar.geoportail.lu"
VITE_CYCLOMEDIA_URL="http://streetsmart.cyclomedia.com/streetsmart"
VITE_OBLIQUE_URL="https://oblique.geoportail.lu/publication/viewer"
VITE_SHORT_URL="http://localhost:8080/short/create"
VITE_QR_URL="http://localhost:8080/qr"
VITE_ADDRESS_URL="http://localhost:8080/geocode/reverse"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="https://map.geoportail.lu/mymaps" # !!! use prod because of CORS
VITE_SYMBOLS_URL="https://map.geoportail.lu/mymaps/symbols" # !!! use prod because of CORS
Expand Down
11 changes: 11 additions & 0 deletions .env.e2e
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_V3_API_HOST="https://migration.geoportail.lu/"

# Proxy urls
VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="https://map.geoportail.lu/ogcproxywms"
Expand All @@ -9,6 +11,15 @@ 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"

# Urls for location info
VITE_FORAGE_URL="https://migration.geoportail.lu/getRapportForageVirtuel"
VITE_LIDAR_URL="https://lidar.geoportail.lu"
VITE_CYCLOMEDIA_URL="http://streetsmart.cyclomedia.com/streetsmart"
VITE_OBLIQUE_URL="https://oblique.geoportail.lu/publication/viewer"
VITE_SHORT_URL="https://migration.geoportail.lu/short/create"
VITE_QR_URL="https://migration.geoportail.lu/qr"
VITE_ADDRESS_URL="https://migration.geoportail.lu/geocode/reverse"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="https://map.geoportail.lu/mymaps" # !!! use prod because of CORS
VITE_SYMBOLS_URL="https://map.geoportail.lu/mymaps/symbols" # !!! use prod because of CORS
Expand Down
11 changes: 11 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_V3_API_HOST="https://migration.geoportail.lu/"

# Proxy urls
VITE_USE_PROXYURL=true
VITE_PROXYURL_WMS="https://migration.geoportail.lu/ogcproxywms"
Expand All @@ -9,6 +11,15 @@ 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"

# Urls for location info
VITE_FORAGE_URL="/getRapportForageVirtuel"
VITE_LIDAR_URL="https://lidar.geoportail.lu"
VITE_CYCLOMEDIA_URL="http://streetsmart.cyclomedia.com/streetsmart"
VITE_OBLIQUE_URL="https://oblique.geoportail.lu/publication/viewer"
VITE_SHORT_URL="https://migration.geoportail.lu/short/create"
VITE_QR_URL="https://migration.geoportail.lu/qr"
VITE_ADDRESS_URL="https://migration.geoportail.lu/geocode/reverse"

# Paths for symbols
VITE_SYMBOL_ICONS_URL="https://migration.geoportail.lu/mymaps"
VITE_SYMBOLS_URL="https://migration.geoportail.lu/mymaps/symbols"
Expand Down
35 changes: 32 additions & 3 deletions cypress/e2e/draw/draw-feat-line.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ function testFeatItemMeasurements() {

describe('Draw "Line"', () => {
beforeEach(() => {
cy.intercept(
{
method: 'POST',
pathname: '/profile.json',
},
req =>
new Promise(r => {
const resp = new Response(req.body, {
headers: { 'content-type': 'application/x-www-form-urlencoded' },
})
resp.formData().then(formData => {
const geom = formData.get('geom')
const coordinates = JSON.parse(geom as string).coordinates
if (coordinates[0][0] > 40000) {
r(req.body)
} else {
r({
fixture: 'profile.json',
})
}
})
})
).as('profile-fixture')
cy.visit('/')
cy.get('button[data-cy="drawButton"]').click()
cy.get('button[data-cy="drawLineButton"]').click()
Expand All @@ -26,10 +49,12 @@ describe('Draw "Line"', () => {
})

it('displays measurements for Line', () => {
cy.wait('@profile-fixture')
testFeatItemMeasurements()
})

it('displays the elevation profile for Line', () => {
cy.wait('@profile-fixture')
cy.get('[data-cy="featItemProfileCumul"]').should(
'contain.text',
'Δ+964 m Δ-1105 m Δ-141 m'
Expand All @@ -50,11 +75,9 @@ describe('Draw "Line"', () => {
})

describe('When editing the line', () => {
beforeEach(() => {
cy.intercept('POST', '/profile.json', { fixture: 'profile.json' })
})
it('refreshes the elevation profile for Line', () => {
cy.dragVertexOnMap(320, 223, 305, 305)
cy.wait('@profile-fixture')
cy.get('[data-cy="featItemProfileCumul"]').should($el => {
const text = $el.text()
const validValues = [
Expand All @@ -72,6 +95,7 @@ describe('Draw "Line"', () => {
})

it('downloads the profile elevation', () => {
cy.wait('@profile-fixture')
cy.get('[data-cy="featItemProfileCSV"]').click()

const downloadPath = 'cypress/downloads/Ligne_1.csv'
Expand All @@ -86,25 +110,30 @@ describe('Draw "Line"', () => {
})

it('updates length measurement when editing geometry', () => {
cy.wait('@profile-fixture')
cy.get('[data-cy="featItemLength"]').should('contain.text', '42.31 km')
cy.dragVertexOnMap(320, 223, 305, 305)
cy.wait('@profile-fixture')
cy.get('[data-cy="featItemLength"]').should('contain.text', '33.26 km')
})

it('displays the possible actions for the feature', () => {
cy.wait('@profile-fixture')
testFeatItem()
})
})

describe('When clicking button dock', () => {
it('displays the feature info in the map popup', () => {
testFeatItemDocking()
cy.wait('@profile-fixture')
testFeatItemMeasurements()
})
})

describe('When clicking button dropdown menu', () => {
it('displays the dropdown menu content for "Line"', () => {
cy.wait('@profile-fixture')
cy.get('[data-cy="featMenuPopup"] > button').should('exist')
cy.get('[data-cy="featMenuPopup"] > button').click()

Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/footer-bar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Footer bar', () => {
cy.get('[data-cy="infoOpenClose"]').find('button').click()
cy.get('[data-cy="infoPanel"]').should('exist')
cy.get('button[data-cy="drawButton"]').click()
cy.get('[data-cy="infoPanel"]').should('not.exist')
cy.get('[data-cy="infoPanel"]').should('be.hidden')
})
})

Expand Down Expand Up @@ -72,7 +72,7 @@ describe('Footer bar', () => {
it('Other panels are closed', () => {
cy.get('[data-cy="styleSelector"]').should('not.exist')
cy.get('[data-cy="layerPanel"]').should('not.exist')
cy.get('[data-cy="infoPanel"]').should('not.exist')
cy.get('[data-cy="infoPanel"]').should('be.hidden')
})

describe('When clicking on layers panel button', () => {
Expand All @@ -94,7 +94,7 @@ describe('Footer bar', () => {
})

it('Info panel is shown', () => {
cy.get('[data-cy="infoPanel"]').should('exist')
cy.get('[data-cy="infoPanel"]').should('be.visible')
})

it('Other panels are closed', () => {
Expand All @@ -108,7 +108,7 @@ describe('Footer bar', () => {
})

it('closes the info panel', () => {
cy.get('[data-cy="infoPanel"]').should('not.exist')
cy.get('[data-cy="infoPanel"]').should('be.hidden')
})
})
})
Expand Down
163 changes: 163 additions & 0 deletions cypress/e2e/info/location-info.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
describe('Location Info', () => {
beforeEach(() => {
cy.intercept('POST', 'short/create', {
statusCode: 200,
body: { short_url: 'http://localhost:8080/s/uSxF' },
}).as('shortUrl')

cy.intercept(
{
method: 'GET',
pathname: '/geocode/reverse',
},
req => {
const dist = Math.sqrt(
(parseFloat(req.query.easting.toString()) - 67887) ** 2 +
(parseFloat(req.query.northing.toString()) - 85410) ** 2
)
const categorizedDist =
dist > 5 ? (dist > 100 ? 1972.1284 : 394.2305) : 20.98493
req.reply({
statusCode: 200,
body: {
count: 1,
results: [
{
id_caclr_locality: '37',
id_caclr_street: '1147',
id_caclr_bat: '213956',
street: 'Bergstr',
number: '18',
locality: 'Roodt/Eisch/Test',
commune: 'Habscht',
postal_code: '8398',
country: 'Luxembourg',
country_code: 'lu',
distance: categorizedDist,
contributor: 'ACT',
geom: {
type: 'Point',
coordinates: [req.query.easting, req.query.northing],
},
geomlonlat: {
type: 'Point',
coordinates: [6.00041535, 49.697110053],
},
},
],
},
})
}
)
})

describe('Open location info on position', () => {
describe('Display basic feature info for multiple layers', () => {
beforeEach(() => {
cy.visit('/?zoom=8')
})
it('should display coordinate and address information in the panel', () => {
cy.get('[data-cy="locationInfo"]').should('be.hidden')
cy.url().should('not.contain', 'crosshair=')
cy.window()
.its('olMap')
.then(function (olMap) {
const featureLayers = olMap
.getLayers()
.getArray()
.filter((l: any) => l.get('cyLayerType') === 'infoFeatureLayer')
const features = featureLayers
.map((l: any) => l.getSource().getFeatures())
.flat()
cy.wrap(features.length).should('equal', 0)
})

cy.get('div.ol-viewport').rightclick(350, 300, { force: true })
cy.get('[data-cy="locationInfo"]').should('be.visible')
cy.get('[data-cy="locationInfo"]').find('input').should('exist')
cy.get('[data-cy="locationInfo"]')
.find('input')
.invoke('val')
.should('contain', 'localhost:8080/s')
// 8 location infos (5 projections, elevation, address, distance)
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr').should(
'have.length',
8
)
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr')
.eq(6)
.find('td')
.should('contain.text', 'Roodt/Eisch/Test')
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr')
.eq(7)
.find('td')
.should('contain.text', '1.97 km')
// check pointer
cy.window()
.its('olMap')
.then(function (olMap) {
const featureLayers = olMap
.getLayers()
.getArray()
.filter((l: any) => l.get('cyLayerType') === 'infoFeatureLayer')
const features = featureLayers
.map((l: any) => l.getSource().getFeatures())
.flat()
cy.wrap(features.length).should('equal', 1)
})

cy.url().should('contain', 'crosshair=true')
})

it('streetview should integrate smoothly in the panel', () => {
cy.get('div.ol-viewport').rightclick(350, 300, { force: true })
cy.get('[data-cy="streetviewOff"]').should('not.exist')
cy.get('[data-cy="streetviewOn"]').click()
cy.get('[data-cy="streetviewOff"]').should('exist')
cy.get('[data-cy="streetviewNoData"]').should('be.visible')
cy.get('[data-cy="streetviewNoData"]')
.find('span')
.should(
'contain.text',
"Il n'y a pas de panorama Google disponible à cet endroit"
)
cy.window()
.its('olMap')
.then(function (olMap) {
const featureLayers = olMap
.getLayers()
.getArray()
.filter((l: any) => l.get('cyLayerType') === 'svFeatureLayer')
const features = featureLayers
.map((l: any) => l.getSource().getFeatures())
.flat()
cy.wrap(features.length).should('equal', 0)
})
cy.get('div.ol-viewport').rightclick(350, 50, { force: true })
cy.get('[data-cy="streetviewNoData"]').should('not.be.visible')
cy.get('[data-cy="streetviewLoading"]').should('not.be.visible')
cy.window()
.its('olMap')
.should(function (olMap) {
const featureLayers = olMap
.getLayers()
.getArray()
.filter((l: any) => l.get('cyLayerType') === 'svFeatureLayer')
const features = featureLayers
.map((l: any) => l.getSource().getFeatures())
.flat()
expect(features.length).to.equal(3)
})
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr')
.last()
.find('td')
.should('contain.text', '20.98 m')
cy.get('div.ol-viewport').click(382, 82, { force: true })
cy.get('[data-cy="locationInfo"] > div > table > tbody > tr')
.last()
.find('td')
.should(el => expect(el).to.contain.text('394.23 m'))
})
})
})
})
Loading

0 comments on commit aea4b4b

Please sign in to comment.