mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
addresses: add pagination in WFS request (WIP)
This commit is contained in:
parent
5f8a506c84
commit
3bc510d116
@ -51,7 +51,9 @@ class LoadAddressReferenceCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
$addressReferenceArray = $this->fetchWFS();
|
|
||||||
|
|
||||||
|
$addressReferenceArray = $this->fetchWFS(1, 10);
|
||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
|
|
||||||
foreach($addressReferenceArray as $a) {
|
foreach($addressReferenceArray as $a) {
|
||||||
@ -62,7 +64,11 @@ class LoadAddressReferenceCommand extends Command
|
|||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isAddressReferenceNew(AddressReference $a): bool
|
public static function isAddressReferenceNew(AddressReference $a): bool
|
||||||
@ -78,22 +84,21 @@ class LoadAddressReferenceCommand extends Command
|
|||||||
* //TODO move this function in App and make the command generic by accepting a fetcher as an argument
|
* //TODO move this function in App and make the command generic by accepting a fetcher as an argument
|
||||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||||
*/
|
*/
|
||||||
private function fetchWFS(): array
|
private function fetchWFS(int $startIndex, int $count ): array
|
||||||
{
|
{
|
||||||
|
|
||||||
$dataSource = 'BAL GeoVendee';
|
$dataSource = 'BAL GeoVendee';
|
||||||
$countryCode = 'FR';
|
$countryCode = 'FR';
|
||||||
|
|
||||||
$addressReferenceArray = array();
|
$addressReferenceArray = array();
|
||||||
|
|
||||||
$wfsUrl = 'https://carto.vendee.fr/arcgis/services/Applications/CHILL/MapServer/WFSServer?SERVICE=WFS&REQUEST=GetFeature';
|
$wfsUrl = 'https://carto.vendee.fr/arcgis/services/Applications/CHILL/MapServer/WFSServer?SERVICE=WFS&REQUEST=GetFeature';
|
||||||
|
|
||||||
$wfsContent = file_get_contents($wfsUrl.'&version=2.0.0&TYPENAME=CHILL:Adresses&MAXFEATURES=3&OUTPUTFORMAT=geojson');
|
$wfsContent = file_get_contents(
|
||||||
//TODO loop for pagination
|
$wfsUrl . '&version=2.0.0&TYPENAME=CHILL:Adresses&startIndex=' . $startIndex . '&count=' . $count . '&OUTPUTFORMAT=geojson'
|
||||||
|
);
|
||||||
|
|
||||||
$jsonContent = json_decode($wfsContent, true);
|
$jsonContent = json_decode($wfsContent, true);
|
||||||
|
|
||||||
|
|
||||||
foreach ($jsonContent['features'] as $key => $value) {
|
foreach ($jsonContent['features'] as $key => $value) {
|
||||||
|
|
||||||
$a = new AddressReference();
|
$a = new AddressReference();
|
||||||
@ -130,6 +135,4 @@ class LoadAddressReferenceCommand extends Command
|
|||||||
return $addressReferenceArray;
|
return $addressReferenceArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user