3

I have a PostGIS table that contains geometry, min_scale, and max_scale fields. The PostGIS table is published as a Geoserver layer with EPSG = 4326. I have created a CSS Style Doc that will show each geoemtry only in its scale range; something like:

[@sd <= max_scale] [@sd >= min_scale]{
     mark: symbol(circle); 
}

My problem is how to set the min_scale and max_scale fields to work properly with Openlayers zoom levels. I tried to use the scale values from the EPSG:4326 Gridset:

http://localhost:8080/geoserver/web/wicket/bookmarkable/org.geoserver.gwc.web.gridset.GridSetEditPage?6&gridSet=EPSG:4326

But it didn't work properly; for example if I set

min_scale = 545978 which corresponds to zoom 9

max_scale = 2183915 which corresponds to zoom 7

The feature appears only at zoom 7 and 8, and didn't appear at zoom 9.

I also tried the values at this table (Default Gridset):

https://docs.geoserver.org/latest/en/user/styling/ysld/reference/scalezoom.html#default-gridset But the same problem occurred.

My question is what is my problem? which scale values should I use in order to work properly with Openlayers zoom levels?

Faz B
  • 465
  • 2
  • 11

1 Answers1

1

As discussed in this question GeoServer uses a DPI (or more correctly a Pixels per inch) of 90.714. Meanwhile this question suggests that OpenLayers uses 72. This is why you get a miss match in scales. The easy answer used to be you added an OpenLayers.DOTS_PER_INCH variable. I don't know how OL3+ handles it.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185