Revert "Save cooridnates as GeoJSON in database"
This reverts commit ddb815d1b4
.
This commit is contained in:
parent
34088972f8
commit
5c25b036a4
5 changed files with 2 additions and 130 deletions
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20210715135559 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE offering ADD coordinates TEXT DEFAULT NULL');
|
||||
$this->addSql('COMMENT ON COLUMN offering.coordinates IS \'(DC2Type:array)\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE offering DROP coordinates');
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20210715142350 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE offering ADD coordinate JSON DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE offering DROP coordinates');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE offering ADD coordinates TEXT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE offering DROP coordinate');
|
||||
$this->addSql('COMMENT ON COLUMN offering.coordinates IS \'(DC2Type:array)\'');
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20210715142732 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE offering ALTER coordinate TYPE TEXT');
|
||||
$this->addSql('ALTER TABLE offering ALTER coordinate DROP DEFAULT');
|
||||
$this->addSql('COMMENT ON COLUMN offering.coordinate IS \'(DC2Type:object)\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE offering ALTER coordinate TYPE JSON');
|
||||
$this->addSql('ALTER TABLE offering ALTER coordinate DROP DEFAULT');
|
||||
$this->addSql('COMMENT ON COLUMN offering.coordinate IS NULL');
|
||||
}
|
||||
}
|
|
@ -13,8 +13,6 @@ use App\Service\DistanceCalculator;
|
|||
use App\Service\OfferPhotoHelper;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Location\Coordinate;
|
||||
use Location\Formatter\Coordinate\GeoJSON;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -40,7 +38,7 @@ class OfferController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/new', name: 'new_offer')]
|
||||
public function newOffer(Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper, PlzToCoordinate $plzconverter): Response
|
||||
public function newOffer(Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response
|
||||
{
|
||||
$offer = new Offering();
|
||||
$form = $this->createForm(OfferingFormType::class, $offer);
|
||||
|
@ -52,11 +50,6 @@ class OfferController extends AbstractController
|
|||
$offer->setByUser($user);
|
||||
$offer->setCreatedAt(new \DateTime());
|
||||
|
||||
if ($offerPlz = $form['zipCode']->getData()) {
|
||||
$coordinate = $plzconverter->convertPlzToCoordinate($offerPlz);
|
||||
$offer->setCoordinate($coordinate->format(new GeoJSON()));
|
||||
}
|
||||
|
||||
if ($photo = $form['photo']->getData()) {
|
||||
$offerPhotoHelper->uploadOfferPhoto($photoDir, $photo, $offer);
|
||||
}
|
||||
|
@ -88,7 +81,7 @@ class OfferController extends AbstractController
|
|||
|
||||
if (isset($userPlz))
|
||||
{
|
||||
$distance = $distanceCalculator->calculateDistance($plzconverter->convertPlzToCoordinate($offerPlz), $plzconverter->convertPlzToCoordinate($userPlz));
|
||||
$distance = $distanceCalculator->calculateDistance($plzconverter->getCoordinates($offerPlz), $plzconverter->getCoordinates($userPlz));
|
||||
}
|
||||
|
||||
return $this->render('app/offer.html.twig', [
|
||||
|
|
|
@ -51,11 +51,6 @@ class Offering
|
|||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="object", nullable=true)
|
||||
*/
|
||||
private $coordinate;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -137,16 +132,4 @@ class Offering
|
|||
{
|
||||
return (string) $this-getTitle();
|
||||
}
|
||||
|
||||
public function getCoordinate()
|
||||
{
|
||||
return $this->coordinate;
|
||||
}
|
||||
|
||||
public function setCoordinate($coordinate): self
|
||||
{
|
||||
$this->coordinate = $coordinate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue