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

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

Primitive caching, to be removed later

File size: 1.1 KB
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_place_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    # Primitive caching... Just so I can continue working without network access...
25    if (! -r $datafile)
26    {
27        my $ua = LWP::UserAgent->new;
28        $ua->env_proxy();
29        $ua->agent("relationbuilder/0.1");
30
31        my $request = HTTP::Request->new(GET => $URL);
32        my $response = $ua->request($request);
33
34        if ($response->is_success)
35        {
36            open OUT, "> $datafile";
37            print OUT $response->content . "\n";
38            close (OUT);
39
40            print $response->status_line . "\n";
41        }
42        else
43        {
44            print $response->status_line . "\n";
45        }
46    }
47}
48
49# Turkey
50fetch_place_nodes("turkey-places.xml", "35.8", "42.5", "26.0", "45.0");
51
52# Cyprus
Note: See TracBrowser for help on using the repository browser.