42 lines
956 B
PHP
42 lines
956 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 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);
|
|
}
|
|
}
|