source: subversion/applications/utils/relationbuilder/fetcher.pl @ 5472

Last change on this file since 5472 was 5472, checked in by hakan, 13 years ago

Basic HTTP fetcher for OsmXApi

File size: 899 bytes
Line 
1#! /usr/bin/perl -w
2
3use strict;
4
5use LWP::UserAgent;
6
7#
8#
9#
10my $URLBASE="http://www.informationfreeway.org/api/0.5";
11
12
13#
14#
15#
16sub fetch_nodes
17{
18    my ($datafile, $min_lat, $max_lat, $min_lon, $max_lon) = @_;
19
20    my $URL=$URLBASE . "/node[place=*][bbox=$min_lon,$min_lat,$max_lon,$max_lat]";
21
22    print $URL . "\n";
23
24    my $ua = LWP::UserAgent->new;
25    $ua->env_proxy();
26    $ua->agent("relationbuilder/0.1");
27
28    my $request = HTTP::Request->new(GET => $URL);
29    my $response = $ua->request($request);
30
31    if ($response->is_success)
32    {
33        open OUT, "> $datafile";
34        print OUT $response->content . "\n";
35        close (OUT);
36
37        print $response->status_line . "\n";
38    }
39    else
40    {
41        print $response->status_line . "\n";
42    }
43}
44
45# Turkey
46fetch_nodes("turkey-places.osm", "35.8", "42.5", "26.0", "45.0");
47
48# Cyprus
Note: See TracBrowser for help on using the repository browser.