I'm using Symfony 4 and Doctrine2-Spatial. The documentation configuration guide says:
Add the types and functions you need to your Symfony configuration file. The doctrine type names are not hardcoded."
And there is an example:
doctrine:
dbal:
types:
geometry: CrEOF\Spatial\DBAL\Types\GeometryType
point: CrEOF\Spatial\DBAL\Types\Geometry\PointType
polygon: CrEOF\Spatial\DBAL\Types\Geometry\PolygonType
linestring: CrEOF\Spatial\DBAL\Types\Geometry\LineStringType
I need to use MultiLineString type, but there is no such type class in CrEOF\Spatial\DBAL\Types\Geometry\
directory. I've added MultiLineStringType (copy of LineStringType class) to my App\Doctrine
directory and added a line to doctrine config like this:
multilinestring: App\Doctrine\MultiLineStringType
Then in my controller I do the following:
$parser = new \CrEOF\Geo\WKT\Parser($multilinestring);
$geo = $parser->parse();
$path = new \CrEOF\Spatial\PHP\Types\Geometry\MultiLineString($geo['value']);
$route->setPath($path); // The multilinestring field type
But then when I persist my doctrine entity, I got an exception
Geometry column values must implement GeometryInterface
Please help me. What am I doing wrong? The documentation is very poor...
UPD: If I put multilinestring data by native SQL query like this:
UPDATE Routes SET Path=PolyFromText(MULTILINESTRING (....)) WHERE Id=1
and then get data via ORM $entity->getPath()
I got a normal CrEOF\Spatial\PHP\Types\Geometry\MultiLineString
object. So I guess the problem is in my Controller where I trying to set MultiLineString object.