addresses: add pagination in WFS request (WIP)

This commit is contained in:
nobohan 2021-05-18 10:03:36 +02:00
parent 5f8a506c84
commit 3bc510d116

View File

@ -51,7 +51,9 @@ class LoadAddressReferenceCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$addressReferenceArray = $this->fetchWFS();
$addressReferenceArray = $this->fetchWFS(1, 10);
$em = $this->entityManager;
foreach($addressReferenceArray as $a) {
@ -62,7 +64,11 @@ class LoadAddressReferenceCommand extends Command
$em->flush();
return 0;
}
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
* @see \Symfony\Component\Console\Command\Command::execute()
*/
private function fetchWFS(): array
private function fetchWFS(int $startIndex, int $count ): array
{
$dataSource = 'BAL GeoVendee';
$countryCode = 'FR';
$addressReferenceArray = array();
$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');
//TODO loop for pagination
$wfsContent = file_get_contents(
$wfsUrl . '&version=2.0.0&TYPENAME=CHILL:Adresses&startIndex=' . $startIndex . '&count=' . $count . '&OUTPUTFORMAT=geojson'
);
$jsonContent = json_decode($wfsContent, true);
foreach ($jsonContent['features'] as $key => $value) {
$a = new AddressReference();
@ -130,6 +135,4 @@ class LoadAddressReferenceCommand extends Command
return $addressReferenceArray;
}
}