[OpenLayers-Users] Sample OL site...
Richard Duivenvoorde
rdmailings at duif.net
Thu Apr 17 04:22:22 EDT 2008
Hi Shipra,
we've just finished a (tiled) map based on OpenStreetmap-data and had
about the same problems as you mention. I thought it would be helpfull
to others to share some experiences:
Those labeling doubles/partials are 'known' problems, of which there are
a lot of solutions. But it's not very obvious, because there are so much
variables: type of geometries, tools used, label positions, edges etc
So there are a lot of buttons you can turn on to get the best result.
It's part of the game to fiddle with those :-)
Assuming you use some 'tiling'-mechanism, for example using Mapserver
and Tilecache, there are the following issues:
- raster vs vector data
The problems you mention only appear if you render vector data (just to
be clear). The actual problem is LABELING.
It has also to be clear that because of tiling you cut up your big-image
in rather small mini-maps. The problem is that a renderer/mapserver will
use only the information it has for current tile/mapimage to determine
which labels to draw. This makes these 'edgy problems'.
DOUBLES and PARTIALS:
- labeling points versus area/polygons and automatic labeling
It good to realize yourself that there is a difference between labeling
point geometries versus area/polygons. With the latter, you renderer (eg
mapserver) is free to choose WHERE to put the label. It searches for the
best position based on eg: available space around (edges), other labels
in the neighborhood. The same for lines.
With points however the renderer does not have that much 'freedom'. If
you use POSITION auto, it does have some, but if you lock it by giving
POSITION the value 'cc', you force the label on one place.
It's this knowledge you can use to choose for example that you will use
a point-layer for you labels (eg to generate a special point-label-layer
from an polygon layer by generating a layer with the centerpoints of the
polygons). In the case of using tiling: to 'fix' your (point)-labels by
using cc for POSITION. But this is not enough to be sure there will be
no doubles in your tiles. If you do not force the renderer to only draw
whole labels (on the edges), you can end up with a partial label on the
edge because the point is laying on the edge of one tile (but on this
tile the label is only drawn half) and on the neighborhood tile nothing
is drawn, because this tile is not aware of the point (and it's label).
So use PARTIALS=false to be sure you will end up with partials on tile
edges.
Another option you can use here is the
"labelcache_map_edge_buffer" "-100"
configuration (in the metabuffer of the MAP FILE NOT THE LAYER!)
This makes that there will be a label-less border of 100 pixels in your
map-image/tile ...
But what about those points laying on just 2 pixels from the edge of a
tile? These will never be drawn then. That's where the Tilecache
configuration 'metaBuffer' kicks in. If you use the metaTile=true option
for tilecache, tilecache will not do 'tile by tile'-requests, but will
request for example a 'metaTile' of 5x5 tiles at once. If you now use
the option
metaBuffer=100
for your metaTiles, it will request big tiles with a 100 pixel wide
buffer around it. And just cut of this 100 pixel wide labelless(!)
buffer for you, and all labels will be shown :-)
be aware of the option FORCE for you labels also. While it's not nice to
have overlapping labels, you sometimes are 'forced' to use FORCE just
because otherwise there will not be enough labels in your tiles... But
be careful with 'FORCE true'...
- multiple labels / too much label for line/polygons
The labeling of lines and polygons is very different from the points,
because mapserver has so much freedom to place the labels along the line
or in the (big) polygons.
Because the map is divided in so much tiles/mini-maps, you will end up
with too much labels for the same lines. This is why you really have to
use metaTiling for your tilecache! Otherwise the
labeling-buffer/mindistance/featuresize is determined for one minitile
... which is not what you want probably...
So, be sure to put on metatiling, and fiddle around with the following
label options then:
mindistance (do no draw the same label within certain distance
minfeaturesize (only put labels on features of a certain size)
buffer (do not draw labels in a certain buffer around current)
partials (do or do not draw partials (on the edges)
Sometimes you have to split up the labeling in different scales, because
at higher levels you want less labels to be seen etc.
Here some other links:
http://mapserver.gis.umn.edu/docs/reference/mapfile the label part:
http://mapserver.gis.umn.edu/docs/reference/mapfile/label
http://biometry.gis.umn.edu/tutorial/ has a nice part about labeling:
http://biometry.gis.umn.edu/tutorial/example1-4.html
And the config names:
MAPSERVER:
web
metadata
...
"labelcache_map_edge_buffer" "-100"
end
end
..
...
class
...
Label
...
partials (false or true)
buffer (4 number)
force (false or true)
position (cc .. )
mindistance (100 )
minfeaturesize (50)
(angle)
end
..
TILECACHE:
[layerx]
metaTile=true
metaBuffer=10
Mmm, ended up with al long email, hope this helps for somebody.
Maybe it's an idea to put this kind of info in a nice (illustrated) wiki
article?
Regards and fiddle around,
Richard Duivenvoorde
shipra wrote:
> Hi Steve
>
> Your Application is nice...
> I have a query....
> I also made an application in openlayers.
> So want to know din't u have any problems with labeling coz I had many of
> labels got cut bcoz of tiles
> also the labels were repeated in tiles.
>
> Wat did u use for that?
> Pls reply..
>
> Regards,
> Shipra
>
> --------------------------------------------------
> From: "Steve Lime" <Steve.Lime at dnr.state.mn.us>
> Sent: Thursday, April 17, 2008 2:06 AM
> To: <users at openlayers.org>
> Subject: [OpenLayers-Users] Sample OL site...
>
>> Hi all: Figured I'd share an OL powered site we've got going.
>>
>> http://www.dnr.state.mn.us/maps/compass.html
>>
>> It's a simple viewer but OL was perfect for this type of thing for us.
>> It's using:
>>
>> - OpenLayers 2.5
>> - MapServer 5.1 (development version, AGG backend)
>> - TileCache 2 (mod_python, WMS layer)
>>
>> We still see the odd clipping problem with road shields, even with
>> metatiling on but for the most it
>> works well.
>>
>> Steve
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
More information about the Users
mailing list