0

I need to access a Esri REST service, which has a weird XYZ-Format. For example:

On a normal XYZ-Service, z is 14 where on this specific service, on the same height, z is 8.

Does anyone know how to convert them and use the "weird" one on OpenLayers?

This is the "normal" service:

...../15/17122/11081.png

And this the "weird" one:

...../8/458/170

They both are roughly for the same location, on equal height.

Toms
  • 25
  • 5
  • Do you have a link to the service? It may have a limited extent or uses a custom projection and needs a custom tile grid. – Mike Nov 01 '20 at 15:05
  • @Mike Yeah. This is the service [link](https://karte.breitbandmessung.de/servertmp/rest/services/Mobilfunkversorgung/MonitoringPortal_DT_4G/Mapserver/tile/5/51/38) and that's the map where it's embedded in: [link](https://www.breitband-monitor.de/mobilfunkmonitoring/karte) ... I need to embed the overlay tiles onto a custom OpenLayers map – Toms Nov 01 '20 at 15:29

1 Answers1

2

It is a custom tile grid for an EPSG:25832 projection. The settings needed to set up the grid in OpenLayers can be found in https://karte.breitbandmessung.de/servertmp/rest/services/Mobilfunkversorgung/MonitoringPortal_DT_4G/Mapserver?f=pjson Only origin and resolutions are needed, but including extent will prevent out of range tiles being requested - the xmax of the fullExtent seems slightly too small and cuts off the eastern most edge of the country, so I made up an extent based on level 0 being 3 tiles wide

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
    <link rel="stylesheet" href="https://openlayers.org/en/v6.4.3/css/ol.css" type="text/css">
    <script src="https://openlayers.org/en/v6.4.3/build/ol.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.6.1/proj4.js"></script>
    <style>
      html, body, .map {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
      }
    </style>
</head>
<body>
<div id="map" class="map"></div> 
<script>

proj4.defs("EPSG:25832", "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
ol.proj.proj4.register(proj4);

var origin = [233184, 6120719];

var resolutions = [
    1222.9948985513972,
     611.4974492756991,
     305.7487246378482,
      152.87436231920458,
       76.43718115960229,
       38.21859057966118,
       19.109295289886575,
        9.5546476449433,
        4.7773238224716374
];

//var extent = [280300, 5235800, 912300, 6106300];
var extent = [origin[0], origin[1] - 3 * 256 * resolutions[0], origin[0] + 3 * 256 * resolutions[0], origin[1]];

var map = new ol.Map({
  target: 'map',
  layers: [   
      new ol.layer.Tile({
          source: new ol.source.OSM(),
      }),
      new ol.layer.Tile({
            source: new ol.source.XYZ({
                url: "https://karte.breitbandmessung.de/servertmp/rest/services/Mobilfunkversorgung/MonitoringPortal_DT_4G/Mapserver/tile/{z}/{y}/{x}",
                projection: "EPSG:25832",
                tileGrid: new ol.tilegrid.TileGrid({
                  origin: origin,
                  extent: extent,
                  resolutions: resolutions,
                  tileSize: [256, 256],
                }),

          }),
          opacity: 0.5,
      }),
  ],
  view: new ol.View({
      projection: "EPSG:25832", 
  })
});
  
map.getView().fit(extent);

   </script>
</body>
</html>
Mike
  • 16,042
  • 2
  • 14
  • 30