将新几何图形添加到 Neo4J 中的 osm 文件 [英] Add new Geometries to an osm file in Neo4J

查看:73
本文介绍了将新几何图形添加到 Neo4J 中的 osm 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些餐馆添加到 importet .osm 文件中.所以我想将餐厅保存为新的点几何并将它们在正确的点与现有的 osm 图连接起来.后来我想读出所有餐厅的信息,并从任何给定点找到最近的餐厅.那么我应该在新图层中添加餐厅吗?有没有一种简单的方法可以将餐厅与正确地理点的图形联系起来?

Hi im trying to add some restaurants to an importet .osm file. So I want to save the restaurants as new Point Geometries and connect them at the right point with the existing osm graph. Later I want to read out all resturants and find the nearest restaurant from any given point. So should I add the restaurants in a new layer? And is there an easy way to connect the restaurants with the graph at the right geogaphical point??

感谢解答

问候

推荐答案

有两个选项:

  • 编辑现有的 OSM 模型(不是微不足道的)
  • 添加一个新层

由于 OSM 编辑很复杂,我将在最后回答.更简单的选择是添加一个新层.在这种情况下,您可以使用 SimplePointLayer,因为您只使用点.只需使用工厂方法创建一个 SpatialDatabaseService.createSimplePointLayer(String name).这将允许您将单个节点存储为具有纬度/经度属性和您想要的任何其他属性(餐厅名称等)的 Point 对象.然后查询 OSM 层(不是点层)的索引以获取附近的几何图形.然后,您可以通过使用您自己的关系将新层的 Point 节点连接到 OSM 层的 Geometry 节点,从而保持餐厅的附近"性.然后,您从 OSM 搜索以查找餐厅需要沿着您的新关系从 OSM 图遍历.

Since the OSM editing is complex, I will answer that last. The easier option is to add a new layer. In this case you could use a SimplePointLayer, since you are only working with points. Just create one with the factory method SpatialDatabaseService.createSimplePointLayer(String name). This will allow you to store single nodes as Point objects with lat/lon attributes and any other attributes you want (restaurant name, etc.). Then query the index of the OSM layer (not the point layer) for nearby Geometries. You can then get fancy by connecting the Point nodes of your new layer to the Geometry nodes of the OSM layer with your own relationships, persisting the 'nearby'ness of the restaurant. Then your searches from OSM to find restaurants would need to traverse from the OSM graph along your new relationships.

另一个选项,今天编辑 OSM 模型并非易事.问题是您需要找到您希望编辑的 OSM 模型部分,然后对其应用更改.这不是为您完成的,需要了解 OSM 图结构.例如,如果您简单地导入一个 OSM 文件,然后使用与导入 OSM 相同的层对象,向该层添加一个点几何图形,该几何图形将作为自由浮点添加,连接到 Rtree,但不到 OSM 模型的其余部分.

The other option, editing the OSM model is not trivial today. The issue being that you need to find the part of the OSM model that you wish to edit and then apply changes to that. This is not done for you and requires knowledge of the OSM graph structure. For example, if you simply import an OSM file and then using the same layer object that the OSM was imported to, add a Point geometry to that layer, the geometry will be added as a free floating point, connected to the Rtree, but not to the rest of the OSM model.

如果您的点已经是 OSM 图中的现有节点,那么最好的选择是找到该节点并对其进行编辑.如果它已经是一个点几何,那么您只需更改 OSM 节点的属性(特征的)或标签.如果它不是点几何体,而只是一个方式的节点,那么您需要将其升级为点几何体并将其添加到索引中.这种升级"可以通过添加一个新节点来完成,称为具有正确属性的geom"节点,并将其添加到 RTree.请参阅 OSMImporter.java 中的示例代码,位于 https://github.com/neo4j/spatial/blob/f473a2e20f8f5392e211470e8fdc472bcf800e2d/src/main/java/org/neo4j/gis/spatial/osm.javaLm1

If your point is already an existing node in the OSM graph, then the best option is to find that node and edit it. If it is already a Point geometry, then you will simply be changing attributes (of the Feature) or tags of the OSM node. If it is not a Point geometry, but simply a node of a way, then you would need to upgrade it to being a Point geometry and add it to the index. This 'upgrade' can be done by adding a new node, called a 'geom' node with the right attributes, and adding that to the RTree. See example code in the OSMImporter.java at https://github.com/neo4j/spatial/blob/f473a2e20f8f5392e211470e8fdc472bcf800e2d/src/main/java/org/neo4j/gis/spatial/osm/OSMImporter.java#L1097.

这让我们回到了首先在 OSM 模型中找到节点的问题.如果您从要添加的位置开始,则可以简单搜索附近的几何图形,然后遍历这些几何图形以找到要编辑的点.如果您发现没有这样的现有点,则需要决定如何添加它.今天在 OSM 图中插入一个新点是使用可视化工具(如 JOSM、iD 或 Potlatch,参见 http://wiki.openstreetmap.org/wiki/Editing).在代码中执行此操作将更具挑战性.也许您可以确定您的点是否在现有方式上(足够靠近连接两个现有节点的边缘),然后您可以将其插入链中.这听起来既复杂又冒险,所以我建议不要这样做.它还需要对 Neo4j Spatial 中当前的 OSM 模型有更深入的了解,这有点复杂.

This get's us back to the question of finding the node in the OSM model in the first place. If you are starting with the location you want to add, then you could do a simple search for nearby Geometries, and traverse those to find the point that you want to edit. If you find no such existing point, you need to take a decision on how to add it. Inserting a new point into the OSM graph today is done using visual tools (like JOSM, iD or Potlatch, see http://wiki.openstreetmap.org/wiki/Editing). To do this in code would be more challenging. Perhaps you could work out if your point was on an existing way (close enough to the edge joining two existing nodes), and you could insert it into the chain. This sounds complex and risky, so I'd advise against it. It also requires a deeper knowledge of the current OSM model in Neo4j Spatial, which is somewhat complex.

这篇关于将新几何图形添加到 Neo4J 中的 osm 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆