Projections · Angular, React and OpenLayers

A tiled WMS in the Polish 1992 grid

Run a native Polish 1992 grid (EPSG:2180) OpenLayers View with proj4, tiled GUGiK WMS 1.1.1 layers and MapServer HiDPI boundary scaling.

GUGiK's topographic map of southern and central Poland in the Polish 1992 grid, from the western border to Lublin and from the Beskids to Warsaw, with the voivodeship boundaries in magenta and a metric scale line in the bottom left corner.
A screenshot of the example. Topographic map and administrative boundaries © GUGiK.

What this example shows

Across southern and central Poland from the western border to Lublin and from the Beskids to Warsaw, both the OpenLayers View and two tiled GUGiK WMS layers—topographic basemap and magenta voivodeship borders—operate natively in the Polish 1992 national grid (EPSG:2180) with a true-metre scale line in the corner.

When you need it

Polish surveying, urban planning (MPZP), environmental impact and cadastral systems work natively in PUWG 1992 (EPSG:2180) or PUWG 2000 so server-rendered national WMS layers stay 100% unwarped and map units represent true ground metres.

Configuring proj4 together with an explicit national extent calibrates zoom levels, tile grids and coordinate transforms cleanly.

The code

The example uses cc-openlayers, my Angular component library for OpenLayers: each aol-… element creates the OpenLayers object it names, updates it from its inputs and disposes of it with the component.

wms-custom-proj.shared.ts
/** The topographic map service. */
export const TOPO = 'https://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer';

/** The administrative boundaries service. */
export const BOUNDARIES = 'https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries';

/** The validity extent of EPSG:2180 around Poland; it also sets the tile grid of zoom level 0. */
export const EXTENT = [100000, 160000, 800000, 880000];
wms-custom-proj.ts
import { ChangeDetectionStrategy, Component, inject, PendingTasks, signal } from '@angular/core';
import {
  ControlScaleLineComponent,
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  loadProj4,
  MapComponent,
  registerProjectionDefinitions,
  SourceTileWMSComponent,
  ViewComponent,
} from 'cc-openlayers';
import { get as getProjection } from 'ol/proj';
import { BOUNDARIES, EXTENT, TOPO } from './wms-custom-proj.shared';

/**
 * Poland's topographic map and voivodeship boundaries on a map in the national grid (EPSG:2180), registered through
 * proj4 before the map starts.
 */
@Component({
  selector: 'app-wms-custom-proj',
  imports: [
    ControlScaleLineComponent,
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceTileWMSComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    @if (ready()) {
      <aol-map height="480px">
        <aol-interaction-default />
        <aol-control-defaults />
        <aol-control-scaleline units="metric" />
        <aol-view [zoom]="2" [extent]="extent" projection="EPSG:2180">
          <aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
        </aol-view>
        <aol-layer-tile [extent]="extent">
          <aol-source-tilewms
            url="${TOPO}"
            [params]="{ LAYERS: 'Raster', FORMAT: 'image/jpeg', VERSION: '1.1.1' }"
            attributions="Topographic map © GUGiK"
          />
        </aol-layer-tile>
        <aol-layer-tile [extent]="extent">
          <aol-source-tilewms
            url="${BOUNDARIES}"
            [params]="{ LAYERS: 'A01_Granice_wojewodztw', VERSION: '1.1.1' }"
            serverType="mapserver"
            attributions="Administrative boundaries © GUGiK"
          />
        </aol-layer-tile>
      </aol-map>
    }
  `,
})
export class WmsCustomProj {
  /** True once EPSG:2180 is known to OpenLayers, which the view needs when it is created. */
  readonly ready = signal(false);

  protected readonly extent = EXTENT;

  constructor() {
    void inject(PendingTasks).run(async () => {
      try {
        registerProjectionDefinitions(await loadProj4(), {
          'EPSG:2180':
            '+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs',
        });
        getProjection('EPSG:2180')?.setExtent(this.extent);
        this.ready.set(true);
      } catch (error) {
        console.error('The projection could not be loaded', error);
      }
    });
  }
}

Architecture and OpenLayers mechanics

registerProjectionDefinitions registers EPSG:2180 via proj4 and getProjection('EPSG:2180')?.setExtent(this.extent) defines the national bounding box before @if (ready()) creates the map.

The EPSG:2180 view clamps navigation inside [extent]="extent", while both tiled WMS layers request VERSION: '1.1.1' (guaranteeing easting-first BBOX order matching plain proj4 definitions) and the boundaries layer adds serverType="mapserver" for sharp Retina MAP_RESOLUTION line widths.

How it works

  • registerProjectionDefinitions registers EPSG:2180 and getProjection('EPSG:2180')?.setExtent(this.extent) calibrates its zoom pyramid before @if (ready()).
  • View [extent]="extent" keeps the entire viewport inside Poland’s national grid bounds.
  • serverType="mapserver" requests high-DPI boundary tiles with matching MAP_RESOLUTION, layered over standard topographic WMS tiles.
  • proj4 supplies bidirectional EPSG:4326 ↔ EPSG:2180 transforms so initial centre coordinates can still be written in degrees.

Pitfalls

  • Plain proj4 definitions without +axis=neu treat EPSG:2180 as easting-first, whereas WMS 1.3.0 expects northing-first for EPSG:2180—specifying VERSION: '1.1.1' forces easting-first BBOX ordering across all coordinate systems (or see wms-image-custom-proj for an axisOrientation option of neu under WMS 1.3.0).
  • OpenLayers derives zoom 0 of a custom projection from projection.getExtent(): changing that extent array changes the ground scale of every integer zoom level.

The same feature in the OpenLayers examples .

Background: state and lifecycle of maps in Angular with OpenLayers, which the components of cc-openlayers take care of.