PDOK is a main provider of spatial data services in the Netherlands. Setting up GeoNetwork to use PDOK WMTS services as default background layers in the maps is not as trivial as one would expect. In this post I present a code snippet that will introduce the PDOK layers in both the search and viewer map.

In the Netherlands Geonovum has defined a national gridset for the epsg:28992 RD-new projection. The WMTS’s at PDOK use this projection. The URL’s of available WMTS’s at PDOK can be discoverd in the national catalog.

GeoNetwork offers 3 ways to modify the default display of the mapviewers

  • modify config-viewer.xml, an owscontext file containing a map configuration
  • in Admin > Settings change the map-config parameter
  • In /web-ui/…/catalog/views/default/config.js add a specific openlayers map configuration

Unfortunately the first and second method currently can’t be used, because they both use the epsg:3857 projection. For the third method, open the file and look for the string “* Define maps“. Replace the definitions at that point for the following snippet:

/*******************************************************************
* Define maps
*/
proj4.defs(“EPSG:28992″,”+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs”);

ol.proj.get(‘EPSG:28992’).setExtent([-285401.92,22598.08,595401.92,903401.92]);
ol.proj.get(‘EPSG:28992’).setWorldExtent([ -1.65729160235431,48.0405018704265,11.2902578747914,55.9136415748388]);

var matrixIds=[];
var matrixIds2=[];
for(var i=0;i<=12;++i){if(i<10){
matrixIds[i]=”0″+i;
matrixIds2[i]=”EPSG:28992:”+i
}else{matrixIds[i]=””+i;
matrixIds2[i]=”EPSG:28992:”+i
}}

var resolutions=[3440.64,1720.32,860.16,430.08,215.04,107.52,53.76,26.88,13.44,6.72,3.36,1.68,0.84];

var tileLayers= [new ol.layer.Tile({
title:’BRT’,attribution:’PDOK’,
source: new ol.source.WMTS({
url: ‘http://geodata.nationaalgeoregister.nl/tiles/service/wmts/brtachtergrondkaartgrijs’,
layer: ‘brtachtergrondkaartgrijs’,
matrixSet: ‘EPSG:28992’,
format: ‘image/png’,
projection: ol.proj.get(‘EPSG:28992’),
tileGrid: new ol.tilegrid.WMTS({
origin: [-285401.92,903402.0],
resolutions: resolutions,
matrixIds: matrixIds2
}),
wrapX: true
})
}),new ol.layer.Tile({
title:’Luchtfoto’,attribution:’PDOK’,visible:false,
source: new ol.source.WMTS({
url: ‘http://geodata1.nationaalgeoregister.nl/luchtfoto/wmts?style=default&’,
layer: ‘luchtfoto’,
matrixSet: ‘nltilingschema’,

format: ‘image/jpeg’,
projection: ol.proj.get(‘EPSG:28992’),
tileGrid: new ol.tilegrid.WMTS({
origin: [-285401.92,903402.0],
resolutions: resolutions,
matrixIds: matrixIds,
style:’default’
}),
wrapX: true
})
})];

//important to set the projection info here (also), used as view configuration

var mapsConfig = {
resolutions: resolutions,
extent: [-285401.92,22598.08,595401.92,903401.92],
projection: ‘EPSG:28992’,
center: [150000, 450000],
zoom: 7
};

// Add backgrounds to TOC
viewerSettings.bgLayers = tileLayers;

viewerSettings.servicesUrl = {};

//Configure the ViewerMap

var viewerMap = new ol.Map({
controls:[],
layers: tileLayers,
view: new ol.View(mapsConfig)
});

//configure the SearchMap

var searchMap = new ol.Map({
controls:[],
layers: [tileLayers[0]],
view: new ol.View(mapsConfig)
});

This code will:

  • provide the definition of epsg:28992
  • define matrixsets, the naming convention is manually extracted from the getcapabilities response of the 2 services
  • the extent and resolutions are extracted from the capabilities
  • Some TileLayers are set up pointing to the endpoints, BRT is available in 3 flavours, default, gray and pastel. Gray seems a good options to be used as a background layer.

SPATIAL DATA INFRASTRUCTURES SIMPLIFIED