Obvody/app/Presentation/Home/HomePresenter.php

47 lines
1014 B
PHP

<?php
declare(strict_types=1);
namespace App\Presentation\Home;
use Nette;
use Nette\Utils\Json;
use Nette\Utils\FileSystem;
final class HomePresenter extends Nette\Application\UI\Presenter
{
public function __construct(
) {
}
public function beforeRender(): void
{
}
public function renderDefault(int $obvod = null): void
{
try {
// načti seznam obvodů:
$content = FileSystem::read('../www/data/geo-obvody.geojson');
// dekóduj geo-json:
$geoObvody = Json::decode($content, true);
} catch (Nette\Utils\JsonException $e) {
// Ošetření výjimky
}
if (empty($geoObvody))
return;
$obvody = array();
foreach ($geoObvody["features"] as $o) {
$obvody[] = $o["properties"]["number"];
}
asort($obvody);
$this->template->obvody = $obvody;
bdump($geoObvody["features"]);
bdump($obvody);
}
}