Answer the question
In order to leave comments, you need to log in
How to get 2 fields from the database by applying postgis-sql functions to them that refer to one column in the database?
I have some field in the database with geometry, which I want to pull out in 2 versions - in geojson, and as text, but the @ORM\Column annotation does not allow accessing the same field twice inside the Entity.
Those. the request should be something like this:
SELECT st_asgeojson(geometry) as geojson, st_astext(geometry) as geom_text, ... from tablename;
/**
* @ORM\Column(type="geojson", options={"geometry_type"="MULTIPOLYGON", "srid"=3857})
* @Groups({"GetTerritory", "CreateTerritory", "UpdateTerritory"})
*/
private ?string $geom;
/**
* @ORM\Column(name="geom", type="geojson", options={"geometry_type"="MULTIPOLYGON", "srid"=3857})
* @Groups({"GetTerritory", "CreateTerritory", "UpdateTerritory"})
* @SerializedName("geom_text")
*/
private ?string $geomAsText;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question