如何在Grakn中定义多边形



我想在Grakn中为物理对象建模。将物理对象建模为点或矩形非常简单:

define
length sub attribute,
value double;
position sub attribute,
value double;
lon sub position;
lat sub position;
elevation sub position;
width sub length;
depth sub length;
height sub length;

physical_object sub entity,
has lon,
has lat,
has elevation,
has width,
has depth,
has height;

对于一个点,简单地将宽度、深度和高度留空。

然而,我正在为如何为多边形的物理对象建模而苦恼,即连接线的列表。如何在Grakn中优雅地建模?

考虑到世界中并非每个physical_object都有宽度、深度和高度,也许我们可以从高级定义中删除这些属性?

physical_object sub entity,
has lon,
has lat,
has elevation;

矩形可以是

rect sub physical_object,
has width,
has depth,
has height;

然后你可以定义像这样的点

point sub physical_object,
plays edge-point_point;

并且边缘将是2点

edge-point sub relation,
relates edge-point_point,
relates edge-point_edge;
edge sub entity,
has length,
plays edge-point_edge;

之后,多边形可以表示为

polygon sub physical_object,
has edge; // here it can be multiple edges, we don't have cardinality constraints yet

但通过这种方式,多边形可以是一组未连接的边,您可以根据您想要如何使用它来不同地定义多边形

大多数空间图数据库(和CAD程序(将其数据存储为基元数组,以便于描述任何可能的形状。这些数据库还允许在这样的阵列上以本机方式执行交集/并集。如果只是为了能够从这些系统导入/导出到这些系统中,那么您可能希望遵循该模式。以下是一个示例:https://docs.oracle.com/database/121/SPATL/simple-example-inserting-indexing-and-querying-spatial-data.htm#SPATL486

因此,GRAKN社区的问题也许应该是:如何最好地为基元数组建模?

第页。S.在混合中加入时间性会让它变得更有趣/更具挑战性!

最新更新