从谷歌地图数据或其他地图 API 创建街区叠加层
我的问题如下:如何抓取城市中的“方块”以在游戏中使用? (然后将它们显示为某种颜色的阴影?)
我的总体想法是在游戏中使用您城市的真实街区,您可以拥有/出售它们。
我想在谷歌地图中将您拥有的区域显示为多边形叠加层。
谷歌地图是前进的方向,还是像 OpenStreetMap 等其他 API 对此更有用?
任何指针都将受到赞赏,例如要获取哪些数据以及如何从中构造“块”的通用算法,或者可以为我返回块/房屋级别多边形的 API 调用。
My question is the following: How can I grab 'blocks' in a city for use in a game? (And then display them shaded in a certain color?)
My general idea is to use real blocks of your city in a game, that you can own/sell.
I want to display the areas you own as polygon overlays in google maps.
Are google maps the way forward, or are other APIs like OpenStreetMap, etc, more useful for this?
Any pointers would be appreciated, like general algorithms of what data to grab and how to construct 'blocks' out of it, or API calls that could return a block/house level polygon for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来很难,主要是因为你很难一致地定义街区是什么——一条街道的一侧,还是四条街道围成的矩形?如果不是长方形怎么办? OpenStreetMap 数据可能
是您最好的选择,因为您实际上可以通过 OSM Export 或 Cloudmade 提取(按区域)。
您可能会考虑另一种方法(即让用户定义自己的多边形)或让用户拥有街道(使用 OSM 数据更容易做到)。
还有商业上可用的地块数据集,可以为您提供城市的属性级别视图。这些可能非常昂贵。
Sounds hard, mostly because you'll have a hard time consistently defining what a block is -- one side of one street, or the rectangle enclosed by four streets? What if it's not a rectangle? Etc.
OpenStreetMap data is probably your best bet, because you can actually download the data -- via OSM Export or Cloudmade extract by region.
You might consider another approach (i.e. letting users define their own polygons) or letting users own streets (which would be easier to do with OSM data).
There are also commercially available parcel datasets which will give you a property-level view of a city. These can be very expensive.
我最近不得不处理这个问题。我最终在 Objective-C 中创建了一个库,它基本上分析了 OSM 街道数据和 OSM 建筑足迹数据的组合,以找出“块”的概念,其中的概念是,“块”是一个多边形区域,它具有它内有建筑物,并且有一个多边形的交叉街道包围它。它并不适用于所有情况(例如没有建筑物足迹数据的街区),但对于城市来说,它在确定街区方面效果很好。
另一种方法(但据我所知 OSM 不支持)是直接从市政府获取块多边形数据,但这并不是特别可扩展,除非您的要求仅适用于少数给定的区域设置。有些城市不公布这些数据。
I recently had to deal with this issue. I ended up creating a library in objective-c which basically analyzes a combination of OSM street data and OSM building footprint data to figure out the concept of a "block", where the notion is, a "block" is a polygonal region that has buildings within it and which has a polygon of intersecting streets encompassing it. It doesn't work for all situations (like blocks with no buildings footprint data), but for cities, it works nicely in determining blocks.
Another approach, but not supported by OSM to my knowledge, is to get block polygon data directly from the city government, but that's not particularly scalable unless your requirement is only for a few given locales. And some cities don't publish that data.