[OpenLayers-Dev] preliminary UTFGrid support in OpenLayers

Tim Schaub tschaub at opengeo.org
Sat Feb 25 20:07:40 EST 2012


On Sat, Feb 25, 2012 at 4:39 PM, Tom MacWright <tom at macwright.org> wrote:
>> In addition, I'd like to add support for highlighting regions in the
> grid.  I've got a plan for doing this, and while I don't want to hold
> up inclusion of the existing functionality, I do think the highlight
> functionality might inform a bit more how things could be structured.
>
> Highlighting is a bit of an unusual question with UTFGrid. It's a tiles-only
> format - original geometries are never sent over in their full form. I've
> written a quick proof of concept, glower: http://mapbox.com/glower/# which
> does an overlay of canvas tiles over normal tiles and implements some simple
> edge-squaring, anti-aliasing (by hand :/ ), and such. The OpenLayers
> implementation - I'm not sure if I've seen whether it loads all tiles by
> default or lazy-loads (as the other implementations do), but basically you
> need to resolve tile boundaries and do a bit of odd logic for figuring out
> which features are equal.

Yeah.  My plan was to use a single canvas for optional highlighting,
scanning the tile grids for target ids, using a user provided
symbolizer with (optional) strokeColor - painting with that when
hitting an edge - and fillColor/Opacity.  This could apply to an
arbitrary number of target ids (in case someone wanted to "select"
more than one "feature").  Will have to see how it works out
performance wise.  Your manual anti-aliasing sounds interesting.  I'll
take a closer look at glower.

Tom, I'm also interested in hearing your feedback on Matt's
implementation.  I just issued him a pull request that I'd like to
keep working on a bit.  One change I made was to remove any assumption
about the structure of the data property values.  Matt's
implementation assumed (by default) that the data would be a simple
attributes style object (with string property values).  Looks to me
like the UTFGrid spec doesn't prescribe anything for the optional data
member.  Matt, I'm gathering that in your experience this data will
always be feature attribute objects.  Still feels to me like it makes
more sense to leave the handling/rendering of this data up to the app
dev (instead of having a default table view rendered by the control).

Hope to squeeze in some more review time later (kids just woke up from
nap).  This is good stuff.

Tim

> On Sat, Feb 25, 2012 at 6:35 PM, Tim Schaub <tschaub at opengeo.org> wrote:
>>
>> Hey Matt,
>>
>> Thanks for this great contribution.  It's been high on my list of
>> desires to get UTFGrid support into OpenLayers, and it looks like you
>> have done a nice job of it.
>>
>> After a quick preliminary review, I do have a few comments.  First,
>> we'll need some tests to go along with this addition.  Beyond that,
>> I've got some suggestions about the layer API that I hope you'll be
>> amenable to.  I think it would make sense to provide a method on the
>> layer to get attribute data for a map location.  This functionality is
>> currently in the control, but can see situations where it would be
>> useful to access this and awkward to have to add a control.  I'll
>> provide a pull request for this and some additional tweaks.  Note that
>> my pull request will look a lot smaller if you merge the latest master
>> into your utfgrid branch.
>>
>> In addition, I'd like to add support for highlighting regions in the
>> grid.  I've got a plan for doing this, and while I don't want to hold
>> up inclusion of the existing functionality, I do think the highlight
>> functionality might inform a bit more how things could be structured.
>>
>> I'll leave more comments on your pull request.
>>
>> Tim
>>
>> On Thu, Feb 16, 2012 at 12:08 PM, Matt Perry <perrygeo at gmail.com> wrote:
>> > Hey all - I'm excited to share my implementation of OpenLayers support
>> > for UTFGrids. I wanted to get some feedback before doing a pull
>> > request.
>> >
>> > Just a little background: UTFGrids are json "hit grids" used to
>> > provide a high degree of interactivity. For example, you can have
>> > mouseover events that display the attributes of the features *without*
>> > fetching additional data from the server. The best demo of the concept
>> > is probably http://mapbox.com/demo/visiblemap/.
>> >
>> > This functionality exists in the wax library and is largely deployed
>> > with ModestMaps. I've ported it to native OpenLayers code to better
>> > integrate with OL event handlers and such. There are three additional
>> > components: a UTFGrid Layer, Control and Tile. It has both ajax and
>> > jsonp loading protocols, tries to keep a clear separation between the
>> > grid layers, the grid controls and callbacks which allows things like
>> > multiple handlers and multiple hit grids per map.
>> >
>> > Some example code:
>> >        var world_utfgrid = new OpenLayers.Layer.UTFGrid(
>> >            'UTFGrid Layer',
>> >            "http://tiles.example.com/world_utfgrid/${z}/${x}/${y}.json"
>> >        );
>> >        map.addLayer(world_utfgrid);
>> >
>> >        var control = new OpenLayers.Control.UTFGrid({
>> >            'div': 'attrsdiv',
>> >            'layers': [world_utfgrid],
>> >            'handlerMode': 'move'
>> >        })
>> >        map.addControl(control);
>> >
>> >
>> > Some demos:
>> > http://labs.ecotrust.org/utfgrid/events.html
>> > http://labs.ecotrust.org/utfgrid/multi.html
>> >
>> > and source:
>> > https://github.com/perrygeo/openlayers/tree/utfgrid
>> >
>> > Any thoughts on getting this into 2.12? This is my first substantial
>> > effort in extending OpenLayers so if you have any critiques or
>> > concerns that need to be addressed before a pull request would be
>> > considered, let me know.
>> > --
>> > ·´¯`·.¸. , . .·´¯`·.. ><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>
>> > "The best way to predict the future is to invent it."  -- Alan Kay
>> > Matthew T. Perry
>> > http://www.perrygeo.net
>> > http://viedevelo.wordpress.com
>> > _______________________________________________
>> > Dev mailing list
>> > Dev at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>>
>>
>>
>> --
>> Tim Schaub
>> OpenGeo http://opengeo.org/
>> Expert service straight from the developers.
>> _______________________________________________
>> Dev mailing list
>> Dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
>



-- 
Tim Schaub
OpenGeo http://opengeo.org/
Expert service straight from the developers.


More information about the Dev mailing list