Phase 0 : entités, migrations, API Platform, PostGIS
- API Platform + Doctrine ORM + jsor/doctrine-postgis installés - 6 entités Symfony (SargassumObservation, SargassumForecast, DataIngestionJob, CoastalPoint, ImpactScore, UserFeedback) - Migration initiale manuelle avec CREATE EXTENSION postgis, toutes les tables, index GIST et BTREE - doctrine.yaml configuré pour PostgreSQL 16 + types PostGIS - Roadmap Phase 0 complète Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
105
backend/src/Entity/SargassumObservation.php
Normal file
105
backend/src/Entity/SargassumObservation.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\SargassumObservationRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Jsor\Doctrine\PostGIS\Types\PostGISType;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SargassumObservationRepository::class)]
|
||||
#[ORM\Index(columns: ['detected_at'], name: 'idx_observation_detected_at')]
|
||||
#[ORM\Index(columns: ['source'], name: 'idx_observation_source')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(),
|
||||
new Get(),
|
||||
]
|
||||
)]
|
||||
class SargassumObservation
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(type: 'geometry', options: ['geometry_type' => 'MULTIPOLYGON', 'srid' => 4326])]
|
||||
private mixed $geometry = null;
|
||||
|
||||
#[ORM\Column(type: 'geometry', nullable: true, options: ['geometry_type' => 'POLYGON', 'srid' => 4326])]
|
||||
private mixed $bbox = null;
|
||||
|
||||
#[ORM\Column(immutable: true)]
|
||||
private ?\DateTimeImmutable $detectedAt = null;
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
private ?string $source = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
private ?string $tileId = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?float $cloudCoverage = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?float $confidence = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?float $afaiMean = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?float $afaiStd = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?float $coverageArea = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true)]
|
||||
private ?string $processingVersion = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: SargassumForecast::class, mappedBy: 'sourceObservation')]
|
||||
private Collection $forecasts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->forecasts = new ArrayCollection();
|
||||
$this->createdAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid { return $this->id; }
|
||||
public function getGeometry(): mixed { return $this->geometry; }
|
||||
public function setGeometry(mixed $geometry): static { $this->geometry = $geometry; return $this; }
|
||||
public function getBbox(): mixed { return $this->bbox; }
|
||||
public function setBbox(mixed $bbox): static { $this->bbox = $bbox; return $this; }
|
||||
public function getDetectedAt(): ?\DateTimeImmutable { return $this->detectedAt; }
|
||||
public function setDetectedAt(\DateTimeImmutable $detectedAt): static { $this->detectedAt = $detectedAt; return $this; }
|
||||
public function getSource(): ?string { return $this->source; }
|
||||
public function setSource(string $source): static { $this->source = $source; return $this; }
|
||||
public function getTileId(): ?string { return $this->tileId; }
|
||||
public function setTileId(string $tileId): static { $this->tileId = $tileId; return $this; }
|
||||
public function getCloudCoverage(): ?float { return $this->cloudCoverage; }
|
||||
public function setCloudCoverage(float $cloudCoverage): static { $this->cloudCoverage = $cloudCoverage; return $this; }
|
||||
public function getConfidence(): ?float { return $this->confidence; }
|
||||
public function setConfidence(float $confidence): static { $this->confidence = $confidence; return $this; }
|
||||
public function getAfaiMean(): ?float { return $this->afaiMean; }
|
||||
public function setAfaiMean(float $afaiMean): static { $this->afaiMean = $afaiMean; return $this; }
|
||||
public function getAfaiStd(): ?float { return $this->afaiStd; }
|
||||
public function setAfaiStd(float $afaiStd): static { $this->afaiStd = $afaiStd; return $this; }
|
||||
public function getCoverageArea(): ?float { return $this->coverageArea; }
|
||||
public function setCoverageArea(?float $coverageArea): static { $this->coverageArea = $coverageArea; return $this; }
|
||||
public function getProcessingVersion(): ?string { return $this->processingVersion; }
|
||||
public function setProcessingVersion(?string $processingVersion): static { $this->processingVersion = $processingVersion; return $this; }
|
||||
public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; }
|
||||
|
||||
/** @return Collection<int, SargassumForecast> */
|
||||
public function getForecasts(): Collection { return $this->forecasts; }
|
||||
}
|
||||
Reference in New Issue
Block a user