doctrine2空间如何使用多重限制类型



我正在使用Symfony 4和Doctrine2 Spatial。文档配置指南中写道:

将所需的类型和函数添加到Symfony配置文件中。条令类型名称不是硬编码的。">

还有一个例子:

doctrine:
dbal:
types:
geometry:   CrEOFSpatialDBALTypesGeometryType
point:      CrEOFSpatialDBALTypesGeometryPointType
polygon:    CrEOFSpatialDBALTypesGeometryPolygonType
linestring: CrEOFSpatialDBALTypesGeometryLineStringType

我需要使用MultiLineString类型,但CrEOFSpatialDBALTypesGeometry目录中没有这样的类型类。我已经将MultiLineStringType(LineStringType类的副本(添加到我的AppDoctrine目录中,并在条令配置中添加了一行,如下所示:

multilinestring: AppDoctrineMultiLineStringType

然后在我的控制器中,我执行以下操作:

$parser = new CrEOFGeoWKTParser($multilinestring);
$geo = $parser->parse();
$path = new CrEOFSpatialPHPTypesGeometryMultiLineString($geo['value']);
$route->setPath($path); // The multilinestring field type

但当我坚持我的学说实体时,我得到了一个例外

Geometry列值必须实现GeometryInterface

请帮帮我。我做错了什么?文件很差。。。

UPD:如果我通过本机SQL查询放入多限制数据,如下所示:

UPDATE Routes SET Path=PolyFromText(MULTILINESTRING (....)) WHERE Id=1

然后通过ORM$entity->getPath()获取数据,得到一个正常的CCD_。所以我想问题出在我的控制器上,我试图设置MultiLineString对象。

您可以更改:

doctrine:
dbal:
types:
geometry:   CrEOFSpatialDBALTypesGeometryType
point:      CrEOFSpatialDBALTypesGeometryPointType
polygon:    CrEOFSpatialDBALTypesGeometryPolygonType
linestring: CrEOFSpatialDBALTypesGeometryLineStringType

进入这个:

doctrine:
dbal:
types:
geometry:        CrEOFSpatialDBALTypesGeometryType
point:           CrEOFSpatialDBALTypesGeometryPointType
polygon:         CrEOFSpatialDBALTypesGeometryPolygonType
linestring:      CrEOFSpatialDBALTypesGeometryLineStringType
multilinestring: CrEOFSpatialDBALTypesGeometryMultiLineStringType

最新更新