[OpenLayers-Users] Multiple labels on the same polygon
Lehtonen, Mika
mika at digikartta.net
Tue Oct 28 02:59:21 EDT 2008
Ok,
thanks! That makes perfectly sense, except the scale. I have that
DOTS_PER_INCH setting set exactly as it is in the OL preview. Still, if
I zoom to same scale, the map is approx. twice as big in my application
than in OL preview. Does it depend on the projection? OL preview uses
EPSG:2393 as my app. uses EPSG:900913. I really don't know if this scale
issue makes any difference, I was just a bit curious about it.
- mika -
Tim Schaub kirjoitti:
> Hey-
>
> Lehtonen, Mika wrote:
>
>> Hi,
>>
>> I am trying to do some labels on polygons which are in an overlay layer
>> on top of Google Map base layer. The polygon data is served through WMS
>> (Geoserver). Labels are produced in GeoServer using its own style
>> definition (TextSymbolizer). The problem is that larger polygons get
>> more than one label on them. I would prefer them to have exactly one per
>> polygon. If I test the polygon layer with Geoserver's OL preview,
>> everything is just like I would want it to be. But my html page is
>> something else.
>>
>>
>
> Regarding labels, your WMS layer probably uses multiple tiles (unless
> you set singleTile to true). With multiple tile requests, the server
> treats each as independent, so it will faithfully label as many polygons
> as the tile bounds intersect.
>
> A good solution for nicely labeled tiles that improves performance is to
> use something that creates meta-tiles (big tiles that are sliced into
> smaller ones) and caches your rendered tiles. Both TileCache and
> GeoWebCache will do this for you.
>
> If you have data that changes frequently - or some other reason not to
> cache tiles on the server - you can use the non-standard TILED and
> TILESORIGIN parameters in your WMS request. This tells GeoServer that
> multiple requests are coming in for tiles, and it figures out which
> polygons to label.
>
> See these two examples:
> http://tinyurl.com/tiledfalse (TILED=false)
> http://tinyurl.com/tiledtrue (TILED=true)
>
> Read the bit on "On the fly meta tiler":
> http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters#WMSvendorparameters-TILED
>
> Also, view the source of your GeoServer layer preview to see the use in
> an OpenLayers page.
>
>
>> I also noticed that the scale in my page when compared to scale in the
>> OL preview, is different. However, the SLD seem to be obeying the scale
>> value although the real map scale is different. Could that differ be the
>> key to my problems?
>>
>
> OpenLayers assumes a display resolution of 72 dots per inch by default.
> This is almost always wrong (but an app designer has no way of knowing).
>
> The SLD spec says the following:
>
> The "standardized rendering pixel size" is defined to be 0.28mm × 0.28mm
> (millimeters).
>
> Which (as it admits) is frequently wrong (and generally unknown by the
> server). But, at least it is a standard.
>
> The GeoServer layer preview sets the OpenLayers.DOTS_PER_INCH constant
> to match the SLD "standardized rendering pixel size." You can do this
> as well in your application:
>
> OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
>
>
>> I will deliver further information if needed. OL is either 2.7 or the
>> one delivered with Geoserver 1.7.0.
>>
>>
>
> None of the above will be different with any 2.x version of OpenLayers.
> But it looks like OpenLayers 2.7 got in to GeoServer 1.7
> (http://jira.codehaus.org/browse/GEOS-2279).
>
> Good luck,
> Tim
>
>
>> - mika -
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
>
More information about the Users
mailing list