Collision label detection

329 views
Skip to first unread message

Olivier Terral

unread,
Apr 3, 2017, 7:42:57 AM4/3/17
to OpenLayers Dev
Hi all,


We are currently, at swisstopo, investigating how could we improve the display of labels with vector tiles.
One of the best feature of competitor like MapboxGLJS  or TangramJS is the label collision detection  [1] .


Does it something we could implement in OL ?  

We would be glad to have your opinion about this.



Bart van den Eijnden

unread,
Apr 3, 2017, 8:57:00 AM4/3/17
to openlay...@googlegroups.com

Hey Olivier,

are you aware of Labelgun already?

https://github.com/Geovation/labelgun

Best regards,

Bart

--
You received this message because you are subscribed to the Google Groups "OpenLayers Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openlayers-de...@googlegroups.com.
To post to this group, send email to openlay...@googlegroups.com.
Visit this group at https://groups.google.com/group/openlayers-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/openlayers-dev/16f86667-245a-475f-b3ca-b5076955cf3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Bart van den Eijnden
JavaScript developer | Boundless
bar...@boundlessgeo.com

Frédéric Junod

unread,
Apr 3, 2017, 10:04:30 AM4/3/17
to OpenLayers Dev
Hello Oliver,

I think it wouldn't be hard to implement this in OpenLayers:
 - add a rbush in ol.render.canvas.Replay
 - compute the text bounding box (in ol.render.canvas.Replay.prototype.replay_)
 - if this bounding box collides an other item; don't draw the text.
 - otherwise draw the text and add the bounding box in the rbush.

Do I miss something ? 

Regards,

fredj

Andreas Hocevar

unread,
Apr 3, 2017, 2:59:26 PM4/3/17
to OpenLayers Dev on behalf of Frédéric Junod
@Fred, for vector layers it is indeed as straightforward as you described. It gets more interesting with vector tile layers, where tiles do not know about each other. That would need to change - label points would need to be collected for the whole viewport, so a label engine can make decisions for the whole visible map.

Andreas.

To unsubscribe from this group and stop receiving emails from it, send an email to openlayers-dev+unsubscribe@googlegroups.com.
To post to this group, send email to openlayers-dev@googlegroups.com.

Olivier Terral

unread,
Apr 6, 2017, 3:38:35 AM4/6/17
to OpenLayers Dev
Thx for your answers guys.

@bart I didn't know about LabelGun, interesting lib. Could be helpful for HTML labelling but we are focus on  canvas/WebGL labelling. I guess it could be the same approach.


@fred and @andreas .

It seems easy when you describe it :) but does it fit all the usecase ? : 

    - Canvas/WebGL
    - VectorTile  using ol.render.Feature 
    - Same approach with text along path?


We would like to achieve  this stuff with OL:

    - Display text along path (https://www.mapbox.com/blog/placing-labels/)
    - Labelling collision detection with horizontal or curved text
    - Both canvas/WebGL


We are may be able to funding this devs depending of costs and timing obviously.

Have boundless or camptocamp any interests in it? if yes could you send me in private an estimation of for these tasks?

Tell me if you need more informations.

Thanks in advance.





Am Montag, 3. April 2017 20:59:26 UTC+2 schrieb Andreas Hocevar:
@Fred, for vector layers it is indeed as straightforward as you described. It gets more interesting with vector tile layers, where tiles do not know about each other. That would need to change - label points would need to be collected for the whole viewport, so a label engine can make decisions for the whole visible map.

Andreas.

Emmanuel Belo

unread,
Apr 6, 2017, 6:15:11 AM4/6/17
to OpenLayers Dev on behalf of Olivier Terral
Hi Olivier

for sure Camptocamp has interest in doing this work. We are going to prepare an estimate.

@Andreas, any interest in a joint effort/proposal?

Best regards

Emmanuel

On 6 April 2017 at 09:38, Olivier Terral via OpenLayers Dev <openlayers-dev+APn2wQeGtk5DS7CcP...@googlegroups.com> wrote:
Thx for your answers guys.

@bart I didn't know about LabelGun, interesting lib. Could be helpful for HTML labelling but we are focus on  canvas/WebGL labelling. I guess it could be the same approach.


@fred and @andreas .

It seems easy when you describe it :) but does it fit all the usecase ? : 

    - Canvas/WebGL
    - VectorTile  using ol.render.Feature 
    - Same approach with text along path?


We would like to achieve  this stuff with OL:

    - Display text along path (https://www.mapbox.com/blog/placing-labels/)
    - Labelling collision detection with horizontal or curved text
    - Both canvas/WebGL


We are may be able to funding this devs depending of costs and timing obviously.

Have boundless or camptocamp any interests in it? if yes could you send me in private an estimation of for these tasks?

Tell me if you need more informations.

Thanks in advance.





Am Montag, 3. April 2017 20:59:26 UTC+2 schrieb Andreas Hocevar:
@Fred, for vector layers it is indeed as straightforward as you described. It gets more interesting with vector tile layers, where tiles do not know about each other. That would need to change - label points would need to be collected for the whole viewport, so a label engine can make decisions for the whole visible map.

Andreas.
To unsubscribe from this group and stop receiving emails from it, send an email to openlayers-dev+unsubscribe@googlegroups.com.
To post to this group, send email to openlayers-dev@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Camptocamp SA
Emmanuel BELO

Mon. Tue. Thu. Fri. 
Reply all
Reply to author
Forward
0 new messages