PHP code example of mapsight / pulp-datex-fuel
1. Go to this page and download the library: Download mapsight/pulp-datex-fuel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mapsight / pulp-datex-fuel example snippets
use OpenMapsight\Pulp;
use OpenMapsight\PulpCache;
use OpenMapsight\PulpDatexFuel;
use OpenMapsight\PulpJSON;
$source = Pulp::start()
->pipe(PulpDatexFuel::srcMobilithek(
$subscriptionId,
$certPath,
$certPassword,
$ifModifiedSince,
));
$files = Pulp::start()
->pipe(PulpCache::remember($source, __DIR__ . '/cache', [
'key' => 'datex-fuel-stations',
'ttl' => 86400,
'fallbackToStale' => true,
]))
->pipe(PulpDatexFuel::stationsGeoJson(
bbox: [6.05, 50.76, 6.08, 50.82],
sourceUrl: 'https://example.com/open-data-docs',
sourceName: 'DATEX Fuel',
documentationUrl: 'https://example.com/open-data-docs',
publicSourceUrl: 'https://example.com/open-data-docs',
))
->run();
use OpenMapsight\Pulp;
use OpenMapsight\PulpDatexFuel;
use OpenMapsight\PulpJSON;
Pulp::start()
->pipe(Pulp::src('stations.xml', __DIR__ . '/input'))
->pipe(PulpDatexFuel::stationsGeoJson(
[6.05, 50.76, 6.08, 50.82],
'https://example.com/open-data-docs',
))
->pipe(PulpJSON::encodeJSON(JSON_PRETTY_PRINT))
->pipe(Pulp::dest(__DIR__ . '/result'))
->run();
$prices = PulpDatexFuel::extractPrices($publication);
$cache = PulpDatexFuel::applyPricePacketToCache($cache, $prices, $packetType, $lastModified);
$merged = PulpDatexFuel::mergePricesIntoFeatureCollection($featureCollection, $cache['prices']);
Pulp::start()
->pipe(Pulp::src('prices.xml', __DIR__ . '/input'))
->pipe(PulpDatexFuel::priceRecords())
->run();
Pulp::start()
->pipe(Pulp::src('prices.xml', __DIR__ . '/input'))
->pipe(PulpDatexFuel::accumulatePrices(__DIR__ . '/cache/tanken-prices.json'))
->run();