I'm trying to display a EPSG:3844 WMTS service from an ArcGIS server in OpenLayers 3.20.1. In order for it to be displayed correctly, I need to manually swap the origin coordinates found in the capabilities file. This is my code:

proj4.defs('EPSG:3844', '+proj=sterea +lat_0=46 +lon_0=25 +k=0.99975 +x_0=500000 +y_0=500000 +ellps=krass +towgs84=2.3283,-147.0416,-92.0802,-0.30924979,0.32482188,0.49730012,5.68907711 +units=m +no_defs');

const response = await fetch(serviceUrl);
const parser = new ol.format.WMTSCapabilities();
const capabilities: any = parser.read(await response.text());
const options = ol.source.WMTS.optionsFromCapabilities(capabilities, {
    layer: capabilities.Contents.Layer[0].Identifier,
    matrixSet: capabilities.Contents.TileMatrixSet[0].Identifier,

const originalTileGrid = options.tileGrid;
options.tileGrid = new ol.tilegrid.WMTS({
    origins: originalTileGrid.getResolutions().map((_, z) => {
        const o = originalTileGrid.getOrigin(z);
        const transposedOrigin: ol.Coordinate = [o[1], o[0]];
        return transposedOrigin;
    resolutions: originalTileGrid.getResolutions(),
    matrixIds: originalTileGrid.getMatrixIds(),
    tileSizes: originalTileGrid.getResolutions().map((_, z) => {
        return originalTileGrid.getTileSize(z);

and this is the relevant portion from WMTSCapabilities.xml:

    <ows:Title>TileMatrix using 0.28mm</ows:Title>
        <TopLeftCorner>754000.0 134000.0</TopLeftCorner>

From the WMTS specification (pdf):

CRS will be inherited from the supportedCRS parameter of the parent TileMatrixSet. The order of these axes, shall be as specified by the supported CRS. These are the precise coordinates of the top left corner of top left pixel of the 0,0 tile.

So my questions are:

Who's doing something wrong here?

Is it ESRI, should they be sending the axes the other way around? Is it OpenLayers, should they switch the axes?

Or is it me and I'm missing something?

  • Doesn't EPSG for Pulkovo 1942(58) specify axis order as Northing, Easting? Then, just verify if the capabilities report correct ordering and you will know who is wrong. – mloskot May 31 '17 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.