I'm developing an application where I need to draw the averaged results of some measurements on a map.
Right now, I'm using Leaflet to draw the map with MapQuest/OpenStreetMap tiles, and have the measurements in a postgres+postGIS database, associated to a geography data type that contains a single point, representing where the measurements were performed.
I was planning on processing that data according to some criteria in order to display a simplified form of it, instead of just showing the raw measurements; the issue is: how the hell am I going to know how to draw these results?
The current solution I was thinking of was dividing the Earth into a grid of (for now, 500x500m) squares, and just matching the raw measurements to one of those squares. However, I feel like this solution has some issues:
1) I'd have to use a projection that's in meters, right? It'd probably be Google's Web Mercator, considering I'm using a mapping API. However, the measurements are in WGS 84: wouldn't converting back and forth waste lots of processing power? Furthermore, is Google's projection even the right choice?
2) How can I figure out the correct square to place things in? Is there an effective postGIS solution? I was thinking dividing (with integer division) the maximum latitude/longitude of the projection by the point's lat/long would give me the index of the square, but is that an effective way to do it?
3) Can leaflet (or other mapping APIs, I can switch if necessary) get its points drawn in an SRID that's not WGS 84, or would I have to perform an ST_Transform for every single grid square I want to draw?
Finally, the entire idea might be a terrible way to go about solving this problem. If so, please tell me I'm an idiot! :)
Aucun commentaire:
Enregistrer un commentaire