弹簧数据neo4j空间处理多边形
你好 我想在更大范围内处理建筑几何图形。为此,我将从各种来源(也包括shp文件)将几何体数据导入使用spring-data-neo4j的嵌入式neo4j数据库。到目前为止还不错 我被困的地方: 在我的领域中,我定义了一个弹簧数据neo4j空间处理多边形,neo4j,cypher,polygon,spring-data-neo4j,neo4j-spatial,Neo4j,Cypher,Polygon,Spring Data Neo4j,Neo4j Spatial,你好 我想在更大范围内处理建筑几何图形。为此,我将从各种来源(也包括shp文件)将几何体数据导入使用spring-data-neo4j的嵌入式neo4j数据库。到目前为止还不错 我被困的地方: 在我的领域中,我定义了一个建筑实体,该实体具有一个多边形wkt 是否可以通过crudepository创建具有多边形属性的节点 使用点就可以了:例如 @NodeEntity public class Building implements Serializable{ @GraphId pr
建筑
实体,该实体具有一个多边形wkt代码>
是否可以通过crudepository
创建具有多边形
属性的节点
使用点
就可以了:例如
@NodeEntity
public class Building implements Serializable{
@GraphId
private Long id;
@Indexed(indexType = IndexType.POINT, indexName = "building_wkt_index", unique = false)
private Point wkt;
}
public interface BuildingRepository extends GraphRepository<Building>, SpatialRepository<Building>{
/**
* CRUD
*/
}
Building b = new Building();
b.setWkt(new Point(12,12));
buildingService.save(b);
并调用存储库的save()。
然而,这似乎不起作用。wkt未存储,它为空
是否有可能在我的建筑中使用这个命名索引(甚至可能),或者将所有事务移到neo4j spatial插件的其余部分真的是唯一的方法吗
例如,是否可以实现新的索引类型
?
非常感谢所有的投入 对于任何对可能的解决方案感兴趣的人:
首先,我手动创建一个空间索引:
template.getGraphDatabaseService().index().forNodes("your_spatial_index", MapUtil.stringMap(
IndexManager.PROVIDER, "spatial", "geometry_type","polygon","wkt", "wkt"));
Transaction tx = template.getGraphDatabase().beginTx();
Node n = template.getNode(b.getId());
template.getGraphDatabase().getIndex("your_spatial_index").add(n,"id",b.getId());
tx.success();
tx.close();
在域实体中,wkt存储为字符串:
String wkt;
然后,我将存储库访问权移动到一个服务。
保存新节点时,将手动将此节点添加到空间索引:
template.getGraphDatabaseService().index().forNodes("your_spatial_index", MapUtil.stringMap(
IndexManager.PROVIDER, "spatial", "geometry_type","polygon","wkt", "wkt"));
Transaction tx = template.getGraphDatabase().beginTx();
Node n = template.getNode(b.getId());
template.getGraphDatabase().getIndex("your_spatial_index").add(n,"id",b.getId());
tx.success();
tx.close();
至少,这是将多边形wkt添加到R树的快速修复方法。
但是,必须手动处理索引节点的更新和删除。您好,请共享您的pom.xml版本的neo4j和neo4j spatial插件。我无法将GraphRespository和SpatialRepository导入到我的项目中。