fix: expose lat/lng from CoastalPoint, fix getCoords in map

This commit is contained in:
Gwadaking
2026-04-01 22:37:14 -04:00
parent 15079ea7b4
commit 1485339aec
2 changed files with 22 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ class CoastalPoint
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
#[Groups(['spot:read'])]
private ?Uuid $id = null;
#[ORM\Column(length: 150)]
@@ -38,7 +39,6 @@ class CoastalPoint
private ?string $name = null;
#[ORM\Column(type: 'geometry', options: ['geometry_type' => 'POINT', 'srid' => 4326])]
#[Groups(['spot:read'])]
private mixed $geometry = null;
#[ORM\Column(length: 30)]
@@ -66,6 +66,22 @@ class CoastalPoint
public function setName(string $name): static { $this->name = $name; return $this; }
public function getGeometry(): mixed { return $this->geometry; }
public function setGeometry(mixed $geometry): static { $this->geometry = $geometry; return $this; }
#[Groups(['spot:read'])]
public function getLongitude(): ?float
{
if ($this->geometry === null) return null;
preg_match('/POINT\(([^ ]+) /', (string) $this->geometry, $m);
return isset($m[1]) ? (float) $m[1] : null;
}
#[Groups(['spot:read'])]
public function getLatitude(): ?float
{
if ($this->geometry === null) return null;
preg_match('/POINT\([^ ]+ ([^)]+)\)/', (string) $this->geometry, $m);
return isset($m[1]) ? (float) $m[1] : null;
}
public function getType(): ?string { return $this->type; }
public function setType(string $type): static { $this->type = $type; return $this; }
public function getRegion(): ?string { return $this->region; }