|
@ -6,6 +6,7 @@ use App\Form\CityToolType; |
|
|
use App\Form\OsmoseToolType; |
|
|
use App\Form\OsmoseToolType; |
|
|
use App\Service\OsmoseClient; |
|
|
use App\Service\OsmoseClient; |
|
|
use App\Service\OverpassClient; |
|
|
use App\Service\OverpassClient; |
|
|
|
|
|
use Psr\Log\LoggerInterface; |
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
|
|
use Symfony\Component\HttpFoundation\HeaderUtils; |
|
|
use Symfony\Component\HttpFoundation\HeaderUtils; |
|
@ -97,6 +98,7 @@ class ToolsController extends AbstractController |
|
|
Request $request, |
|
|
Request $request, |
|
|
OsmoseClient $osmose, |
|
|
OsmoseClient $osmose, |
|
|
OverpassClient $overpass, |
|
|
OverpassClient $overpass, |
|
|
|
|
|
LoggerInterface $logger |
|
|
): Response { |
|
|
): Response { |
|
|
$form = $this->createForm(OsmoseToolType::class, array_merge(['limit' => 500], $request->query->all())); |
|
|
$form = $this->createForm(OsmoseToolType::class, array_merge(['limit' => 500], $request->query->all())); |
|
|
$form->add('submit', SubmitType::class, ['label' => 'Générer']); |
|
|
$form->add('submit', SubmitType::class, ['label' => 'Générer']); |
|
@ -126,6 +128,10 @@ class ToolsController extends AbstractController |
|
|
|
|
|
|
|
|
$issuesGeojson = \GeoJson\GeoJson::jsonUnserialize(json_decode($issues, true)); |
|
|
$issuesGeojson = \GeoJson\GeoJson::jsonUnserialize(json_decode($issues, true)); |
|
|
|
|
|
|
|
|
|
|
|
$logger->debug(__METHOD__.' osmose issues', [ |
|
|
|
|
|
count($issuesGeojson->getFeatures()), |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
$groupByCity = (bool) $form->get('group_by_city')->getData(); |
|
|
$groupByCity = (bool) $form->get('group_by_city')->getData(); |
|
|
if ($groupByCity) { |
|
|
if ($groupByCity) { |
|
|
$minLat = null; |
|
|
$minLat = null; |
|
@ -154,6 +160,11 @@ class ToolsController extends AbstractController |
|
|
|
|
|
|
|
|
$citiesData = $overpass->query(sprintf('relation[admin_level=8][boundary=administrative]["ref:INSEE"](%f,%f,%f,%f);', $minLat, $minLon, $maxLat, $maxLon)); |
|
|
$citiesData = $overpass->query(sprintf('relation[admin_level=8][boundary=administrative]["ref:INSEE"](%f,%f,%f,%f);', $minLat, $minLon, $maxLat, $maxLon)); |
|
|
$citiesOsm = \OSM\OSM::createFromJson($citiesData); |
|
|
$citiesOsm = \OSM\OSM::createFromJson($citiesData); |
|
|
|
|
|
|
|
|
|
|
|
$logger->debug(__METHOD__.' overpass cities', [ |
|
|
|
|
|
count($citiesOsm->elements), |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
$cities = []; |
|
|
$cities = []; |
|
|
foreach ($citiesOsm->elements as $cityOsm) { |
|
|
foreach ($citiesOsm->elements as $cityOsm) { |
|
|
$geojson = \OSM\GeoJsonConverter::convertRelationToPolygon($cityOsm); |
|
|
$geojson = \OSM\GeoJsonConverter::convertRelationToPolygon($cityOsm); |
|
@ -179,6 +190,10 @@ class ToolsController extends AbstractController |
|
|
|
|
|
|
|
|
$cities = array_filter($cities, function ($city) { return !empty($city['features']); }); |
|
|
$cities = array_filter($cities, function ($city) { return !empty($city['features']); }); |
|
|
|
|
|
|
|
|
|
|
|
$logger->debug(__METHOD__.' cities', [ |
|
|
|
|
|
count($cities), |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
$response->setCallback(function () use ($cities): void { |
|
|
$response->setCallback(function () use ($cities): void { |
|
|
$headings = [ |
|
|
$headings = [ |
|
|
'name', |
|
|
'name', |
|
|