Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Geo-ShapeFile CPAN distribution.

Report information
The Basics
Id: 89563
Status: resolved
Priority: 0/
Queue: Geo-ShapeFile

People
Owner: SLAFFAN [...] cpan.org
Requestors: daniel.smith [...] baesystems.com
Cc:
AdminCc:

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



Subject: Shapes_In_Area Function is incorrect
Date: Wed, 16 Oct 2013 15:49:09 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith [...] baesystems.com>
The Shapes in Area function misses out a LOT of overlapping shapes because of an erroneous check_in_area test Here it the essential part of check_in_area it stands: my $lhit = self->between(x1_min,$x2_min,$x2,max); my $rhit = self->between(x1_max,$x2_min,$x2,max); my $thit = self->between(y1_min,$y2_min,$y2,max); my $bhit = self->between(y1_max,$x2_min,$x2,max); return (#collision ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && $bhit) ) || ( #containment ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && $bhit) ); This is does not return true if the two areas overlap on one side only, it only fires if at least one corner of each shape is within the other (or one contains the other) For instance the areas {0,10,0,10} and {1,11,1,9}, which are obviously overlapping, are not detected by the algorithm because: between(x1_min,$x2_min,$x2,max) FALSE between(x1_max,$x2_min,$x2,max) TRUE between(y1_min,$y2_min,$y2,max) FALSE between(y1_max,$x2_min,$x2,max) FALSE Since only one of the tests is true the algorithm returns false because it needs at least two of the tests to fire. A working algorithm only needs one line as follows: return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > $y2_max or $y1_max < $y2_min); This has the beneficial side effect that it fires if A contains B AND if B contains A, as well as if they overlap Therefore the call to check_in_area in "shapes_in_area" can be optimised from the current: If ($self->check_in_area(@p,@area) || $self->check_in_area(@area,@p)) { To If ($self->check_in_area(@p,@area)) { Hope that is clear, if not contact me for a patch. Dan Smith ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
Hello Dan, Development for this module is now on github. https://github.com/shawnlaffan/Geo-ShapeFile Are you able to submit a pull request with these changes, and ideally some tests or an update to the test suite? Thanks, Shawn. On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote: Show quoted text
> The Shapes in Area function misses out a LOT of overlapping shapes > because of an erroneous check_in_area test > Here it the essential part of check_in_area it stands: > my $lhit = self->between(x1_min,$x2_min,$x2,max); > my $rhit = self->between(x1_max,$x2_min,$x2,max); > my $thit = self->between(y1_min,$y2_min,$y2,max); > my $bhit = self->between(y1_max,$x2_min,$x2,max); > return (#collision > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && > $bhit) > ) || ( #containment > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && > $bhit) > ); > > This is does not return true if the two areas overlap on one side > only, it only fires if at least one corner of each shape is within the > other (or one contains the other) > For instance the areas {0,10,0,10} and {1,11,1,9}, which are obviously > overlapping, are not detected by the algorithm because: > between(x1_min,$x2_min,$x2,max) FALSE > between(x1_max,$x2_min,$x2,max) TRUE > between(y1_min,$y2_min,$y2,max) FALSE > between(y1_max,$x2_min,$x2,max) FALSE > Since only one of the tests is true the algorithm returns false > because it needs at least two of the tests to fire. > > A working algorithm only needs one line as follows: > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > $y2_max > or $y1_max < $y2_min); > > This has the beneficial side effect that it fires if A contains B AND > if B contains A, as well as if they overlap > Therefore the call to check_in_area in "shapes_in_area" can be > optimised from the current: > If ($self->check_in_area(@p,@area) || $self->check_in_area(@area,@p)) > { > > To > > If ($self->check_in_area(@p,@area)) { > > Hope that is clear, if not contact me for a patch. > Dan Smith > ******************************************************************** > This email and any attachments are confidential to the intended > recipient and may also be privileged. If you are not the intended > recipient please delete it from your system and notify the sender. > You should not copy it or use it for any purpose nor disclose or > distribute its contents to any other person. > ********************************************************************
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Mon, 10 Feb 2014 12:07:53 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith [...] baesystems.com>
Thanks for getting back to me Shawn! I may need a bit of hand holding What I have here is a bugfixed version which I am using, I tested it as follows: I downloaded a set of shapefiles which cover the whole of the earth (openly available fom nasa) I tested the new shapefile routines by using them to pull out the shapes that overlap with a lat long box, and seeing that when I found the shapes in a box containing (say) the arabian gulf, or the uk, I could plot those shapes in an excel chart and the resultant map looked like the correct bits of the coastline. This was good enough for my purposes, but probably not what you need because: a) The test data set is huge. b) The pass criteria is subjective What we really need is a small set of simple polygons that definitely overlap with a box but were not detected by the old routines and are by the new one. However I also do not really know what you mean by "a pull request", or how to integrate my tests into the "test suite". Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 09 February 2014 08:19 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Hello Dan, Development for this module is now on github. https://github.com/shawnlaffan/Geo-ShapeFile Are you able to submit a pull request with these changes, and ideally some tests or an update to the test suite? Thanks, Shawn. On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> The Shapes in Area function misses out a LOT of overlapping shapes > because of an erroneous check_in_area test Here it the essential part > of check_in_area it stands: > my $lhit = self->between(x1_min,$x2_min,$x2,max); > my $rhit = self->between(x1_max,$x2_min,$x2,max); > my $thit = self->between(y1_min,$y2_min,$y2,max); > my $bhit = self->between(y1_max,$x2_min,$x2,max); > return (#collision > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && > $bhit) > ) || ( #containment > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && > $bhit) > ); > > This is does not return true if the two areas overlap on one side > only, it only fires if at least one corner of each shape is within the > other (or one contains the other) For instance the areas {0,10,0,10} > and {1,11,1,9}, which are obviously overlapping, are not detected by > the algorithm because: > between(x1_min,$x2_min,$x2,max) FALSE > between(x1_max,$x2_min,$x2,max) TRUE > between(y1_min,$y2_min,$y2,max) FALSE > between(y1_max,$x2_min,$x2,max) FALSE > Since only one of the tests is true the algorithm returns false > because it needs at least two of the tests to fire. > > A working algorithm only needs one line as follows: > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > $y2_max > or $y1_max < $y2_min); > > This has the beneficial side effect that it fires if A contains B AND > if B contains A, as well as if they overlap Therefore the call to > check_in_area in "shapes_in_area" can be optimised from the current: > If ($self->check_in_area(@p,@area) || $self->check_in_area(@area,@p)) > { > > To > > If ($self->check_in_area(@p,@area)) { > > Hope that is clear, if not contact me for a patch. > Dan Smith > ******************************************************************** > This email and any attachments are confidential to the intended > recipient and may also be privileged. If you are not the intended > recipient please delete it from your system and notify the sender. > You should not copy it or use it for any purpose nor disclose or > distribute its contents to any other person. > ********************************************************************
Thanks for the response Daniel. Could you send me the URL for the shapefiles? And also send me a bounding box which did not work? That way I can replicate the issue on my machine. Don't worry about the pull request and test suite. They're useful if you're able to edit the code and provide fixes via git (see, for example, https://help.github.com/articles/using-pull-requests ). Regards, Shawn. On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote: Show quoted text
> Thanks for getting back to me Shawn! > I may need a bit of hand holding > What I have here is a bugfixed version which I am using, I tested it > as follows: > > I downloaded a set of shapefiles which cover the whole of the earth > (openly available fom nasa) > I tested the new shapefile routines by using them to pull out the > shapes that overlap with a lat long box, and seeing that when I found > the shapes in a box containing (say) the arabian gulf, or the uk, I > could plot those shapes in an excel chart and the resultant map looked > like the correct bits of the coastline. > > This was good enough for my purposes, but probably not what you need > because: > > a) The test data set is huge. > b) The pass criteria is subjective > > What we really need is a small set of simple polygons that definitely > overlap with a box but were not detected by the old routines and are > by the new one. > > However I also do not really know what you mean by "a pull request", > or how to integrate my tests into the "test suite". > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited > Registered Office: Warwick House, PO Box 87, Farnborough Aerospace > Centre, Farnborough, Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > Please consider the environment before printing this email. > > -----Original Message----- > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > Sent: 09 February 2014 08:19 > To: Smith, Daniel E (UK) > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > ----------------------! WARNING ! ---------------------- This message > originates from outside our organisation, either from an external > partner or from the internet. > Consider carefully whether you should click on any links, open any > attachments or reply. > Follow the 'Report Suspicious Emails' link on IT matters for > instructions on reporting suspicious email messages. > -------------------------------------------------------- > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > Hello Dan, > > Development for this module is now on github. > https://github.com/shawnlaffan/Geo-ShapeFile > > Are you able to submit a pull request with these changes, and ideally > some tests or an update to the test suite? > > > Thanks, > Shawn. > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > The Shapes in Area function misses out a LOT of overlapping shapes > > because of an erroneous check_in_area test Here it the essential > > part > > of check_in_area it stands: > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > return (#collision > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && > > $bhit) > > ) || ( #containment > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit && > > $bhit) > > ); > > > > This is does not return true if the two areas overlap on one side > > only, it only fires if at least one corner of each shape is within > > the > > other (or one contains the other) For instance the areas {0,10,0,10} > > and {1,11,1,9}, which are obviously overlapping, are not detected by > > the algorithm because: > > between(x1_min,$x2_min,$x2,max) FALSE > > between(x1_max,$x2_min,$x2,max) TRUE > > between(y1_min,$y2_min,$y2,max) FALSE > > between(y1_max,$x2_min,$x2,max) FALSE > > Since only one of the tests is true the algorithm returns false > > because it needs at least two of the tests to fire. > > > > A working algorithm only needs one line as follows: > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > $y2_max > > or $y1_max < $y2_min); > > > > This has the beneficial side effect that it fires if A contains B AND > > if B contains A, as well as if they overlap Therefore the call to > > check_in_area in "shapes_in_area" can be optimised from the current: > > If ($self->check_in_area(@p,@area) || $self->check_in_area(@area,@p)) > > { > > > > To > > > > If ($self->check_in_area(@p,@area)) { > > > > Hope that is clear, if not contact me for a patch. > > Dan Smith > > ******************************************************************** > > This email and any attachments are confidential to the intended > > recipient and may also be privileged. If you are not the intended > > recipient please delete it from your system and notify the sender. > > You should not copy it or use it for any purpose nor disclose or > > distribute its contents to any other person. > > ********************************************************************
> > >
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Mon, 10 Feb 2014 20:29:45 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <Daniel.Smith [...] baesystems.com>
Hi I will do that tomorrow, I am at work at the moment and going home soon Do you have excel by the way, if so I can send you an excel 2010 (or 2003 if you like) analysis of what goes wrong In my original ticket, I mentioned shapes {0,10,0,10} and {1,11,1,9},: If you make one of those into a shape, and the other into a bounding box, you will see that the existing code says they do not overlap, but my improved code says they do overlap. If you draw them they obviously overlap too. Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 10 February 2014 20:13 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Thanks for the response Daniel. Could you send me the URL for the shapefiles? And also send me a bounding box which did not work? That way I can replicate the issue on my machine. Don't worry about the pull request and test suite. They're useful if you're able to edit the code and provide fixes via git (see, for example, https://help.github.com/articles/using-pull-requests ). Regards, Shawn. On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> Thanks for getting back to me Shawn! > I may need a bit of hand holding > What I have here is a bugfixed version which I am using, I tested it > as follows: > > I downloaded a set of shapefiles which cover the whole of the earth > (openly available fom nasa) I tested the new shapefile routines by > using them to pull out the shapes that overlap with a lat long box, > and seeing that when I found the shapes in a box containing (say) the > arabian gulf, or the uk, I could plot those shapes in an excel chart > and the resultant map looked like the correct bits of the coastline. > > This was good enough for my purposes, but probably not what you need > because: > > a) The test data set is huge. > b) The pass criteria is subjective > > What we really need is a small set of simple polygons that definitely > overlap with a box but were not detected by the old routines and are > by the new one. > > However I also do not really know what you mean by "a pull request", > or how to integrate my tests into the "test suite". > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited Registered Office: > Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, > Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > P Please consider the environment before printing this email. > > -----Original Message----- > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > Sent: 09 February 2014 08:19 > To: Smith, Daniel E (UK) > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > ----------------------! WARNING ! ---------------------- This message > originates from outside our organisation, either from an external > partner or from the internet. > Consider carefully whether you should click on any links, open any > attachments or reply. > Follow the 'Report Suspicious Emails' link on IT matters for > instructions on reporting suspicious email messages. > -------------------------------------------------------- > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > Hello Dan, > > Development for this module is now on github. > https://github.com/shawnlaffan/Geo-ShapeFile > > Are you able to submit a pull request with these changes, and ideally > some tests or an update to the test suite? > > > Thanks, > Shawn. > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > The Shapes in Area function misses out a LOT of overlapping shapes > > because of an erroneous check_in_area test Here it the essential > > part of check_in_area it stands: > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > return (#collision > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit > > && > > $bhit) > > ) || ( #containment > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit > > && > > $bhit) > > ); > > > > This is does not return true if the two areas overlap on one side > > only, it only fires if at least one corner of each shape is within > > the other (or one contains the other) For instance the areas > > {0,10,0,10} and {1,11,1,9}, which are obviously overlapping, are not > > detected by the algorithm because: > > between(x1_min,$x2_min,$x2,max) FALSE > > between(x1_max,$x2_min,$x2,max) TRUE > > between(y1_min,$y2_min,$y2,max) FALSE > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the tests is > > true the algorithm returns false because it needs at least two of > > the tests to fire. > > > > A working algorithm only needs one line as follows: > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > $y2_max or $y1_max < $y2_min); > > > > This has the beneficial side effect that it fires if A contains B > > AND if B contains A, as well as if they overlap Therefore the call > > to check_in_area in "shapes_in_area" can be optimised from the current: > > If ($self->check_in_area(@p,@area) || > > $self->check_in_area(@area,@p)) { > > > > To > > > > If ($self->check_in_area(@p,@area)) { > > > > Hope that is clear, if not contact me for a patch. > > Dan Smith > > ******************************************************************** > > This email and any attachments are confidential to the intended > > recipient and may also be privileged. If you are not the intended > > recipient please delete it from your system and notify the sender. > > You should not copy it or use it for any purpose nor disclose or > > distribute its contents to any other person. > > ********************************************************************
> > >
I do have excel (2010 and 2013), so please send it. The coords you sent should also server for debugging. I'll give them a go. Regards, Shawn. On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote: Show quoted text
> Hi > I will do that tomorrow, I am at work at the moment and going home > soon > Do you have excel by the way, if so I can send you an excel 2010 (or > 2003 if you like) analysis of what goes wrong > > In my original ticket, I mentioned shapes {0,10,0,10} and {1,11,1,9},: > If you make one of those into a shape, and the other into a bounding > box, you will see that the existing code says they do not overlap, but > my improved code says they do overlap. If you draw them they obviously > overlap too. > > > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited > Registered Office: Warwick House, PO Box 87, Farnborough Aerospace > Centre, Farnborough, Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > Please consider the environment before printing this email. > > > -----Original Message----- > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > Sent: 10 February 2014 20:13 > To: Smith, Daniel E (UK) > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > ----------------------! WARNING ! ---------------------- This message > originates from outside our organisation, either from an external > partner or from the internet. > Consider carefully whether you should click on any links, open any > attachments or reply. > Follow the 'Report Suspicious Emails' link on IT matters for > instructions on reporting suspicious email messages. > -------------------------------------------------------- > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > Thanks for the response Daniel. > > Could you send me the URL for the shapefiles? And also send me a > bounding box which did not work? That way I can replicate the issue on > my machine. > > Don't worry about the pull request and test suite. They're useful if > you're able to edit the code and provide fixes via git (see, for > example, https://help.github.com/articles/using-pull-requests ). > > Regards, > Shawn. > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > Thanks for getting back to me Shawn! > > I may need a bit of hand holding > > What I have here is a bugfixed version which I am using, I tested it > > as follows: > > > > I downloaded a set of shapefiles which cover the whole of the earth > > (openly available fom nasa) I tested the new shapefile routines by > > using them to pull out the shapes that overlap with a lat long box, > > and seeing that when I found the shapes in a box containing (say) the > > arabian gulf, or the uk, I could plot those shapes in an excel chart > > and the resultant map looked like the correct bits of the coastline. > > > > This was good enough for my purposes, but probably not what you need > > because: > > > > a) The test data set is huge. > > b) The pass criteria is subjective > > > > What we really need is a small set of simple polygons that definitely > > overlap with a box but were not detected by the old routines and are > > by the new one. > > > > However I also do not really know what you mean by "a pull request", > > or how to integrate my tests into the "test suite". > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered Office: > > Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, > > Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 09 February 2014 08:19 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This message > > originates from outside our organisation, either from an external > > partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Hello Dan, > > > > Development for this module is now on github. > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > Are you able to submit a pull request with these changes, and ideally > > some tests or an update to the test suite? > > > > > > Thanks, > > Shawn. > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > The Shapes in Area function misses out a LOT of overlapping shapes > > > because of an erroneous check_in_area test Here it the essential > > > part of check_in_area it stands: > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > return (#collision > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit > > > && > > > $bhit) > > > ) || ( #containment > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit > > > && > > > $bhit) > > > ); > > > > > > This is does not return true if the two areas overlap on one side > > > only, it only fires if at least one corner of each shape is within > > > the other (or one contains the other) For instance the areas > > > {0,10,0,10} and {1,11,1,9}, which are obviously overlapping, are > > > not > > > detected by the algorithm because: > > > between(x1_min,$x2_min,$x2,max) FALSE > > > between(x1_max,$x2_min,$x2,max) TRUE > > > between(y1_min,$y2_min,$y2,max) FALSE > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the tests > > > is > > > true the algorithm returns false because it needs at least two of > > > the tests to fire. > > > > > > A working algorithm only needs one line as follows: > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > $y2_max or $y1_max < $y2_min); > > > > > > This has the beneficial side effect that it fires if A contains B > > > AND if B contains A, as well as if they overlap Therefore the call > > > to check_in_area in "shapes_in_area" can be optimised from the > > > current: > > > If ($self->check_in_area(@p,@area) || > > > $self->check_in_area(@area,@p)) { > > > > > > To > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > Hope that is clear, if not contact me for a patch. > > > Dan Smith > > > ******************************************************************** > > > This email and any attachments are confidential to the intended > > > recipient and may also be privileged. If you are not the intended > > > recipient please delete it from your system and notify the sender. > > > You should not copy it or use it for any purpose nor disclose or > > > distribute its contents to any other person. > > > ********************************************************************
> > > > > >
> > >
Those coords turned out to be very useful. The between function is (was) returning false positives due to the use of the lower precedence "and". This means the max check is skipped when the min check passes, and the function returns true. I have fixed the issue, and the code is on github. It will be in the next release (planned for today). I've listed the optimisation as its own issue on github (I forgot about that in the last few posts). https://github.com/shawnlaffan/Geo-ShapeFile/issues/9 I'd also still appreciate the URL for the files, as I'm always on the lookout for data and they might be useful for other projects I have. Regards, Shawn. On Mon Feb 10 15:39:19 2014, SLAFFAN wrote: Show quoted text
> I do have excel (2010 and 2013), so please send it. > > The coords you sent should also server for debugging. I'll give them > a go. > > Regards, > Shawn. > > > On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote:
> > Hi > > I will do that tomorrow, I am at work at the moment and going home > > soon > > Do you have excel by the way, if so I can send you an excel 2010 (or > > 2003 if you like) analysis of what goes wrong > > > > In my original ticket, I mentioned shapes {0,10,0,10} and > > {1,11,1,9},: > > If you make one of those into a shape, and the other into a bounding > > box, you will see that the existing code says they do not overlap, > > but > > my improved code says they do overlap. If you draw them they > > obviously > > overlap too. > > > > > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited > > Registered Office: Warwick House, PO Box 87, Farnborough Aerospace > > Centre, Farnborough, Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > Please consider the environment before printing this email. > > > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 10 February 2014 20:13 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This message > > originates from outside our organisation, either from an external > > partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Thanks for the response Daniel. > > > > Could you send me the URL for the shapefiles? And also send me a > > bounding box which did not work? That way I can replicate the issue > > on > > my machine. > > > > Don't worry about the pull request and test suite. They're useful if > > you're able to edit the code and provide fixes via git (see, for > > example, https://help.github.com/articles/using-pull-requests ). > > > > Regards, > > Shawn. > > > > > > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > > Thanks for getting back to me Shawn! > > > I may need a bit of hand holding > > > What I have here is a bugfixed version which I am using, I tested > > > it > > > as follows: > > > > > > I downloaded a set of shapefiles which cover the whole of the earth > > > (openly available fom nasa) I tested the new shapefile routines by > > > using them to pull out the shapes that overlap with a lat long box, > > > and seeing that when I found the shapes in a box containing (say) > > > the > > > arabian gulf, or the uk, I could plot those shapes in an excel > > > chart > > > and the resultant map looked like the correct bits of the > > > coastline. > > > > > > This was good enough for my purposes, but probably not what you > > > need > > > because: > > > > > > a) The test data set is huge. > > > b) The pass criteria is subjective > > > > > > What we really need is a small set of simple polygons that > > > definitely > > > overlap with a box but were not detected by the old routines and > > > are > > > by the new one. > > > > > > However I also do not really know what you mean by "a pull > > > request", > > > or how to integrate my tests into the "test suite". > > > > > > Daniel Smith > > > Radar Systems Engineer, Sampson > > > BAE Systems Maritime Services, > > > Newport Road, > > > Cowes, > > > Isle of Wight, PO31 8PF, UK > > > I: +44 (0) 198320 2937 > > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > > > BAE Systems Integrated System Technologies Limited Registered > > > Office: > > > Warwick House, PO Box 87, Farnborough Aerospace Centre, > > > Farnborough, > > > Hants, GU14 6YU, UK. > > > Registered in England & Wales No: 3456325 > > > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > > Sent: 09 February 2014 08:19 > > > To: Smith, Daniel E (UK) > > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > > > ----------------------! WARNING ! ---------------------- This > > > message > > > originates from outside our organisation, either from an external > > > partner or from the internet. > > > Consider carefully whether you should click on any links, open any > > > attachments or reply. > > > Follow the 'Report Suspicious Emails' link on IT matters for > > > instructions on reporting suspicious email messages. > > > -------------------------------------------------------- > > > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > > > Hello Dan, > > > > > > Development for this module is now on github. > > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > > > Are you able to submit a pull request with these changes, and > > > ideally > > > some tests or an update to the test suite? > > > > > > > > > Thanks, > > > Shawn. > > > > > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > > The Shapes in Area function misses out a LOT of overlapping > > > > shapes > > > > because of an erroneous check_in_area test Here it the essential > > > > part of check_in_area it stands: > > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > > return (#collision > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit > > > > && > > > > $bhit) > > > > ) || ( #containment > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit > > > > && > > > > $bhit) > > > > ); > > > > > > > > This is does not return true if the two areas overlap on one > > > > side > > > > only, it only fires if at least one corner of each shape is > > > > within > > > > the other (or one contains the other) For instance the areas > > > > {0,10,0,10} and {1,11,1,9}, which are obviously overlapping, are > > > > not > > > > detected by the algorithm because: > > > > between(x1_min,$x2_min,$x2,max) FALSE > > > > between(x1_max,$x2_min,$x2,max) TRUE > > > > between(y1_min,$y2_min,$y2,max) FALSE > > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the tests > > > > is > > > > true the algorithm returns false because it needs at least two of > > > > the tests to fire. > > > > > > > > A working algorithm only needs one line as follows: > > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > > $y2_max or $y1_max < $y2_min); > > > > > > > > This has the beneficial side effect that it fires if A contains B > > > > AND if B contains A, as well as if they overlap Therefore the > > > > call > > > > to check_in_area in "shapes_in_area" can be optimised from the > > > > current: > > > > If ($self->check_in_area(@p,@area) || > > > > $self->check_in_area(@area,@p)) { > > > > > > > > To > > > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > > > Hope that is clear, if not contact me for a patch. > > > > Dan Smith > > > > ******************************************************************** > > > > This email and any attachments are confidential to the intended > > > > recipient and may also be privileged. If you are not the intended > > > > recipient please delete it from your system and notify the > > > > sender. > > > > You should not copy it or use it for any purpose nor disclose or > > > > distribute its contents to any other person. > > > > ********************************************************************
> > > > > > > > >
> > > > > >
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Tue, 11 Feb 2014 12:24:38 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith [...] baesystems.com>
OK! The attached zip file contains my land map generator (which outputs a .csv can be plotted in excel as a line chart to show a map), and my modified versions of geo files, which were based on geo 2.51 (I couldn't find 2.51 any more on cpan, so my windiff comparison with the cpan version was not very useful (as you have made so many useful changes!) perhaps you have access to version 2.51 and can run a dif?) I downloaded geo 2.54 from cpan and have tried that out, it gives identical results, as is shown in the enclosed spreadsheet The only measurable difference between geo 2.54 and mine is that with 2.54 the csv generation took 40 seconds, and with mine it took 35. The difference is probably my mod to get_part in shape.pm, where I have made it use "wantarray" appropriately, so with my modified file I can say: my $part_ptr = $shape->get_part($part); Whereas with 2.54 I had to change that to My $part_ptr = [($shape->get_part($part))]; Which probably takes a bit longer as arrays have to be generated, sliced, and chucked around inside get_part Perhaps you could release a 2.55 with all your changes (which look very good) plus a get_part that returns a pointer if wanted? This makes it similar to get_points etc. Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 10 February 2014 20:39 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > I do have excel (2010 and 2013), so please send it. The coords you sent should also server for debugging. I'll give them a go. Regards, Shawn. On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote:
> Hi > I will do that tomorrow, I am at work at the moment and going home > soon Do you have excel by the way, if so I can send you an excel 2010 > (or > 2003 if you like) analysis of what goes wrong > > In my original ticket, I mentioned shapes {0,10,0,10} and {1,11,1,9},: > If you make one of those into a shape, and the other into a bounding > box, you will see that the existing code says they do not overlap, but > my improved code says they do overlap. If you draw them they obviously > overlap too. > > > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited Registered Office: > Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, > Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > P Please consider the environment before printing this email. > > > -----Original Message----- > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > Sent: 10 February 2014 20:13 > To: Smith, Daniel E (UK) > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > ----------------------! WARNING ! ---------------------- This message > originates from outside our organisation, either from an external > partner or from the internet. > Consider carefully whether you should click on any links, open any > attachments or reply. > Follow the 'Report Suspicious Emails' link on IT matters for > instructions on reporting suspicious email messages. > -------------------------------------------------------- > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > Thanks for the response Daniel. > > Could you send me the URL for the shapefiles? And also send me a > bounding box which did not work? That way I can replicate the issue on > my machine. > > Don't worry about the pull request and test suite. They're useful if > you're able to edit the code and provide fixes via git (see, for > example, https://help.github.com/articles/using-pull-requests ). > > Regards, > Shawn. > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > Thanks for getting back to me Shawn! > > I may need a bit of hand holding > > What I have here is a bugfixed version which I am using, I tested > > it as follows: > > > > I downloaded a set of shapefiles which cover the whole of the earth > > (openly available fom nasa) I tested the new shapefile routines by > > using them to pull out the shapes that overlap with a lat long box, > > and seeing that when I found the shapes in a box containing (say) > > the arabian gulf, or the uk, I could plot those shapes in an excel > > chart and the resultant map looked like the correct bits of the coastline. > > > > This was good enough for my purposes, but probably not what you need > > because: > > > > a) The test data set is huge. > > b) The pass criteria is subjective > > > > What we really need is a small set of simple polygons that > > definitely overlap with a box but were not detected by the old > > routines and are by the new one. > > > > However I also do not really know what you mean by "a pull request", > > or how to integrate my tests into the "test suite". > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered Office: > > Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, > > Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 09 February 2014 08:19 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This > > message originates from outside our organisation, either from an > > external partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Hello Dan, > > > > Development for this module is now on github. > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > Are you able to submit a pull request with these changes, and > > ideally some tests or an update to the test suite? > > > > > > Thanks, > > Shawn. > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > The Shapes in Area function misses out a LOT of overlapping shapes > > > because of an erroneous check_in_area test Here it the essential > > > part of check_in_area it stands: > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > return (#collision > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit > > > && > > > $bhit) > > > ) || ( #containment > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || ($rhit > > > && > > > $bhit) > > > ); > > > > > > This is does not return true if the two areas overlap on one side > > > only, it only fires if at least one corner of each shape is within > > > the other (or one contains the other) For instance the areas > > > {0,10,0,10} and {1,11,1,9}, which are obviously overlapping, are > > > not detected by the algorithm because: > > > between(x1_min,$x2_min,$x2,max) FALSE > > > between(x1_max,$x2_min,$x2,max) TRUE > > > between(y1_min,$y2_min,$y2,max) FALSE > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the tests > > > is true the algorithm returns false because it needs at least two > > > of the tests to fire. > > > > > > A working algorithm only needs one line as follows: > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > $y2_max or $y1_max < $y2_min); > > > > > > This has the beneficial side effect that it fires if A contains B > > > AND if B contains A, as well as if they overlap Therefore the call > > > to check_in_area in "shapes_in_area" can be optimised from the > > > current: > > > If ($self->check_in_area(@p,@area) || > > > $self->check_in_area(@area,@p)) { > > > > > > To > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > Hope that is clear, if not contact me for a patch. > > > Dan Smith > > > ****************************************************************** > > > ** This email and any attachments are confidential to the intended > > > recipient and may also be privileged. If you are not the intended > > > recipient please delete it from your system and notify the sender. > > > You should not copy it or use it for any purpose nor disclose or > > > distribute its contents to any other person. > > > ****************************************************************** > > > **
> > > > > >
> > >
Download landmap_gen.zip
application/x-zip-compressed 8.6m

Message body not shown because it is not plain text.

Sending the previous mail has failed. Please contact your admin, they can find more details in the logs.
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Tue, 11 Feb 2014 12:52:51 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith [...] baesystems.com>
Hi, I've just read this The files you need are (it is mentioned in the readme in the previous zip too) in: https://hiu.state.gov/data/data.aspx To use my script with them you need to download the americas and europe world polygons (top two links there) and unzip them to a load of flat files in the binary_maps directory of my perl script, it looks at them by name I hope all that works and my perl is not *too* dumb! Writing perl is certainly not my main job. Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 10 February 2014 21:43 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Those coords turned out to be very useful. The between function is (was) returning false positives due to the use of the lower precedence "and". This means the max check is skipped when the min check passes, and the function returns true. I have fixed the issue, and the code is on github. It will be in the next release (planned for today). I've listed the optimisation as its own issue on github (I forgot about that in the last few posts). https://github.com/shawnlaffan/Geo-ShapeFile/issues/9 I'd also still appreciate the URL for the files, as I'm always on the lookout for data and they might be useful for other projects I have. Regards, Shawn. On Mon Feb 10 15:39:19 2014, SLAFFAN wrote:
> I do have excel (2010 and 2013), so please send it. > > The coords you sent should also server for debugging. I'll give them > a go. > > Regards, > Shawn. > > > On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote:
> > Hi > > I will do that tomorrow, I am at work at the moment and going home > > soon Do you have excel by the way, if so I can send you an excel > > 2010 (or > > 2003 if you like) analysis of what goes wrong > > > > In my original ticket, I mentioned shapes {0,10,0,10} and > > {1,11,1,9},: > > If you make one of those into a shape, and the other into a bounding > > box, you will see that the existing code says they do not overlap, > > but my improved code says they do overlap. If you draw them they > > obviously overlap too. > > > > > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered > > Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, > > Farnborough, Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 10 February 2014 20:13 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This > > message originates from outside our organisation, either from an > > external partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Thanks for the response Daniel. > > > > Could you send me the URL for the shapefiles? And also send me a > > bounding box which did not work? That way I can replicate the issue > > on my machine. > > > > Don't worry about the pull request and test suite. They're useful > > if you're able to edit the code and provide fixes via git (see, for > > example, https://help.github.com/articles/using-pull-requests ). > > > > Regards, > > Shawn. > > > > > > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > > Thanks for getting back to me Shawn! > > > I may need a bit of hand holding > > > What I have here is a bugfixed version which I am using, I tested > > > it as follows: > > > > > > I downloaded a set of shapefiles which cover the whole of the > > > earth (openly available fom nasa) I tested the new shapefile > > > routines by using them to pull out the shapes that overlap with a > > > lat long box, and seeing that when I found the shapes in a box > > > containing (say) the arabian gulf, or the uk, I could plot those > > > shapes in an excel chart and the resultant map looked like the > > > correct bits of the coastline. > > > > > > This was good enough for my purposes, but probably not what you > > > need > > > because: > > > > > > a) The test data set is huge. > > > b) The pass criteria is subjective > > > > > > What we really need is a small set of simple polygons that > > > definitely overlap with a box but were not detected by the old > > > routines and are by the new one. > > > > > > However I also do not really know what you mean by "a pull > > > request", or how to integrate my tests into the "test suite". > > > > > > Daniel Smith > > > Radar Systems Engineer, Sampson > > > BAE Systems Maritime Services, > > > Newport Road, > > > Cowes, > > > Isle of Wight, PO31 8PF, UK > > > I: +44 (0) 198320 2937 > > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > > > BAE Systems Integrated System Technologies Limited Registered > > > Office: > > > Warwick House, PO Box 87, Farnborough Aerospace Centre, > > > Farnborough, Hants, GU14 6YU, UK. > > > Registered in England & Wales No: 3456325 > > > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > > Sent: 09 February 2014 08:19 > > > To: Smith, Daniel E (UK) > > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > > > ----------------------! WARNING ! ---------------------- This > > > message originates from outside our organisation, either from an > > > external partner or from the internet. > > > Consider carefully whether you should click on any links, open any > > > attachments or reply. > > > Follow the 'Report Suspicious Emails' link on IT matters for > > > instructions on reporting suspicious email messages. > > > -------------------------------------------------------- > > > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > > > Hello Dan, > > > > > > Development for this module is now on github. > > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > > > Are you able to submit a pull request with these changes, and > > > ideally some tests or an update to the test suite? > > > > > > > > > Thanks, > > > Shawn. > > > > > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > > The Shapes in Area function misses out a LOT of overlapping > > > > shapes because of an erroneous check_in_area test Here it the > > > > essential part of check_in_area it stands: > > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > > return (#collision > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ) || ( #containment > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ); > > > > > > > > This is does not return true if the two areas overlap on one > > > > side only, it only fires if at least one corner of each shape is > > > > within the other (or one contains the other) For instance the > > > > areas {0,10,0,10} and {1,11,1,9}, which are obviously > > > > overlapping, are not detected by the algorithm because: > > > > between(x1_min,$x2_min,$x2,max) FALSE > > > > between(x1_max,$x2_min,$x2,max) TRUE > > > > between(y1_min,$y2_min,$y2,max) FALSE > > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the > > > > tests is true the algorithm returns false because it needs at > > > > least two of the tests to fire. > > > > > > > > A working algorithm only needs one line as follows: > > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > > $y2_max or $y1_max < $y2_min); > > > > > > > > This has the beneficial side effect that it fires if A contains > > > > B AND if B contains A, as well as if they overlap Therefore the > > > > call to check_in_area in "shapes_in_area" can be optimised from > > > > the > > > > current: > > > > If ($self->check_in_area(@p,@area) || > > > > $self->check_in_area(@area,@p)) { > > > > > > > > To > > > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > > > Hope that is clear, if not contact me for a patch. > > > > Dan Smith > > > > **************************************************************** > > > > **** This email and any attachments are confidential to the > > > > intended recipient and may also be privileged. If you are not > > > > the intended recipient please delete it from your system and > > > > notify the sender. > > > > You should not copy it or use it for any purpose nor disclose or > > > > distribute its contents to any other person. > > > > **************************************************************** > > > > ****
> > > > > > > > >
> > > > > >
******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Tue, 11 Feb 2014 13:11:19 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith [...] baesystems.com>
Yes, I agree with you about the between function not working, but I can't see any low precedence and in it, they all look like high precedence ones. maybe I fixed them and forgot about it. Personally I always use low precedence Boolean functions unless I really need the high precedence ones, as they usually reduce the number of brackets needed and more often work the way you think they should. I also think that the way it written with the between function made it hard to review and spot the bug. By the way, the shapefile.pm I sent you has a slightly (and unimportantly) difference check_in_area, the method I suggested on cpan was: !(a or b or c or d) When a, b, c and d are the tests eg "s1_max < s2_min" But when I did this to my own file I though it was a bit neater to change to the equivalent: (a' and b' and c' and d') And reverse the tests to (e.g) S1_max >= s2_min It can be done either way around of course, makes no practical difference Cheers Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 10 February 2014 21:43 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Those coords turned out to be very useful. The between function is (was) returning false positives due to the use of the lower precedence "and". This means the max check is skipped when the min check passes, and the function returns true. I have fixed the issue, and the code is on github. It will be in the next release (planned for today). I've listed the optimisation as its own issue on github (I forgot about that in the last few posts). https://github.com/shawnlaffan/Geo-ShapeFile/issues/9 I'd also still appreciate the URL for the files, as I'm always on the lookout for data and they might be useful for other projects I have. Regards, Shawn. On Mon Feb 10 15:39:19 2014, SLAFFAN wrote:
> I do have excel (2010 and 2013), so please send it. > > The coords you sent should also server for debugging. I'll give them > a go. > > Regards, > Shawn. > > > On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote:
> > Hi > > I will do that tomorrow, I am at work at the moment and going home > > soon Do you have excel by the way, if so I can send you an excel > > 2010 (or > > 2003 if you like) analysis of what goes wrong > > > > In my original ticket, I mentioned shapes {0,10,0,10} and > > {1,11,1,9},: > > If you make one of those into a shape, and the other into a bounding > > box, you will see that the existing code says they do not overlap, > > but my improved code says they do overlap. If you draw them they > > obviously overlap too. > > > > > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered > > Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, > > Farnborough, Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 10 February 2014 20:13 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This > > message originates from outside our organisation, either from an > > external partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Thanks for the response Daniel. > > > > Could you send me the URL for the shapefiles? And also send me a > > bounding box which did not work? That way I can replicate the issue > > on my machine. > > > > Don't worry about the pull request and test suite. They're useful > > if you're able to edit the code and provide fixes via git (see, for > > example, https://help.github.com/articles/using-pull-requests ). > > > > Regards, > > Shawn. > > > > > > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > > Thanks for getting back to me Shawn! > > > I may need a bit of hand holding > > > What I have here is a bugfixed version which I am using, I tested > > > it as follows: > > > > > > I downloaded a set of shapefiles which cover the whole of the > > > earth (openly available fom nasa) I tested the new shapefile > > > routines by using them to pull out the shapes that overlap with a > > > lat long box, and seeing that when I found the shapes in a box > > > containing (say) the arabian gulf, or the uk, I could plot those > > > shapes in an excel chart and the resultant map looked like the > > > correct bits of the coastline. > > > > > > This was good enough for my purposes, but probably not what you > > > need > > > because: > > > > > > a) The test data set is huge. > > > b) The pass criteria is subjective > > > > > > What we really need is a small set of simple polygons that > > > definitely overlap with a box but were not detected by the old > > > routines and are by the new one. > > > > > > However I also do not really know what you mean by "a pull > > > request", or how to integrate my tests into the "test suite". > > > > > > Daniel Smith > > > Radar Systems Engineer, Sampson > > > BAE Systems Maritime Services, > > > Newport Road, > > > Cowes, > > > Isle of Wight, PO31 8PF, UK > > > I: +44 (0) 198320 2937 > > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > > > BAE Systems Integrated System Technologies Limited Registered > > > Office: > > > Warwick House, PO Box 87, Farnborough Aerospace Centre, > > > Farnborough, Hants, GU14 6YU, UK. > > > Registered in England & Wales No: 3456325 > > > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > > Sent: 09 February 2014 08:19 > > > To: Smith, Daniel E (UK) > > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > > > ----------------------! WARNING ! ---------------------- This > > > message originates from outside our organisation, either from an > > > external partner or from the internet. > > > Consider carefully whether you should click on any links, open any > > > attachments or reply. > > > Follow the 'Report Suspicious Emails' link on IT matters for > > > instructions on reporting suspicious email messages. > > > -------------------------------------------------------- > > > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > > > Hello Dan, > > > > > > Development for this module is now on github. > > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > > > Are you able to submit a pull request with these changes, and > > > ideally some tests or an update to the test suite? > > > > > > > > > Thanks, > > > Shawn. > > > > > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > > The Shapes in Area function misses out a LOT of overlapping > > > > shapes because of an erroneous check_in_area test Here it the > > > > essential part of check_in_area it stands: > > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > > return (#collision > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ) || ( #containment > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ); > > > > > > > > This is does not return true if the two areas overlap on one > > > > side only, it only fires if at least one corner of each shape is > > > > within the other (or one contains the other) For instance the > > > > areas {0,10,0,10} and {1,11,1,9}, which are obviously > > > > overlapping, are not detected by the algorithm because: > > > > between(x1_min,$x2_min,$x2,max) FALSE > > > > between(x1_max,$x2_min,$x2,max) TRUE > > > > between(y1_min,$y2_min,$y2,max) FALSE > > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the > > > > tests is true the algorithm returns false because it needs at > > > > least two of the tests to fire. > > > > > > > > A working algorithm only needs one line as follows: > > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > > $y2_max or $y1_max < $y2_min); > > > > > > > > This has the beneficial side effect that it fires if A contains > > > > B AND if B contains A, as well as if they overlap Therefore the > > > > call to check_in_area in "shapes_in_area" can be optimised from > > > > the > > > > current: > > > > If ($self->check_in_area(@p,@area) || > > > > $self->check_in_area(@area,@p)) { > > > > > > > > To > > > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > > > Hope that is clear, if not contact me for a patch. > > > > Dan Smith > > > > **************************************************************** > > > > **** This email and any attachments are confidential to the > > > > intended recipient and may also be privileged. If you are not > > > > the intended recipient please delete it from your system and > > > > notify the sender. > > > > You should not copy it or use it for any purpose nor disclose or > > > > distribute its contents to any other person. > > > > **************************************************************** > > > > ****
> > > > > > > > >
> > > > > >
******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Tue, 11 Feb 2014 13:48:11 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith [...] baesystems.com>
Ok, by the way, I think that the dependencies in https://github.com/shawnlaffan/Geo-ShapeFile are missing parent.pm? At least, I had to download parent.pm to get the new version working Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 10 February 2014 21:43 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Those coords turned out to be very useful. The between function is (was) returning false positives due to the use of the lower precedence "and". This means the max check is skipped when the min check passes, and the function returns true. I have fixed the issue, and the code is on github. It will be in the next release (planned for today). I've listed the optimisation as its own issue on github (I forgot about that in the last few posts). https://github.com/shawnlaffan/Geo-ShapeFile/issues/9 I'd also still appreciate the URL for the files, as I'm always on the lookout for data and they might be useful for other projects I have. Regards, Shawn. On Mon Feb 10 15:39:19 2014, SLAFFAN wrote:
> I do have excel (2010 and 2013), so please send it. > > The coords you sent should also server for debugging. I'll give them > a go. > > Regards, > Shawn. > > > On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote:
> > Hi > > I will do that tomorrow, I am at work at the moment and going home > > soon Do you have excel by the way, if so I can send you an excel > > 2010 (or > > 2003 if you like) analysis of what goes wrong > > > > In my original ticket, I mentioned shapes {0,10,0,10} and > > {1,11,1,9},: > > If you make one of those into a shape, and the other into a bounding > > box, you will see that the existing code says they do not overlap, > > but my improved code says they do overlap. If you draw them they > > obviously overlap too. > > > > > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered > > Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, > > Farnborough, Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 10 February 2014 20:13 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This > > message originates from outside our organisation, either from an > > external partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Thanks for the response Daniel. > > > > Could you send me the URL for the shapefiles? And also send me a > > bounding box which did not work? That way I can replicate the issue > > on my machine. > > > > Don't worry about the pull request and test suite. They're useful > > if you're able to edit the code and provide fixes via git (see, for > > example, https://help.github.com/articles/using-pull-requests ). > > > > Regards, > > Shawn. > > > > > > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > > Thanks for getting back to me Shawn! > > > I may need a bit of hand holding > > > What I have here is a bugfixed version which I am using, I tested > > > it as follows: > > > > > > I downloaded a set of shapefiles which cover the whole of the > > > earth (openly available fom nasa) I tested the new shapefile > > > routines by using them to pull out the shapes that overlap with a > > > lat long box, and seeing that when I found the shapes in a box > > > containing (say) the arabian gulf, or the uk, I could plot those > > > shapes in an excel chart and the resultant map looked like the > > > correct bits of the coastline. > > > > > > This was good enough for my purposes, but probably not what you > > > need > > > because: > > > > > > a) The test data set is huge. > > > b) The pass criteria is subjective > > > > > > What we really need is a small set of simple polygons that > > > definitely overlap with a box but were not detected by the old > > > routines and are by the new one. > > > > > > However I also do not really know what you mean by "a pull > > > request", or how to integrate my tests into the "test suite". > > > > > > Daniel Smith > > > Radar Systems Engineer, Sampson > > > BAE Systems Maritime Services, > > > Newport Road, > > > Cowes, > > > Isle of Wight, PO31 8PF, UK > > > I: +44 (0) 198320 2937 > > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > > > BAE Systems Integrated System Technologies Limited Registered > > > Office: > > > Warwick House, PO Box 87, Farnborough Aerospace Centre, > > > Farnborough, Hants, GU14 6YU, UK. > > > Registered in England & Wales No: 3456325 > > > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > > Sent: 09 February 2014 08:19 > > > To: Smith, Daniel E (UK) > > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > > > ----------------------! WARNING ! ---------------------- This > > > message originates from outside our organisation, either from an > > > external partner or from the internet. > > > Consider carefully whether you should click on any links, open any > > > attachments or reply. > > > Follow the 'Report Suspicious Emails' link on IT matters for > > > instructions on reporting suspicious email messages. > > > -------------------------------------------------------- > > > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > > > Hello Dan, > > > > > > Development for this module is now on github. > > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > > > Are you able to submit a pull request with these changes, and > > > ideally some tests or an update to the test suite? > > > > > > > > > Thanks, > > > Shawn. > > > > > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > > The Shapes in Area function misses out a LOT of overlapping > > > > shapes because of an erroneous check_in_area test Here it the > > > > essential part of check_in_area it stands: > > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > > return (#collision > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ) || ( #containment > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ); > > > > > > > > This is does not return true if the two areas overlap on one > > > > side only, it only fires if at least one corner of each shape is > > > > within the other (or one contains the other) For instance the > > > > areas {0,10,0,10} and {1,11,1,9}, which are obviously > > > > overlapping, are not detected by the algorithm because: > > > > between(x1_min,$x2_min,$x2,max) FALSE > > > > between(x1_max,$x2_min,$x2,max) TRUE > > > > between(y1_min,$y2_min,$y2,max) FALSE > > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the > > > > tests is true the algorithm returns false because it needs at > > > > least two of the tests to fire. > > > > > > > > A working algorithm only needs one line as follows: > > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > > $y2_max or $y1_max < $y2_min); > > > > > > > > This has the beneficial side effect that it fires if A contains > > > > B AND if B contains A, as well as if they overlap Therefore the > > > > call to check_in_area in "shapes_in_area" can be optimised from > > > > the > > > > current: > > > > If ($self->check_in_area(@p,@area) || > > > > $self->check_in_area(@area,@p)) { > > > > > > > > To > > > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > > > Hope that is clear, if not contact me for a patch. > > > > Dan Smith > > > > **************************************************************** > > > > **** This email and any attachments are confidential to the > > > > intended recipient and may also be privileged. If you are not > > > > the intended recipient please delete it from your system and > > > > notify the sender. > > > > You should not copy it or use it for any purpose nor disclose or > > > > distribute its contents to any other person. > > > > **************************************************************** > > > > ****
> > > > > > > > >
> > > > > >
******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Tue, 11 Feb 2014 14:43:06 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <Daniel.Smith [...] baesystems.com>
I have found what I think is the old code: I don't think the problem was with the priority on "and", I reckon (I described it on cpan as well) that the issue is with check_area Basically this fires if: a) One or more of the corners of the first rectangle is in the second rectangle b) The first rectangle totally contains the second rectangle however what creeps through its net, (because the algorithm is totally flawed) is the case where: The side of the first rectangle passes through the second rectangle but none of the corners of the first rectangle are within the second rectangle Its easy to come up with this, if you draw a big first rectangle, and a small second rectangle which overlap on one side ---------- | -- |---------- | | | | | - |---------- ---------- Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 10 February 2014 21:43 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Those coords turned out to be very useful. The between function is (was) returning false positives due to the use of the lower precedence "and". This means the max check is skipped when the min check passes, and the function returns true. I have fixed the issue, and the code is on github. It will be in the next release (planned for today). I've listed the optimisation as its own issue on github (I forgot about that in the last few posts). https://github.com/shawnlaffan/Geo-ShapeFile/issues/9 I'd also still appreciate the URL for the files, as I'm always on the lookout for data and they might be useful for other projects I have. Regards, Shawn. On Mon Feb 10 15:39:19 2014, SLAFFAN wrote:
> I do have excel (2010 and 2013), so please send it. > > The coords you sent should also server for debugging. I'll give them > a go. > > Regards, > Shawn. > > > On Mon Feb 10 15:29:57 2014, daniel.smith@baesystems.com wrote:
> > Hi > > I will do that tomorrow, I am at work at the moment and going home > > soon Do you have excel by the way, if so I can send you an excel > > 2010 (or > > 2003 if you like) analysis of what goes wrong > > > > In my original ticket, I mentioned shapes {0,10,0,10} and > > {1,11,1,9},: > > If you make one of those into a shape, and the other into a bounding > > box, you will see that the existing code says they do not overlap, > > but my improved code says they do overlap. If you draw them they > > obviously overlap too. > > > > > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered > > Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, > > Farnborough, Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > Sent: 10 February 2014 20:13 > > To: Smith, Daniel E (UK) > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > ----------------------! WARNING ! ---------------------- This > > message originates from outside our organisation, either from an > > external partner or from the internet. > > Consider carefully whether you should click on any links, open any > > attachments or reply. > > Follow the 'Report Suspicious Emails' link on IT matters for > > instructions on reporting suspicious email messages. > > -------------------------------------------------------- > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > Thanks for the response Daniel. > > > > Could you send me the URL for the shapefiles? And also send me a > > bounding box which did not work? That way I can replicate the issue > > on my machine. > > > > Don't worry about the pull request and test suite. They're useful > > if you're able to edit the code and provide fixes via git (see, for > > example, https://help.github.com/articles/using-pull-requests ). > > > > Regards, > > Shawn. > > > > > > > > > > On Mon Feb 10 07:08:06 2014, daniel.smith@baesystems.com wrote:
> > > Thanks for getting back to me Shawn! > > > I may need a bit of hand holding > > > What I have here is a bugfixed version which I am using, I tested > > > it as follows: > > > > > > I downloaded a set of shapefiles which cover the whole of the > > > earth (openly available fom nasa) I tested the new shapefile > > > routines by using them to pull out the shapes that overlap with a > > > lat long box, and seeing that when I found the shapes in a box > > > containing (say) the arabian gulf, or the uk, I could plot those > > > shapes in an excel chart and the resultant map looked like the > > > correct bits of the coastline. > > > > > > This was good enough for my purposes, but probably not what you > > > need > > > because: > > > > > > a) The test data set is huge. > > > b) The pass criteria is subjective > > > > > > What we really need is a small set of simple polygons that > > > definitely overlap with a box but were not detected by the old > > > routines and are by the new one. > > > > > > However I also do not really know what you mean by "a pull > > > request", or how to integrate my tests into the "test suite". > > > > > > Daniel Smith > > > Radar Systems Engineer, Sampson > > > BAE Systems Maritime Services, > > > Newport Road, > > > Cowes, > > > Isle of Wight, PO31 8PF, UK > > > I: +44 (0) 198320 2937 > > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > > > BAE Systems Integrated System Technologies Limited Registered > > > Office: > > > Warwick House, PO Box 87, Farnborough Aerospace Centre, > > > Farnborough, Hants, GU14 6YU, UK. > > > Registered in England & Wales No: 3456325 > > > > > > P Please consider the environment before printing this email. > > > > > > -----Original Message----- > > > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > > > Sent: 09 February 2014 08:19 > > > To: Smith, Daniel E (UK) > > > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > > > > > ----------------------! WARNING ! ---------------------- This > > > message originates from outside our organisation, either from an > > > external partner or from the internet. > > > Consider carefully whether you should click on any links, open any > > > attachments or reply. > > > Follow the 'Report Suspicious Emails' link on IT matters for > > > instructions on reporting suspicious email messages. > > > -------------------------------------------------------- > > > > > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > > > > > Hello Dan, > > > > > > Development for this module is now on github. > > > https://github.com/shawnlaffan/Geo-ShapeFile > > > > > > Are you able to submit a pull request with these changes, and > > > ideally some tests or an update to the test suite? > > > > > > > > > Thanks, > > > Shawn. > > > > > > > > > > > > On Wed Oct 16 11:49:28 2013, daniel.smith@baesystems.com wrote:
> > > > The Shapes in Area function misses out a LOT of overlapping > > > > shapes because of an erroneous check_in_area test Here it the > > > > essential part of check_in_area it stands: > > > > my $lhit = self->between(x1_min,$x2_min,$x2,max); > > > > my $rhit = self->between(x1_max,$x2_min,$x2,max); > > > > my $thit = self->between(y1_min,$y2_min,$y2,max); > > > > my $bhit = self->between(y1_max,$x2_min,$x2,max); > > > > return (#collision > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ) || ( #containment > > > > ($lhit && $thit) || ($rhit && $thit) || ($lhit && $bhit) || > > > > ($rhit && > > > > $bhit) > > > > ); > > > > > > > > This is does not return true if the two areas overlap on one > > > > side only, it only fires if at least one corner of each shape is > > > > within the other (or one contains the other) For instance the > > > > areas {0,10,0,10} and {1,11,1,9}, which are obviously > > > > overlapping, are not detected by the algorithm because: > > > > between(x1_min,$x2_min,$x2,max) FALSE > > > > between(x1_max,$x2_min,$x2,max) TRUE > > > > between(y1_min,$y2_min,$y2,max) FALSE > > > > between(y1_max,$x2_min,$x2,max) FALSE Since only one of the > > > > tests is true the algorithm returns false because it needs at > > > > least two of the tests to fire. > > > > > > > > A working algorithm only needs one line as follows: > > > > return !($x1_min > $x2_max or $x1_max < $x2_min or $y1_min > > > > > $y2_max or $y1_max < $y2_min); > > > > > > > > This has the beneficial side effect that it fires if A contains > > > > B AND if B contains A, as well as if they overlap Therefore the > > > > call to check_in_area in "shapes_in_area" can be optimised from > > > > the > > > > current: > > > > If ($self->check_in_area(@p,@area) || > > > > $self->check_in_area(@area,@p)) { > > > > > > > > To > > > > > > > > If ($self->check_in_area(@p,@area)) { > > > > > > > > Hope that is clear, if not contact me for a patch. > > > > Dan Smith > > > > **************************************************************** > > > > **** This email and any attachments are confidential to the > > > > intended recipient and may also be privileged. If you are not > > > > the intended recipient please delete it from your system and > > > > notify the sender. > > > > You should not copy it or use it for any purpose nor disclose or > > > > distribute its contents to any other person. > > > > **************************************************************** > > > > ****
> > > > > > > > >
> > > > > >
******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************

Message body is not shown because it is too large.

Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Wed, 12 Feb 2014 13:20:06 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <Daniel.Smith [...] baesystems.com>

Message body is not shown because it is too large.

Good to hear it works. I'll mark this ticket as resolved. If you identify any more improvements then please open a new ticket via the github issue tracker. https://github.com/shawnlaffan/Geo-ShapeFile/issues/ If you want to keep on top of the changes then you can register to "watch" the changes in the github repo. There is an option on the main page. https://github.com/shawnlaffan/Geo-ShapeFile Regards, Shawn. On Wed Feb 12 08:20:28 2014, daniel.smith@baesystems.com wrote: Show quoted text
> Brilliant Shawn! > Your shapefile 2.54 does indeed work fine for me - as you can see from > the spreadsheet I sent > If you do some other efficiency related improvements I can easily > compare the time taken to generate a land map by two different > versions of the code > > If you do want me to do that let me know, in either case - thanks for > your emails and I am very glad my input was useful > Cheers! > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited > Registered Office: Warwick House, PO Box 87, Farnborough Aerospace > Centre, Farnborough, Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > Please consider the environment before printing this email. > > >
Subject: RE: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Thu, 13 Feb 2014 10:54:27 +0000
To: "bug-Geo-ShapeFile [...] rt.cpan.org" <bug-Geo-ShapeFile [...] rt.cpan.org>
From: "Smith, Daniel E (UK)" <Daniel.Smith [...] baesystems.com>
I don't have any more bugs! I was thinking in an idle moment of how to write "point is really in shape" and a "shapes really do overlap" procedures (probably better names could be found), but they are additional algorithms rather than bugs, and are quite complex The issue for point is in shape is that a point can be in the bounding box of a shape but not be inside the shape. The usual way to make this work is to draw a straight line from the point and see how many sides of the shape that line interects, if it intersects an odd number of sides (and the shape is closed) then the point is in the shape. The issue for overlapping shapes is similar: The bounding boxes of two shapes MUST overlap if the shapes overlap, however sometimes the bounding boxes overlap if the shapes do not overlap. The fix here (once the point really in shape procedure is working) is to say that if two shapes overlap (and they are closed polygons with straight sides) then at least one of the points of one of the shapes must be inside the other shape. What do you think? I don't know if you want to do any more work on it.... Daniel Smith  Radar Systems Engineer, Sampson BAE Systems Maritime Services, Newport Road, Cowes, Isle of Wight, PO31 8PF, UK I: +44 (0) 198320 2937  :: daniel.smith@baesystems.com / www.baesystems.com BAE Systems Integrated System Technologies Limited  Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, Hants, GU14 6YU, UK. Registered in England & Wales No: 3456325 Please consider the environment before printing this email. Show quoted text
-----Original Message----- From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] Sent: 12 February 2014 20:20 To: Smith, Daniel E (UK) Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect ----------------------! WARNING ! ---------------------- This message originates from outside our organisation, either from an external partner or from the internet. Consider carefully whether you should click on any links, open any attachments or reply. Follow the 'Report Suspicious Emails' link on IT matters for instructions on reporting suspicious email messages. -------------------------------------------------------- <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > Good to hear it works. I'll mark this ticket as resolved. If you identify any more improvements then please open a new ticket via the github issue tracker. https://github.com/shawnlaffan/Geo-ShapeFile/issues/ If you want to keep on top of the changes then you can register to "watch" the changes in the github repo. There is an option on the main page. https://github.com/shawnlaffan/Geo-ShapeFile Regards, Shawn. On Wed Feb 12 08:20:28 2014, daniel.smith@baesystems.com wrote:
> Brilliant Shawn! > Your shapefile 2.54 does indeed work fine for me - as you can see from > the spreadsheet I sent If you do some other efficiency related > improvements I can easily compare the time taken to generate a land > map by two different versions of the code > > If you do want me to do that let me know, in either case - thanks for > your emails and I am very glad my input was useful Cheers! > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited Registered Office: > Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, > Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > P Please consider the environment before printing this email. > > >
******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
Subject: Re: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect
Date: Thu, 13 Feb 2014 22:08:07 +1100
To: bug-Geo-ShapeFile [...] rt.cpan.org
From: Shawn Laffan <shawnlaffan [...] gmail.com>
Feel free to list them as new issues on the issue tracker. There is already a function called contains_point in Geo::ShapeFile::Shape which uses the winding number algorithm. The shapes_in_area method should be renamed to something like shapes_in_box or similar. The shape overlap approach could iterate over the points in one shape relative to the points in the other shape, but this needs to account for non-intersection of vertices. Regards, Shawn. On 13 February 2014 21:54, Smith, Daniel E via RT < bug-Geo-ShapeFile@rt.cpan.org> wrote: Show quoted text
> Queue: Geo-ShapeFile > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > I don't have any more bugs! > > I was thinking in an idle moment of how to write "point is really in > shape" and a "shapes really do overlap" procedures (probably better names > could be found), but they are additional algorithms rather than bugs, and > are quite complex > > The issue for point is in shape is that a point can be in the bounding box > of a shape but not be inside the shape. The usual way to make this work is > to draw a straight line from the point and see how many sides of the shape > that line interects, if it intersects an odd number of sides (and the shape > is closed) then the point is in the shape. > > The issue for overlapping shapes is similar: The bounding boxes of two > shapes MUST overlap if the shapes overlap, however sometimes the bounding > boxes overlap if the shapes do not overlap. The fix here (once the point > really in shape procedure is working) is to say that if two shapes overlap > (and they are closed polygons with straight sides) then at least one of the > points of one of the shapes must be inside the other shape. > > What do you think? I don't know if you want to do any more work on it.... > > > Daniel Smith > Radar Systems Engineer, Sampson > BAE Systems Maritime Services, > Newport Road, > Cowes, > Isle of Wight, PO31 8PF, UK > I: +44 (0) 198320 2937 > :: daniel.smith@baesystems.com / www.baesystems.com > > BAE Systems Integrated System Technologies Limited > Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre, > Farnborough, Hants, GU14 6YU, UK. > Registered in England & Wales No: 3456325 > > Please consider the environment before printing this email. > > > -----Original Message----- > From: Shawn Laffan via RT [mailto:bug-Geo-ShapeFile@rt.cpan.org] > Sent: 12 February 2014 20:20 > To: Smith, Daniel E (UK) > Subject: [rt.cpan.org #89563] Shapes_In_Area Function is incorrect > > ----------------------! WARNING ! ---------------------- This message > originates from outside our organisation, either from an external partner > or from the internet. > Consider carefully whether you should click on any links, open any > attachments or reply. > Follow the 'Report Suspicious Emails' link on IT matters for instructions > on reporting suspicious email messages. > -------------------------------------------------------- > > <URL: https://rt.cpan.org/Ticket/Display.html?id=89563 > > > Good to hear it works. > > I'll mark this ticket as resolved. > > If you identify any more improvements then please open a new ticket via > the github issue tracker. > https://github.com/shawnlaffan/Geo-ShapeFile/issues/ > > If you want to keep on top of the changes then you can register to "watch" > the changes in the github repo. There is an option on the main page. > https://github.com/shawnlaffan/Geo-ShapeFile > > > Regards, > Shawn. > > On Wed Feb 12 08:20:28 2014, daniel.smith@baesystems.com wrote:
> > Brilliant Shawn! > > Your shapefile 2.54 does indeed work fine for me - as you can see from > > the spreadsheet I sent If you do some other efficiency related > > improvements I can easily compare the time taken to generate a land > > map by two different versions of the code > > > > If you do want me to do that let me know, in either case - thanks for > > your emails and I am very glad my input was useful Cheers! > > > > Daniel Smith > > Radar Systems Engineer, Sampson > > BAE Systems Maritime Services, > > Newport Road, > > Cowes, > > Isle of Wight, PO31 8PF, UK > > I: +44 (0) 198320 2937 > > :: daniel.smith@baesystems.com / www.baesystems.com > > > > BAE Systems Integrated System Technologies Limited Registered Office: > > Warwick House, PO Box 87, Farnborough Aerospace Centre, Farnborough, > > Hants, GU14 6YU, UK. > > Registered in England & Wales No: 3456325 > > > > P Please consider the environment before printing this email. > > > > > >
> ******************************************************************** > This email and any attachments are confidential to the intended > recipient and may also be privileged. If you are not the intended > recipient please delete it from your system and notify the sender. > You should not copy it or use it for any purpose nor disclose or > distribute its contents to any other person. > ******************************************************************** > >