1

I have a little problem, that I do not understand.

My Tiles come from a own mapserver (Mapserver) and everything is fine there. Is a orthophoto of Berlin. But if I invite the WMTS in OpenLayers I get too high tiles for the respective zoom level and the TileRow is negative:

http://10.40.6.199/mapcache/wmts?layer=wms_test&style=default&tilematrixset=test&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=2&TileCol=31&TileRow=-30

It has to be like this:

http://10.40.6.199/mapcache/wmts?layer=wms_test&style=default&tilematrixset=test&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=3&TileCol=1&TileRow=1

My Code in OpenLayers:

      var projectionExtent = [368000.0000000000000000, 5798000.0000000000000000, 416000.0000000000000000, 5838000.0000000000000000];
      var resolutions = new Array(14);
      var resolutions = [700, 280, 140, 70, 28, 14, 7, 2.8, 1.4, 0.7, 0.28, 0.14, 0.07, 0.028];
      var matrixIds = new Array(14);
      for (var z = 0; z < 14; ++z) {
        matrixIds[z] = z;
      }
      var wmts = new ol.source.WMTS({
              attributions: 'Tiles © Mapserver',
              url: 'http://10.40.6.199/mapcache/wmts?',
              serverType: 'mapserver',
              crossOrigin: 'anonymous',
              layer: 'wms_test',
              matrixSet: 'test',
              format: 'image/png',
              projection: 'EPSG:3006',
              tileGrid: new ol.tilegrid.WMTS({
                  origins: [[368000, 5977200], [368000, 5869680], [368000, 5869680], [368000, 5851760], [368000, 5841008], [368000, 5841008], [368000, 5839216], [368000, 5838140], [368000, 5838140.8], [368000, 5838140.8], [368000, 5838069.12], [368000, 5838033.28], [368000, 5838015.36], [368000, 5838004.608]],
                resolutions: resolutions,
                matrixIds: matrixIds,
              }),
              style: 'default',
            });

Mapcache.xml :

<?xml version="1.0" encoding="UTF-8"?>

<mapcache>
   <cache name="disk" type="disk">
           <base>/mnt/speicher/mapcache</base>
           <symlink_blank/>
   </cache>

   <grid name="test">
      <metadata>
         <title>test_3006</title>
                 <WellKnownScaleSet>test-3006</WellKnownScaleSet>
      </metadata>
      <extent>368000.0000000000000000 5798000.0000000000000000 416000.0000000000000000 5838000.0000000000000000</extent>
      <srs>EPSG:3006</srs>
      <srsalias>EPSG:3006</srsalias>
      <resolutions>700 280 140 70 28 14 7 2.8 1.4 0.7 0.28 0.14 0.07 0.028</resolutions>
      <units>m</units>
      <size>256 256</size>
   </grid>

   <source name="luftbild" type="wms">
      <http>
              <url>http://localhost/cgi-bin/mapserv?</url>
                 <connection_timeout>300</connection_timeout>
      </http>
      <getmap>
         <params>
            <FORMAT>image/png</FORMAT>
            <LAYERS>Berlin</LAYERS>
            <MAP>/home/oliver/Dokumente/orthophoto_berlin/orthophoto_simple.map</MAP>
            <TRANSPARENT>TRUE</TRANSPARENT>
         </params>
      </getmap>
   </source>

   <tileset name="wms_test">
      <source>luftbild</source>
      <cache>disk</cache>
      <grid>test</grid>
      <format>PNG</format>
      <metatile>5 5</metatile>
      <metabuffer>10</metabuffer>
      <expires>3600</expires>
   </tileset>

   <default_format>JPEG</default_format>

   <service type="wms" enabled="true">
      <full_wms>assemble</full_wms>
      <resample_mode>bilinear</resample_mode>
      <format>PNG</format>
   </service>
   <service type="wmts" enabled="true"/>
   <service type="tms" enabled="true"/>
   <service type="kml" enabled="true"/>
   <service type="gmaps" enabled="true"/>
   <service type="ve" enabled="true"/>
   <service type="demo" enabled="true"/>

   <errors>report</errors>
   <lock_dir>/home/oliver/Dokumente/lockdir</lock_dir>

</mapcache>

Mapfile:

MAP
  NAME "ORTHOPHOTO_BERLIN"
  EXTENT 368000.0000000000000000 5798000.0000000000000000 416000.0000000000000000 5838000.0000000000000000
  UNITS kilometers
  SHAPEPATH "/home/oliver/Dokumente/orthophoto_berlin/"
  SIZE 1000 1000
  IMAGETYPE PNG24
  PROJECTION
    "init=epsg:3006"
  END

  WEB
    METADATA
      ows_title "Orthophoto_Berlin"
      ows_enable_request "*"
      ows_srs "EPSG:3006"
    END
  END

  LAYER
    NAME "berlin"
    STATUS ON
    TYPE RASTER
    DEBUG 10
    PROJECTION
        "init=epsg:3006"
    END
    TILEINDEX "kachelindex.shp"
    TILEITEM "location"
  END

OUTPUTFORMAT
  NAME "png"
  DRIVER AGG/PNG
  MIMETYPE "image/png"
  IMAGEMODE RGB
  EXTENSION "png"
END

END
4
  • You may need to swap your coordinates. It seems EPSG:3006 uses Northing - Easting epsg.io/3006 but OpenLayers will be expecting Easting-Northing
    – Mike
    Oct 25, 2019 at 20:26
  • @mike OpenLayers shouldn't expect this, it should honour the defined coordinate axis, moving on then, in swapping coordinates, do you mean in the OpenLayers code, or do you mean get mapserver to advertise a projection in its service, then put out coordinates in the wrong order?
    – nmtoken
    Oct 26, 2019 at 4:45
  • Although that part of the code has not been shown OpenLayers code wpuld normally use the proj4js definition of the projection from epsg.io/3006 which does not swap the axes, so coordinates used in the OpenLayers code should be supplied as Easting, Northing. The server's definition isn't important as OpenLayers is requesting tile grid coordinates, not geographical coordinates. However there would be problems if instead of setting up the tilegrid manually in OpenLayers it was done by parsing the capabilities using the WMTS.optionsFromCapabilities method.
    – Mike
    Oct 26, 2019 at 10:40
  • Inserting +axis=neu in the proj4 definition may provide a quick fix proj4.defs("EPSG:3006","+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +axis=neu +no_defs");
    – Mike
    Oct 26, 2019 at 11:57

1 Answer 1

0

I had to change the EPSG from 3006 to 25833 in Openlayers, although 3006 is in the WMTS and the .ecw datas, that come into the mapserver.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.