Skip to content

Commit

Permalink
Merge pull request #919 from geoadmin/bug-PB-546-print-scale
Browse files Browse the repository at this point in the history
PB-546: Improved default print scale computed from map size
  • Loading branch information
ltshb authored Jun 17, 2024
2 parents eee65b7 + b28b6a9 commit 0268423
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export default function usePrintAreaRenderer(map) {
const selectedScale = computed(() => store.state.print.selectedScale)
// For simplicity we use the screen size for the map size
const mapWidth = computed(() => store.state.ui.width)
// Same here for simplicity we take the screen size minus the header size for the map size
const mapHeight = computed(() => store.state.ui.height - store.state.ui.headerHeight)
// Same here for simplicity we take the screen size minus the header size for the map size (map
// is under the header). We take the header size twice as the overlay is then centered on the
// whole map (not only the part below the header)
const mapHeight = computed(() => store.state.ui.height - store.state.ui.headerHeight * 2)

watch(isActive, (newValue) => {
if (newValue) {
Expand Down Expand Up @@ -168,6 +170,6 @@ export default function usePrintAreaRenderer(map) {
selectedLayoutScales
)
// Find the first scale that is smaller than the testScale in descending order
return selectedLayoutScales.find((scale) => scale < testScale) ?? selectedLayoutScales[0]
return selectedLayoutScales.find((scale) => scale <= testScale) ?? selectedLayoutScales[0]
}
}
12 changes: 6 additions & 6 deletions tests/cypress/tests-e2e/print.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Testing print', () => {
cy.get('[data-cy="print-scale-selector"]').find('option').should('have.length', 15)
cy.get('[data-cy="print-scale-selector"]')
.find('option:selected')
.should('have.text', `1:${formatThousand(2500000)}`)
.should('have.text', `1:${formatThousand(1500000)}`)
})
})

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Testing print', () => {
)

const mapAttributes = attributes.map
expect(mapAttributes['scale']).to.equals(2500000)
expect(mapAttributes['scale']).to.equals(1500000)
expect(mapAttributes['dpi']).to.equals(254)
expect(mapAttributes['projection']).to.equals('EPSG:2056')

Expand Down Expand Up @@ -271,7 +271,7 @@ describe('Testing print', () => {
)

const mapAttributes = attributes.map
expect(mapAttributes['scale']).to.equals(2500000)
expect(mapAttributes['scale']).to.equals(1500000)
expect(mapAttributes['dpi']).to.equals(254)
expect(mapAttributes['projection']).to.equals('EPSG:2056')

Expand Down Expand Up @@ -312,7 +312,7 @@ describe('Testing print', () => {
)

const mapAttributes = attributes.map
expect(mapAttributes['scale']).to.equals(10000)
expect(mapAttributes['scale']).to.equals(5000)
expect(mapAttributes['dpi']).to.equals(254)
expect(mapAttributes['projection']).to.equals('EPSG:2056')

Expand Down Expand Up @@ -444,7 +444,7 @@ describe('Testing print', () => {
)

const mapAttributes = attributes.map
expect(mapAttributes['scale']).to.equals(10000)
expect(mapAttributes['scale']).to.equals(5000)
expect(mapAttributes['dpi']).to.equals(254)
expect(mapAttributes['projection']).to.equals('EPSG:2056')

Expand Down Expand Up @@ -515,7 +515,7 @@ describe('Testing print', () => {
)

const mapAttributes = attributes.map
expect(mapAttributes['scale']).to.equals(10000)
expect(mapAttributes['scale']).to.equals(5000)
expect(mapAttributes['dpi']).to.equals(254)
expect(mapAttributes['projection']).to.equals('EPSG:2056')

Expand Down

0 comments on commit 0268423

Please sign in to comment.