diff --git a/quaeldich2geojson/README.md b/quaeldich2geojson/README.md new file mode 100644 index 0000000..25e2a4c --- /dev/null +++ b/quaeldich2geojson/README.md @@ -0,0 +1,22 @@ +# Quäldich.de to GeoJSON + +This small Perl script converts the Quäldich.de (http://www.quaeldich.de/) location JSON into a GeoJSON file. + + +## Example with the island of Mallorca + +### View the map and locate location_json_v3.php + +http://www.quaeldich.de/paesse/puig-major/karte/ + +![Map](quaelldich-karte.jpg) + +### Download location JSON and convert to GeoJSON + +``` +curl -s -f 'http://www.quaeldich.de/webinclude/php/location_json_v3.php?swlon=1.3197287499999675&swlat=39.153399417839836&nelon=4.4508322656249675&nelat=40.41967792946016&items=0' | perl quaeldich2geojson.pl > mallorca.geojson +``` + +## Output + +https://github.com/Cyclenerd/cyclenerd.github.io/blob/master/mallorca/paesse.geojson diff --git a/quaeldich2geojson/quaeldich2geojson.pl b/quaeldich2geojson/quaeldich2geojson.pl new file mode 100755 index 0000000..05241b6 --- /dev/null +++ b/quaeldich2geojson/quaeldich2geojson.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl + + +# +# This small Perl script converts the Quäldich.de (http://www.quaeldich.de/) location JSON into a GeoJSON file. +# +# Example with the island of Mallorca: +# +# http://www.quaeldich.de/paesse/puig-major/karte/ +# +# curl -s -f 'http://www.quaeldich.de/webinclude/php/location_json_v3.php?swlon=1.3197287499999675&swlat=39.153399417839836&nelon=4.4508322656249675&nelat=40.41967792946016&items=0' | perl quaeldich2geojson.pl > mallorca.geojson +# +# +# Output: +# https://github.com/Cyclenerd/cyclenerd.github.io/blob/master/mallorca/paesse.geojson +# + + +use strict; +use JSON; + +my $input = ''; +while () { + $input .= $_; +} + +my $json = decode_json $input; + +my @paesse = (); +foreach my $pass (@{$json->{'paesse'}}) { + my $name = $pass->{'name'}; + my $textid = $pass->{'textid'}; + my $lat = $pass->{'latitude'}; + my $lng = $pass->{'longitude'}; + my $alt = $pass->{'output'}; + $alt =~ s/ m//; + my $point = { + 'type' => 'Feature', + 'geometry' => { + 'type' => 'Point', + 'coordinates' => [$lng, $lat] + }, + 'properties' => { + 'name' => $name, + 'type' => 'Mountain', + 'meters' => $alt, + 'marker-symbol' => 'triangle', + 'url' => "http://www.quaeldich.de/paesse/$textid" + } + }; + push(@paesse, $point); +} + +my $output = { + 'type' => 'FeatureCollection', + 'features' => \@paesse +}; + +print to_json($output, { ascii => 1, pretty => 1 } ); diff --git a/quaeldich2geojson/quaelldich-karte.jpg b/quaeldich2geojson/quaelldich-karte.jpg new file mode 100644 index 0000000..6ca20b6 Binary files /dev/null and b/quaeldich2geojson/quaelldich-karte.jpg differ