Skip to content

Commit

Permalink
quaeldich2geojson
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyclenerd committed Mar 18, 2017
1 parent 1016224 commit b0d3981
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
22 changes: 22 additions & 0 deletions quaeldich2geojson/README.md
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions quaeldich2geojson/quaeldich2geojson.pl
Original file line number Diff line number Diff line change
@@ -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 (<STDIN>) {
$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/&nbsp;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 } );
Binary file added quaeldich2geojson/quaelldich-karte.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b0d3981

Please sign in to comment.