Skip Menu |

This queue is for tickets about the Geography-NationalGrid CPAN distribution.

Report information
The Basics
Id: 11168
Status: open
Priority: 0/
Queue: Geography-NationalGrid

People
Owner: Nobody in particular
Requestors: cpan [...] barryhunter.co.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: fudge factor not really required
the script introduces a fudge, see the code below, when converting from Lat/Long to GridRef. However I dont think this sentiment is correct in the UK as National Grid References are by convention to the lower left corner. my $fudge = $self->{'DefaultResolution'} / 2; # because the point is within the _square_ based at the E,N coordinate ($self->{'Easting'}, $self->{'Northing'}) = ($E + $fudge, $N + $fudge); (line 244,245 of the Geography\NationalGrid.pm) changing it to ($self->{'Easting'}, $self->{'Northing'}) = ($E + 0.5, $N + 0.5); seemed to do the trick! (0.5 is actually to account for rounding errors because the module later uses int() to round the easting/northings) The fact that it did this 'fudge' one way but not the other is slightly worrying, meaning that the coordinates by this module arent reversible. However its debateable if this 'feature' is an issue for your application.
If you want a 1m resolution, then you can specify DefaultResolution => 1 in the constructor, which then has the effect you say. Not sure why this isn't documented, or its relevance to a lat/lon conversion, as you say, perhaps something to be looked at if we can get it republished.
Subject: Re: [rt.cpan.org #11168] fudge factor not really required
Date: Sat, 4 May 2019 14:03:51 +0100
To: bug-Geography-NationalGrid [...] rt.cpan.org
From: Barry Hunter <barry [...] barryhunter.co.uk>
ok wow, blast from past. Thanks for the information! Don't remember the specifics now, but suspect I didn't want to mess with DefaultResolution due to effect on actual grid-references. ... as far as I could see, it was never correct to do the fudge during a lat/lng->easting/nothing conversion, as no knowledge that lat/long would of been a location of bottom left of a square. If a fudge required, it would during grid-reference->easting/northing conversion. It can also be 'aware' of the resolution of the specific grid-reference to do the fudge :) ... eve then it could be a specific toggleable option. I suspect (in hindsight!) the fudge came after doing a grid-refernece->e/n->lat/long conversion. That may of resulted in a lat/long representing bottom/left, and wanted to when converted back to be middle of square. would of worked with fudge when grid-reference->e/n conversion, resulting in lat/long for center of square, and it being convertable back to e/n, or even a grid-ref. On Fri, May 3, 2019 at 11:27 PM mySociety via RT < bug-Geography-NationalGrid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=11168 > > > If you want a 1m resolution, then you can specify DefaultResolution => 1 > in the constructor, which then has the effect you say. Not sure why this > isn't documented, or its relevance to a lat/lon conversion, as you say, > perhaps something to be looked at if we can get it republished. >
-- Barry - www.nearby.org.uk - www.geograph.org.uk -