[NUUG fiksgatami] Decimal point separator

Petter Reinholdtsen pere at hungry.com
Sat Feb 14 22:24:53 CET 2009


[Matthew Somerville]
> Hi,
> 
> The commit I've just made:
>     https://secure.mysociety.org/cvstrac/chngview?cn=14147
> enables the location display to work fine with a Norwegian locale, for 
> example: http://matthew.fixmystreet.com/?pc=sw1a1aa (with my browser's 
> language set to nb). Hope that makes sense.

Great.  It definitely make sense to us, and are very similar to the
changes I made to our tree.  I was never found time to check if my
changes were complete, and this is the reason I did not push the patch
your way yet.

I had a few more changes, which I am not sure still make sense, but
thought it best to show to you for comments.  I had to change these
blocks as well to get things working for me.  I have not tested if
they are still required to get it working.

Index: bci/perllib/Problems.pm
===================================================================
RCS file: /repos/mysociety/bci/perllib/Problems.pm,v
retrieving revision 1.10
diff -u -3 -p -r1.10 Problems.pm
--- bci/perllib/Problems.pm	14 Feb 2009 11:30:49 -0000	1.10
+++ bci/perllib/Problems.pm	14 Feb 2009 21:19:42 -0000
@@ -173,7 +173,8 @@ sub fixed_nearby {
 
 sub fetch_problem {
     my $id = shift;
-    dbh()->selectrow_hashref(
+    mySociety::Locale::push('en-gb');
+    my $retval = dbh()->selectrow_hashref(
         "select id, easting, northing, council, category, title, detail, (photo is not null) as photo,
         used_map, name, anonymous, extract(epoch from confirmed) as time,
         state, extract(epoch from whensent-confirmed) as whensent,
@@ -181,6 +182,8 @@ sub fetch_problem {
         from problem where id=? and state in ('confirmed','fixed', 'hidden')
         $site_restriction", {}, $id
     );
+    mySociety::Locale::pop();
+    return $retval;
 }
 
 1;
Index: perllib/mySociety/GeoUtil.pm
===================================================================
RCS file: /repos/mysociety/perllib/mySociety/GeoUtil.pm,v
retrieving revision 1.6
diff -u -3 -p -r1.6 GeoUtil.pm
--- perllib/mySociety/GeoUtil.pm	26 Jan 2009 14:21:52 -0000	1.6
+++ perllib/mySociety/GeoUtil.pm	14 Feb 2009 21:19:43 -0000
@@ -32,6 +32,7 @@ Northern Ireland.  The latitude and long
 sub national_grid_to_wgs84($$$) {
     my ($easting, $northing, $coordsyst) = @_;
 
+    mySociety::Locale::push('en-gb');
     our ($wgs84, $airy1830, $airy1830m);
     $wgs84      ||= Geo::HelmertTransform::datum("WGS84");
     $airy1830   ||= Geo::HelmertTransform::datum("Airy1830");
@@ -52,7 +53,9 @@ sub national_grid_to_wgs84($$$) {
     } else {
         die "bad value '$coordsyst' for coordinate system in nationalgrid_to_wgs84";
     }
-    return Geo::HelmertTransform::convert_datum($d, $wgs84, $lat, $lon, 0); # 0 is altitude
+    my @ret = Geo::HelmertTransform::convert_datum($d, $wgs84, $lat, $lon, 0); # 0 is altitude
+    mySociety::Locale::pop();
+    return @ret;
 }
 
 =item wgs84_to_national_grid LATITUDE LONGITUDE COORDSYST
@@ -64,6 +67,7 @@ Northern Ireland.  The easting and north
 sub wgs84_to_national_grid($$$) {
     my ($lat, $lon, $coordsyst) = @_;
 
+   mySociety::Locale::push('en-gb');
     our ($wgs84, $airy1830, $airy1830m);
     $wgs84      ||= Geo::HelmertTransform::datum("WGS84");
     $airy1830   ||= Geo::HelmertTransform::datum("Airy1830");
@@ -89,6 +93,8 @@ sub wgs84_to_national_grid($$$) {
     } else {
         die "bad value '$coordsyst' for coordinate system in nationalgrid_to_wgs84";
     }
+    mySociety::Locale::pop();
+    print STDERR "Geo: ", $p->easting,",", $p->northing, "\n";
     return ($p->easting, $p->northing);
 }
 


More information about the fiksgatami mailing list