aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@fury.ukcod.org.uk>2011-02-26 02:00:00 +0000
committerMatthew Somerville <matthew@fury.ukcod.org.uk>2011-02-26 02:00:00 +0000
commitfe72a8ec3d195ec2b88bf902ec4bbff1c9693f86 (patch)
treea2af1ab4b6fe14bc87d1f19f675964507501aba9
parentd0bcc4d1d639b7ae806e8719727d3494a6229db1 (diff)
Move compass function to Tilma code, pass Q through to click->latlon lookup.
-rw-r--r--perllib/FixMyStreet/Map.pm31
-rw-r--r--perllib/FixMyStreet/Map/Tilma/Original.pm32
-rwxr-xr-xweb/index.cgi12
3 files changed, 40 insertions, 35 deletions
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index a9978103f..e507726c2 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -102,35 +102,4 @@ sub map_features {
return ( $around_map, $around_map_list, $nearby, $dist );
}
-sub compass ($$$) {
- my ( $q, $x, $y ) = @_;
- my @compass;
- for ( my $i = $x - 1 ; $i <= $x + 1 ; $i++ ) {
- for ( my $j = $y - 1 ; $j <= $y + 1 ; $j++ ) {
- $compass[$i][$j] = NewURL( $q, x => $i, y => $j );
- }
- }
- my $recentre = NewURL($q);
- my $host = Page::base_url_with_lang( $q, undef );
- return <<EOF;
-<table cellpadding="0" cellspacing="0" border="0" id="compass">
-<tr valign="bottom">
-<td align="right"><a rel="nofollow" href="${compass[$x-1][$y+1]}"><img src="$host/i/arrow-northwest.gif" alt="NW" width=11 height=11></a></td>
-<td align="center"><a rel="nofollow" href="${compass[$x][$y+1]}"><img src="$host/i/arrow-north.gif" vspace="3" alt="N" width=13 height=11></a></td>
-<td><a rel="nofollow" href="${compass[$x+1][$y+1]}"><img src="$host/i/arrow-northeast.gif" alt="NE" width=11 height=11></a></td>
-</tr>
-<tr>
-<td><a rel="nofollow" href="${compass[$x-1][$y]}"><img src="$host/i/arrow-west.gif" hspace="3" alt="W" width=11 height=13></a></td>
-<td align="center"><a rel="nofollow" href="$recentre"><img src="$host/i/rose.gif" alt="Recentre" width=35 height=34></a></td>
-<td><a rel="nofollow" href="${compass[$x+1][$y]}"><img src="$host/i/arrow-east.gif" hspace="3" alt="E" width=11 height=13></a></td>
-</tr>
-<tr valign="top">
-<td align="right"><a rel="nofollow" href="${compass[$x-1][$y-1]}"><img src="$host/i/arrow-southwest.gif" alt="SW" width=11 height=11></a></td>
-<td align="center"><a rel="nofollow" href="${compass[$x][$y-1]}"><img src="$host/i/arrow-south.gif" vspace="3" alt="S" width=13 height=11></a></td>
-<td><a rel="nofollow" href="${compass[$x+1][$y-1]}"><img src="$host/i/arrow-southeast.gif" alt="SE" width=11 height=11></a></td>
-</tr>
-</table>
-EOF
-}
-
1;
diff --git a/perllib/FixMyStreet/Map/Tilma/Original.pm b/perllib/FixMyStreet/Map/Tilma/Original.pm
index b6d24fd6a..961e507df 100644
--- a/perllib/FixMyStreet/Map/Tilma/Original.pm
+++ b/perllib/FixMyStreet/Map/Tilma/Original.pm
@@ -268,6 +268,7 @@ sub click_to_os {
# Given some click co-ords (the tile they were on, and where in the
# tile they were), convert to WGS84 and return.
sub click_to_wgs84 {
+ my $q = shift;
my ( $easting, $northing ) = FixMyStreet::Map::click_to_os(@_);
my ( $lat, $lon ) = mySociety::GeoUtil::national_grid_to_wgs84( $easting, $northing, 'G' );
return ( $lat, $lon );
@@ -308,4 +309,35 @@ sub os_to_px_with_adjust {
return ($x_tile, $y_tile, $px, $py);
}
+sub compass ($$$) {
+ my ( $q, $x, $y ) = @_;
+ my @compass;
+ for ( my $i = $x - 1 ; $i <= $x + 1 ; $i++ ) {
+ for ( my $j = $y - 1 ; $j <= $y + 1 ; $j++ ) {
+ $compass[$i][$j] = NewURL( $q, x => $i, y => $j );
+ }
+ }
+ my $recentre = NewURL($q);
+ my $host = Page::base_url_with_lang( $q, undef );
+ return <<EOF;
+<table cellpadding="0" cellspacing="0" border="0" id="compass">
+<tr valign="bottom">
+<td align="right"><a rel="nofollow" href="${compass[$x-1][$y+1]}"><img src="$host/i/arrow-northwest.gif" alt="NW" width=11 height=11></a></td>
+<td align="center"><a rel="nofollow" href="${compass[$x][$y+1]}"><img src="$host/i/arrow-north.gif" vspace="3" alt="N" width=13 height=11></a></td>
+<td><a rel="nofollow" href="${compass[$x+1][$y+1]}"><img src="$host/i/arrow-northeast.gif" alt="NE" width=11 height=11></a></td>
+</tr>
+<tr>
+<td><a rel="nofollow" href="${compass[$x-1][$y]}"><img src="$host/i/arrow-west.gif" hspace="3" alt="W" width=11 height=13></a></td>
+<td align="center"><a rel="nofollow" href="$recentre"><img src="$host/i/rose.gif" alt="Recentre" width=35 height=34></a></td>
+<td><a rel="nofollow" href="${compass[$x+1][$y]}"><img src="$host/i/arrow-east.gif" hspace="3" alt="E" width=11 height=13></a></td>
+</tr>
+<tr valign="top">
+<td align="right"><a rel="nofollow" href="${compass[$x-1][$y-1]}"><img src="$host/i/arrow-southwest.gif" alt="SW" width=11 height=11></a></td>
+<td align="center"><a rel="nofollow" href="${compass[$x][$y-1]}"><img src="$host/i/arrow-south.gif" vspace="3" alt="S" width=13 height=11></a></td>
+<td><a rel="nofollow" href="${compass[$x+1][$y-1]}"><img src="$host/i/arrow-southeast.gif" alt="SE" width=11 height=11></a></td>
+</tr>
+</table>
+EOF
+}
+
1;
diff --git a/web/index.cgi b/web/index.cgi
index ed5b285c2..e801e076b 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -500,8 +500,12 @@ sub display_form {
$longitude = $lon;
}
} elsif ($pin_x && $pin_y) {
- # tilma map was clicked on
- ($latitude, $longitude) = FixMyStreet::Map::click_to_wgs84($pin_tile_x, $pin_x, $pin_tile_y, $pin_y);
+
+ # Map was clicked on (tilma, or non-JS OpenLayers, for example)
+ ($latitude, $longitude) = FixMyStreet::Map::click_to_wgs84($q, $pin_tile_x, $pin_x, $pin_tile_y, $pin_y);
+ # Shrink, as don't need accuracy plus we want them as English strings
+ ($latitude, $longitude) = map { Utils::truncate_coordinate($_) } ( $latitude, $longitude );
+
} elsif ( $input{partial} && $input{pc} && !length $input{latitude} && !length $input{longitude} ) {
my $error;
try {
@@ -719,8 +723,8 @@ photo of the problem if you have one), etc.'));
}
$vars{text_help} .= '
-<input type="hidden" name="latitude" value="' . $latitude . '">
-<input type="hidden" name="longitude" value="' . $longitude . '">';
+<input type="hidden" name="latitude" id="fixmystreet.latitude" value="' . $latitude . '">
+<input type="hidden" name="longitude" id="fixmystreet.longitude" value="' . $longitude . '">';
if (@errors) {
$vars{errors} = '<ul class="error"><li>' . join('</li><li>', @errors) . '</li></ul>';