Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
UTFGrid Layer, Tile and Controls #244
See the related email to dev list at:
More info here:
I'd love to see support for UTFGrids included in the next release. Let me know if there's anything I can do to clean things up to make this happen...
I've added a few commits that I'm hoping you'll consider. These are included in a pull request. I wanted to make some changes that were based on recent work in master. The bulk of the commits in that pull request will go away if you merge master with your branch.
The first change (34a9c46) just adds the new UTFGrid component to the debug loader so examples can work without a build. The next change (6284e44) updates the examples so they fit in a bit better with the rest (and run without the missing ./OpenLayers.js).
My understanding of the UTFGrid spec is that the structure of property values in the data member may be of any type. The existing implementation assumes that the property values will be objects with keys representing feature attribute names and values representing these attribute values. The UTFGrid spec examples show a simple data structure with strings that wouldn't work with this implementation. I've updated things (e1dffac) so that the user provided callback receives a data lookup - keys corresponding to layer index and values straight from the data member.
This change (e1dffac) also gives the layer a
I'd be interested to here if others have comments on this. That's it for now. More review later.
I'm adding commits in my fork while reviewing.
In 4d31a3e, I've changed the layer's
In experimenting with the UTFGrid highlighting, I've noticed a few other issues with the layer. Will be good to write up tests for these.
I think it would be great to get this into 2.12. There are a few more changes I'd like to make. Matt, I'm interested to know how these sound to you.
Single arg layer constructor
I think single arg constructors are the way forward for the library. Details upon request. For this layer, here's the difference.
Instead of this
A user would write this
The difference gets more pronounced when you start assigning more layer properties in the constructor. The three arg constructor is particularly awkward when you have a bunch of options (highlightStyle, useJSONP, zoomOffset, etc.)
The layer and control still need tests.
I'm also interested to work out what is going on with character codes between 55296 and 57343 (mapbox/utfgrid-spec#1). I'm fairly confident there is nothing wrong with this implementation. It's either an encoding issue with the example/tests or a real consideration that needs to be accounted for in the spec. So, while I don't think it should block inclusion of these components, I'd like to figure out why the demo.js tests won't pass.
I'd like to see the JSONP functionality in action. Are there reliable servers that we could use in an example? I think it also makes sense to have examples with pan/zoom navigation. I understand it's tough to load up a bunch of static UTFGrids. But at least being able to pan a bit or zoom once would be nice.
Maybe persnickety, but I'm inclined to change
I'd like to clean up the examples a bit more. Minor stuff: separate js file, some name/structure changes.
Single Arg constructor
The problem is that OpenLayers script protocol uses a global callback registry so the returned JSONP file must dynamically wrap the json in that function. At the moment, the jsonp support is not very practical since the two main utfgrid servers don't support dynamic jsonp callbacks.
Tilestream serves up jsonp files with a hardcoded
I've added dynamic jsonp callbacks to my Tilestache fork at https://github.com/perrygeo/tilestache but that hasn't been pulled into the upstream master yet nor are there really any reliable servers out there running it.
Pan/Zoom in examples
I will update the examples and generate another zoom level of tiles if it's OK to add them to the repository.
Thanks for the feedback. All sounds good. I'm happy to stick with your
I'll try to find a bit more time for the tests.
As mentioned on the other pull request, I only opened that in case Matt doesn't get a chance to pull in my additional commits. I'd like to get some additional eyes on this, but I think it's in good shape. I still want to have an example that allows for some navigation. I've pulled down three zoom levels of grids from MapBox's geography-class layer. I'll try to put together an updated example with that before too long.