Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions plugins/draw/src/adapters/openlayers/snap/snapEngine.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import VectorLayer from 'ol/layer/Vector.js'
import VectorTileLayer from 'ol/layer/VectorTile.js'
import VectorSource from 'ol/source/Vector.js'
import { Projection, addProjection, addCoordinateTransforms } from 'ol/proj.js'
import { createSnapEngine } from './snapEngine.js'
import { polygonFeature } from '../__helpers__/harness.js'

Expand Down Expand Up @@ -177,6 +178,22 @@ describe('vector-tile layers', () => {
map.layers.unshift(new VectorLayer({})) // a non-tile layer sits in the stack
expect(engine.query([600, 2005], 12)).toEqual({ type: 'edge', coord: [600, 2000] })
})

test('reprojects the query coordinate when the tile source has a genuinely different projection', () => {
// Real ol/proj Projection objects (not the bare code strings the other tests use), with
// different codes and an identity transform between them, so toSource actually calls
// transform() instead of short-circuiting, while leaving the mocked tileGrid's numbers valid.
const viewProj = new Projection({ code: 'x-test-view', units: 'm' })
const sourceProj = new Projection({ code: 'x-test-source', units: 'm' })
addProjection(viewProj)
addProjection(sourceProj)
addCoordinateTransforms(viewProj, sourceProj, (c) => c, (c) => c)

const { engine, map } = setupVT({ features: [renderFeature('LineString', [500, 2000, 1500, 2000])] })
map.getView = () => ({ getResolution: () => 1, getProjection: () => viewProj })
map.layers[0].getSource().getProjection = () => sourceProj
expect(engine.query([600, 2005], 12)).toEqual({ type: 'edge', coord: [600, 2000] })
})
})

describe('invisible shared fill boundaries', () => {
Expand Down
Loading