creof / doctrine2-spatial

Doctrine2 multi-platform support for spatial types and functions.
MIT License
272 stars 176 forks source link

Assigning EWKT to type #188

Open yurtesen opened 6 years ago

yurtesen commented 6 years ago

If I have a 'geopoint' column, but I access it using SQL with something like SELECT ST_AsEWKT(coords) as coords and I will get the EWKT text, how can I parese it to a Point() object?

I came up with something like below, but I am guessing this is not the right way?:

    $sql = "SELECT st.id,st.name,ST_AsEWKT(coords) as coords FROM store st LIMIT 1";
    $conn = $this->getEntityManager()->getConnection();
    $stmt = $conn->prepare($sql);
    $stmt->execute();
    $result = $stmt->fetchAll();
    $parser = new PostgreSql();
    $point = $parser->convertStringToPHPValue(AbstractSpatialType::getType('geopoint'),$result[0]['coords']);