Calculating distances #14

Closed
opened 2021-06-13 15:15:31 +02:00 by thisfro · 2 comments
Owner

To get the Geolocation of a PLZ (in this case 6006):

use Location\Coordinate;
use Location\Distance\Vincenty;

$content = file_get_contents("https://swisspost.opendatasoft.com/api/records/1.0/search/?dataset=plz_verzeichnis_v2&q=postleitzahl%3D6006");
        $result  = json_decode($content);

        $lat = $result->records[0]->fields->geo_point_2d[0];
        $long = $result->records[0]->fields->geo_point_2d[1];

Which returns 47.0538244131 and 8.33446804114.

This can then be used with e.g. phpgeo to calculate distance between two PLZ

To get the Geolocation of a PLZ (in this case `6006`): ```php use Location\Coordinate; use Location\Distance\Vincenty; $content = file_get_contents("https://swisspost.opendatasoft.com/api/records/1.0/search/?dataset=plz_verzeichnis_v2&q=postleitzahl%3D6006"); $result = json_decode($content); $lat = $result->records[0]->fields->geo_point_2d[0]; $long = $result->records[0]->fields->geo_point_2d[1]; ``` Which returns `47.0538244131` and `8.33446804114`. This can then be used with e.g. [phpgeo](https://github.com/mjaschen/phpgeo) to calculate distance between two PLZ
thisfro added the
Idea
label 2021-06-13 15:15:32 +02:00
Author
Owner

This could maybe be implementad as a symfony service

This could maybe be implementad as a [symfony service](https://symfony.com/doc/current/service_container.html)
thisfro added this to the Basic functionality milestone 2021-06-13 18:46:30 +02:00
Author
Owner

Implemented in d33e28467b

Implemented in d33e28467b
This repo is archived. You cannot comment on issues.
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: thisfro/pflaenz.li-Symfony#14
No description provided.