动态生成地图
我希望生成类似于标志性伦敦地铁地图的交通地图。
这些地图会不时发生变化,并且需要很多地图,因此我希望从数据库或数据集中动态生成它们,而不是在 inkscape [或类似的] 中手动绘制它们。
有谁知道是否有任何库 API 等可以帮助完成此任务,或者有任何关于如何[或如何不]执行此任务的一般建议?
我认为 svg 是最好的方式,而且可能还需要基本的交互性。
我正在 php 中工作,否则它是 GDlib、ImageMagick 吗?
提前致谢。
.k
I am looking to generate transport maps in a style similar to the iconic London underground [tube] map.
These maps will change from time to time and many will be required so instead of drawing them up manually in inkscape [or similar] I am hoping to have them generated dynamically from a db or dataset.
Does anyone know if there is any library apis etc. out there that would help with this task, or any suggestions in general of how [or how not] to go about this ?
I am thinking svg's would be the best way to go with this, plus there may be need for basic interactivity down the line.
I am working in php so otherwise it's GDlib, ImageMagick ?
Thanks in advance.
.k
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯,答案实际上不在于如何使用 GD 或 ImageMagick,有相关手册。至于辅助库,大多数库都专注于图形,其他任何东西你都必须自己编写。作为解决方案,最好的选择是让管理界面在后端数据更改时生成图像并缓存图像,因为没有理由每次有人访问图像时都构建图像。
为了生成地图,我认为最好的选择是用一条或多条“线”定义站点,这些“线”确定与周围站点的某种关系的指标,以及 x,y。您可能只需要确定一个“父”站,因为您只是从 ab 开始绘制线条。这样,您就可以按照与实际火车上通常渲染的方式相同的方式放置它们,使用线路和周围的车站来绘制地图。
听起来并不是一个太难的问题。 3 个表:
SVG 非常擅长这类事情,并且您可以避免整个图像构建和缓存过程,但要警惕浏览器支持问题。
听起来是一个非常有趣的项目,祝你好运:)
Well, the answer really isnt in how to use GD or ImageMagick, there are manuals for that. As for helper libraries, most libraries focus on graphing, anything else you will have to write yourself. Your best bet as a solution would be to have your admin interface generate the images when data in the backend changes and cache the images, since there's no reason to build the image every time someone accesses it.
For generating maps, i think your best bet would be defining stations with one or many 'lines' which determine some sort of indicator of relationship to the stations around, and an x,y. You'd probably only need to determine a 'parent' station since you're just drawing lines from a-b. That way you can position them in the same manner as they're typically rendered on the actual trains, use the lines and surrounding stations to draw mappings.
Doesn't sound like too difficult a problem. 3 tables:
SVG would be pretty good at this sort of thing, and you would avoid the whole image building and caching process, but be wary of browser support issues.
Sounds like a pretty interesting project though, good luck :)
当我需要从数据库中的数据生成图形时,我使用的一种策略是以某种 XML 方式提取数据(例如 Oracle SQLX 或 Cocoon XSP/ESQL 或 eXist-db XQuery)并通过 XSLT 处理它以生成 SVG 。如果您不想编写任何代码(当然 XSL 除外;-),那么旧的 Cocoon 就适合这种工作。
SVG本身可以加载到一些图形工具中进行重新处理。
One strategy I use when I need to generate graphs from data in a db is to extract the data in some kind of XML way (e.g. Oracle SQLX or Cocoon XSP/ESQL or eXist-db XQuery) and process it through an XSLT to generate SVG. Good old Cocoon is fine for this kind of job if you don't want to write any code (except the XSL of course ;-).
The SVG itself can be loaded in some graphic tools to reprocess.
如果我处于您的立场,我要做的第一件事就是尝试证明 Google Maps API 不适用于您的应用程序。然后,也许可以证明 ArcGIS 不起作用。 (即使它们不起作用,它们也被广泛使用,你可以在你的简历中添加行。)
If I were in your shoes, the very first thing I'd do is try to prove that the Google Maps API won't work for your application. Then, maybe, prove that ArcGIS won't work. (Even if they don't work, they're widely used, and you get to add lines to your CV.)