aboutsummaryrefslogtreecommitdiffstats
path: root/bin/zurich
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2014-03-03 17:58:12 +0000
committerMatthew Somerville <matthew@mysociety.org>2014-03-12 17:46:10 +0000
commitd2ebd056a2bd0484959d47b763dc6918b5b35015 (patch)
tree5f9c8240fc33336da9d82d01b9c7b5114a2d42e7 /bin/zurich
parent8b725b38bb6abf3b77e22c2f65f93fabfc92c645 (diff)
[Zurich] basic commandline tool for geocoder
Also add warning to Geocoder to pass on server error if you are running in development.
Diffstat (limited to 'bin/zurich')
-rwxr-xr-xbin/zurich/geocode45
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/zurich/geocode b/bin/zurich/geocode
new file mode 100755
index 000000000..9482b27e6
--- /dev/null
+++ b/bin/zurich/geocode
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+zurich/geocode - commandline tool to test the Zurich geocoder
+
+=head1 SYNOPSIS
+
+ # Firstly:
+ ## copy the GEOCODER config from a current Zurich conf to your conf/general.yml
+ $ eval `perl setenv.pl`
+
+ $ bin/zurich/geocode Magnus
+
+ # ... output from geocoder
+
+This can be used to test the results of, e.g.
+
+ https://www.zueriwieneu.ch/ajax/geocode?term=Magnus
+
+but without the caching which FixMyStreet applies, and passing on any 500
+errors from the server.
+
+=cut
+
+use strict;
+use warnings;
+require 5.8.0;
+
+
+use Data::Dumper;
+use feature 'say';
+
+use FixMyStreet;
+use FixMyStreet::App;
+use FixMyStreet::Geocode::Zurich;
+
+# TODO use FixMyStreet::override_config to get data from conf/general.yml.zurich if available
+my $geocoder = FixMyStreet->config('GEOCODER')
+ or die "No GEOCODER config -- please copy appropriate Zurich conf to conf/general.yml";
+
+my $c = FixMyStreet::App->new();
+my $s = join ' ', @ARGV;
+
+say Dumper( FixMyStreet::Geocode::Zurich::string( $s, $c ) );