diff options
Diffstat (limited to 'bin/import-flickr')
-rwxr-xr-x | bin/import-flickr | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/bin/import-flickr b/bin/import-flickr index 992a6ac8e..f4a838547 100755 --- a/bin/import-flickr +++ b/bin/import-flickr @@ -24,7 +24,6 @@ use mySociety::Config; use mySociety::DBHandle qw(dbh select_all); use mySociety::EmailUtil; use mySociety::Email; -use mySociety::GeoUtil; BEGIN { mySociety::Config::set_file("$FindBin::Bin/../conf/general"); @@ -55,36 +54,36 @@ foreach (@$st) { # XXX: Hmm... Use format=perl now Cal has added it for me! :) while ($result =~ /<photo id="([^"]*)" owner="([^"]*)" secret="([^"]*)" server="([^"]*)" farm="([^"]*)" title="([^"]*)".*?latitude="([^"]*)" longitude="([^"]*)".*?machine_tags="([^"]*)"/g) { - my ($id, $owner, $secret, $server, $farm, $title, $lat, $lon, $machine) = ($1, $2, $3, $4, $5, $6, $7, $8, $9); + my ($id, $owner, $secret, $server, $farm, $title, $latitude, $longitude, $machine) = ($1, $2, $3, $4, $5, $6, $7, $8, $9); next if $ids{$id}; - if ($machine =~ /geo:/ && !$lat && !$lon) { + if ($machine =~ /geo:/ && !$latitude && !$longitude) { # Have to fetch raw tags, as otherwise can't tell if it's negative, or how many decimal places my $url = 'http://api.flickr.com/services/rest/?method=flickr.tags.getListPhoto&api_key=' . $key . '&photo_id=' . $id; my $tags = get($url); - ($lon) = $tags =~ /raw="geo:lon=([^"]*)"/i; - ($lat) = $tags =~ /raw="geo:lat=([^"]*)"/i; + ($longitude) = $tags =~ /raw="geo:lon=([^"]*)"/i; + ($latitude) = $tags =~ /raw="geo:lat=([^"]*)"/i; } my $url = "http://farm$farm.static.flickr.com/$server/".$id.'_'.$secret.'_m.jpg'; my $image = get($url); - problem_create($id, $owner, $title, $lat, $lon, $image); + problem_create($id, $owner, $title, $latitude, $longitude, $image); } sub problem_create { - my ($photo_id, $owner, $title, $lat, $lon, $image) = @_; + my ($photo_id, $owner, $title, $latitude, $longitude, $image) = @_; my ($name, $email) = dbh()->selectrow_array("select name, email from partial_user where service='flickr' and nsid=?", {}, $owner); - my ($easting, $northing) = (0,0); + + # set some defaults $name ||= ''; - if ($lat && $lon) { - # XXX This appears to be going wrong :( - ($easting, $northing) = mySociety::GeoUtil::wgs84_to_national_grid($lat, $lon, 'G'); - } + $latitude ||= 0; + $longitude ||= 0; + my $id = dbh()->selectrow_array("select nextval('problem_id_seq')"); Utils::workaround_pg_bytea("insert into problem - (id, postcode, easting, northing, title, detail, name, + (id, postcode, latitude, longitude, title, detail, name, email, phone, photo, state, used_map, anonymous, category, areas) values (?, '', ?, ?, ?, '', ?, ?, '', ?, 'partial', 't', 'f', '', '')", 7, - $id, $easting, $northing, $title, $name, $email, $image + $id, $latitude, $longitude, $title, $name, $email, $image ); dbh()->do('insert into flickr_imported (id, problem_id) values (?, ?)', {}, $photo_id, $id); |