aboutsummaryrefslogtreecommitdiffstats
path: root/t/Nominatim.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2015-08-26 13:43:10 +0200
committerMarius Halden <marius.h@lden.org>2015-08-26 13:43:10 +0200
commitcc0acdd34052e79f3df368ac1f524de31df19a1b (patch)
tree505f561b5f16c5b78f07514e8c2b2bdc18fef51d /t/Nominatim.pm
parent1c5c685d0b0904e7ddc6e764e58e8fae08632d1d (diff)
parent6b84622fb7d58531baa7943abdcc7620999c34ee (diff)
Merge tag 'v1.6.1' into fiksgatami-dev
Diffstat (limited to 't/Nominatim.pm')
-rw-r--r--t/Nominatim.pm37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/Nominatim.pm b/t/Nominatim.pm
new file mode 100644
index 000000000..2041b4677
--- /dev/null
+++ b/t/Nominatim.pm
@@ -0,0 +1,37 @@
+package t::Nominatim;
+
+use JSON;
+use Web::Simple;
+
+has json => (
+ is => 'lazy',
+ default => sub {
+ JSON->new->pretty->allow_blessed->convert_blessed;
+ },
+);
+
+sub dispatch_request {
+ my $self = shift;
+
+ sub (GET + /search + ?q=) {
+ my ($self, $q) = @_;
+ my $response = $self->query($q);
+ my $json = $self->json->encode($response);
+ return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ];
+ },
+}
+
+sub query {
+ my ($self, $q) = @_;
+ if ($q eq 'high street') {
+ return [
+ {"osm_type"=>"way","osm_id"=>"4684282","lat"=>"55.9504009","lon"=>"-3.1858425","display_name"=>"High Street, Old Town, City of Edinburgh, Scotland, EH1 1SP, United Kingdom","class"=>"highway","type"=>"tertiary","importance"=>0.55892577838734},
+ {"osm_type"=>"node","osm_id"=>"27424410","lat"=>"55.8596449","lon"=>"-4.240377","display_name"=>"High Street, Collegelands, Merchant City, Glasgow, Glasgow City, Scotland, G, United Kingdom","class"=>"railway","type"=>"station","importance"=>0.53074299592768}
+ ];
+ }
+ return [];
+}
+
+
+
+__PACKAGE__->run_if_script;