rozklad / heremaps-flexible-polyline
PHP implementation of Flexible Polyline encoding: a lossy compressed representation of a list of coordinate pairs or triples
Installs: 187 466
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.2.0
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: >=8.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-11-15 14:17:53 UTC
README
composer test
Usage
Decode
FlexiblePolyline::decode(string $encoded): array
$data = FlexiblePolyline::decode('BlBoz5xJ67i1BU1B7PUzIhaUxL7YU');
/** $data:
[
'precision' => 5,
'thirdDim' => 2,
'thirdDimPrecision' => 0,
'polyline' => [
[50.10228, 8.69821, 10],
[50.10201, 8.69567, 20],
[50.10063, 8.6915, 30],
[50.09878, 8.68752, 40]
]
]
*/
Encode
FlexiblePolyline::encode(array $coordinates [, int $precision = null, int $thirdDim = null, int $thirdDimPrecision = 0]): string
$encoded = FlexiblePolyline::encode([
[50.10228, 8.69821, 10],
[50.10201, 8.69567, 20],
[50.10063, 8.6915, 30],
[50.09878, 8.68752, 40]
], 5, 2, 0);
/** $encoded:
BlBoz5xJ67i1BU1B7PUzIhaUxL7YU
*/
Third Dimension
FlexiblePolyline::getThirdDimension(string $encoded): int
$thirdDimension = FlexiblePolyline::getThirdDimension('BVoz5xJ67i1BU')
/** $thirdDimension:
1
*/