html5 canvas:服务器或客户端从经纬度快速转换为像素值
我正在使用 html5 canvas 元素制作一些地图和动画(示例 在此处可见 .)我希望能够基于画布的几何形状有效地生成像素值线串(x1、y1、x2、y2),最好是从 PostGIS 生成。也就是说,在伪 geojson 中:
"Coordinates":"[[-122.0, 35.0], [-121.0, 36.0]]"
在函数传递 100px canvas-width 的情况下可能会输出参数:
"Pixels":"[[30, 40],[50,60]]"
我想最终启用如下网址:
www.example.com/canvas_size:200/ box_width:3-miles/center_point:lon|lat
所以我认为这必须动态完成。其他人是如何处理这种事情的?我突然想到,也许可以将整个世界视为一个 20,000,000 像素的画布,以像素形式存储预转换的数据,然后用客户端算术对其进行偏移。欢迎提出任何建议,包括远离我最初想法的方法。如果有人熟悉卡塔根是否或如何完成此操作,将不胜感激指向一个库或函数或两个的指针。
I am working on some maps and animations using the html5 canvas element (example visible here.) I would like to be able to efficiently generate pixel-valued linestrings (x1, y1, x2, y2), ideally from PostGIS, based on the geometry of the canvas. That is, in pseudo-geojson:
"Coordinates":"[[-122.0, 35.0], [-121.0, 36.0]]"
might output in the case of a function passed a 100px canvas-width parameter:
"Pixels":"[[30, 40],[50,60]]"
I would like to eventually enable urls like:
www.example.com/canvas_size:200/box_width:3-miles/center_point:lon|lat
so I assume this has to be done dynamically. How have other people tackled this kind of thing? It has occurred to me is to maybe treat the entire world as a 20,000,000 pixel canvas, store pre-transformed data in pixel form, then just offset it with client-side arithmetic. Any suggestions welcome, including approaches far afield of my first thoughts. If anyone is familiar with if or how this is done in Cartagen, would appreciate a pointer to a library or function or two.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下代码,其中像素将适应画布的高度和宽度:
Try this code where the pixels will adapt to the height and width of the canvas: