Re: [mapserver-users] Labels colliding with symbols
Thanks Lars! Based on your workaround, it seems to me that line labeling works something like this: 1. candidate positions are computed along the line using repeat distance and other factors 2. the candidate positions that are not possible due to collisions with other labels are excluded (unless force is set) I tried to confirm this hypothesis by looking at the code, but being new to MapServer, I can't be sure. However, I did find the code that does step 1: https://github.com/MapServer/MapServer/blob/20b7671f788952c6097ae154b667dd564cf70764/mapprimitive.c#L1956 So it's likely that I'm not far from the truth. For my particular use case, I would like to label the line just once, certainly not many times. For this, it would be helpful to compute candidate placements once the restrictions on positioning are known. Is there any way to accomplish this currently? Thanks, Iljya Em qui., 18 de fev. de 2021 às 10:57, escreveu: > Hi, > > I have modified your example a little bit. > > I You add REPEATDISTANCE for the text and then a fake label with > transparent text above the svg symbol > I think that You get something that is close to what you are looking for. > > If You remove the last fake label block You get the old behavior that the > text is written above the symbol. > > I have inserted the code in your GIST: > https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a > > I have been experimenting without repeatdistance and I can agree with You > that the results were strange. > I thought that the fake label would do the trick, but it didn't > > /Lars Schylberg > > 17 februari 2021 kl. 20:05, "Iljya Kalai" > > skrev: > > Hi Steve, > I've created a minimal example to demonstrate the issue: > https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a > Thanks for your help, > Iljya > Em ter., 16 de fev. de 2021 às 20:41, Steve Lime > escreveu: > > Hmmm... Point symbols are automatically considered as part of label > placement and collision detection. Since they are drawn first, their > placement is cached and labels are placed around them. Can you share > specifics on your layers and symbols - perhaps a small test case? --Steve > On Tue, Feb 16, 2021 at 4:28 PM Iljya Kalai wrote: > > Hi, > On my map, labels sometimes overlap symbols. Is there a way to avoid this, > or are only label/label conflicts avoided? I tried both CC and AUTO for > LAYER::CLASS::LABEL::POSITION. > https://i.imgur.com/C9Ir7dA.png > Thanks! > Iljya > *# *Map file extract > ... > LAYER > NAME "LINE" > TYPE LINE > CLASS > STYLE > COLOR 0 0 0 > WIDTH 1 > END > LABEL > COLOR 150 150 150 > TYPE truetype > SIZE 10 > ANGLE AUTO > POSITION CC > TEXT "hello" > END > END > END > LAYER > NAME "SYMBOLS" > TYPE POINT > ... > CLASS > STYLE > SYMBOL "ABC" > END > END > END > ... > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/mapserver-users > > > > ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Labels colliding with symbols
Hi, I have modified your example a little bit. I You add REPEATDISTANCE for the text and then a fake label with transparent text above the svg symbol I think that You get something that is close to what you are looking for. If You remove the last fake label block You get the old behavior that the text is written above the symbol. I have inserted the code in your GIST: https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a (https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a) I have been experimenting without repeatdistance and I can agree with You that the results were strange. I thought that the fake label would do the trick, but it didn't /Lars Schylberg 17 februari 2021 kl. 20:05, "Iljya Kalai" mailto:iljya.ka...@gmail.com?to=%22Iljya%20Kalai%22%20)> skrev: Hi Steve, I've created a minimal example to demonstrate the issue: https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a (https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a) Thanks for your help, Iljya Em ter., 16 de fev. de 2021 às 20:41, Steve Lime mailto:sdl...@gmail.com)> escreveu: Hmmm... Point symbols are automatically considered as part of label placement and collision detection. Since they are drawn first, their placement is cached and labels are placed around them. Can you share specifics on your layers and symbols - perhaps a small test case? --Steve On Tue, Feb 16, 2021 at 4:28 PM Iljya Kalai mailto:iljya.ka...@gmail.com)> wrote: Hi, On my map, labels sometimes overlap symbols. Is there a way to avoid this, or are only label/label conflicts avoided? I tried both CC and AUTO for LAYER::CLASS::LABEL::POSITION. https://i.imgur.com/C9Ir7dA.png (https://i.imgur.com/C9Ir7dA.png) Thanks! Iljya # Map file extract ... LAYER NAME "LINE" TYPE LINE CLASS STYLE COLOR 0 0 0 WIDTH 1 END LABEL COLOR 150 150 150 TYPE truetype SIZE 10 ANGLE AUTO POSITION CC TEXT "hello" END END END LAYER NAME "SYMBOLS" TYPE POINT ... CLASS STYLE SYMBOL "ABC" END END END ... ___ mapserver-users mailing list mapserver-users@lists.osgeo.org (mailto:mapserver-users@lists.osgeo.org) https://lists.osgeo.org/mailman/listinfo/mapserver-users (https://lists.osgeo.org/mailman/listinfo/mapserver-users) ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Labels colliding with symbols
Hi Steve, I've created a minimal example to demonstrate the issue: https://gist.github.com/iljya/b1d58f250be11e8972ea6e5628f84b2a Thanks for your help, Iljya Em ter., 16 de fev. de 2021 às 20:41, Steve Lime escreveu: > Hmmm... Point symbols are automatically considered as part of label > placement and collision detection. Since they are drawn first, their > placement is cached and labels are placed around them. Can you share > specifics on your layers and symbols - perhaps a small test case? --Steve > > On Tue, Feb 16, 2021 at 4:28 PM Iljya Kalai wrote: > >> Hi, >> >> On my map, labels sometimes overlap symbols. Is there a way to avoid >> this, or are only label/label conflicts avoided? I tried both CC and AUTO >> for LAYER::CLASS::LABEL::POSITION. >> >> https://i.imgur.com/C9Ir7dA.png >> >> Thanks! >> Iljya >> >> >> *# *Map file extract >> ... >> LAYER >> NAME "LINE" >> TYPE LINE >> CLASS >> STYLE >> COLOR 0 0 0 >> WIDTH 1 >> END >> LABEL >> COLOR 150 150 150 >> TYPE truetype >> SIZE 10 >> ANGLE AUTO >> POSITION CC >> TEXT "hello" >> END >> END >> END >> >> LAYER >> NAME "SYMBOLS" >> TYPE POINT >> ... >> CLASS >> STYLE >> SYMBOL "ABC" >>END >> END >> END >> ... >> ___ >> mapserver-users mailing list >> mapserver-users@lists.osgeo.org >> https://lists.osgeo.org/mailman/listinfo/mapserver-users >> > ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Labels colliding with symbols
Hmmm... Point symbols are automatically considered as part of label placement and collision detection. Since they are drawn first, their placement is cached and labels are placed around them. Can you share specifics on your layers and symbols - perhaps a small test case? --Steve On Tue, Feb 16, 2021 at 4:28 PM Iljya Kalai wrote: > Hi, > > On my map, labels sometimes overlap symbols. Is there a way to avoid this, > or are only label/label conflicts avoided? I tried both CC and AUTO for > LAYER::CLASS::LABEL::POSITION. > > https://i.imgur.com/C9Ir7dA.png > > Thanks! > Iljya > > > *# *Map file extract > ... > LAYER > NAME "LINE" > TYPE LINE > CLASS > STYLE > COLOR 0 0 0 > WIDTH 1 > END > LABEL > COLOR 150 150 150 > TYPE truetype > SIZE 10 > ANGLE AUTO > POSITION CC > TEXT "hello" > END > END > END > > LAYER > NAME "SYMBOLS" > TYPE POINT > ... > CLASS > STYLE > SYMBOL "ABC" >END > END > END > ... > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/mapserver-users > ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
[mapserver-users] Labels colliding with symbols
Hi, On my map, labels sometimes overlap symbols. Is there a way to avoid this, or are only label/label conflicts avoided? I tried both CC and AUTO for LAYER::CLASS::LABEL::POSITION. https://i.imgur.com/C9Ir7dA.png Thanks! Iljya *# *Map file extract ... LAYER NAME "LINE" TYPE LINE CLASS STYLE COLOR 0 0 0 WIDTH 1 END LABEL COLOR 150 150 150 TYPE truetype SIZE 10 ANGLE AUTO POSITION CC TEXT "hello" END END END LAYER NAME "SYMBOLS" TYPE POINT ... CLASS STYLE SYMBOL "ABC" END END END ... ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users