Ticket #3411 (closed bug: fixed)

Opened 23 months ago

Last modified 23 months ago

Correct Longitude when Wrapping Dateline

Reported by: cayenne Owned by:
Priority: minor Milestone: 2.12 Release
Component: Util Version: 2.10
Keywords: Cc:
State:

Description

The getFormattedLatLon function works fine except in the vicinity of a dateline wrap. Then it displays spurious values like 215E.

This can be fixed with a minor change to the routine using addition, subtraction, and modulo. It might be more efficient to use an "if>180" test, but my revised code works.

Attachments

betterlatlon.js Download (2.1 KB) - added by cayenne 23 months ago.
latlon.util.patch Download (455 bytes) - added by cayenne 23 months ago.

Change History

Changed 23 months ago by cayenne

  Changed 23 months ago by tschaub

ICLA  received. Thanks.

  Changed 23 months ago by ahocevar

@cayenne: Thanks a lot for your contribution. Please provide patches for improvements you want to contribute. See CreatingPatches for instructions.

  Changed 23 months ago by cayenne

@ahocevar

Okay, I will do so. I'll need to learn yet another system, but that's part of the fun.

It's just a single line, but I'll go learn the patch process for svn.

coordinate = (coordinate+540)%360 - 180; // normalize for sphere wraparound

Changed 23 months ago by cayenne

  Changed 23 months ago by cayenne

Patch added. That was not too hard to learn!

  Changed 23 months ago by ahocevar

  • status changed from new to closed
  • resolution set to fixed

(In [12172]) fixing dateline handling of Util.getFormattedLonLat. p=cayenne, r=me (closes #3411)

follow-up: ↓ 7   Changed 23 months ago by ahocevar

Thanks @cayenne for taking the time to create the patch. Great work. I added two simple assertions to the test suite. Now that you already know how to create patches, maybe your next patch will even come with some test coverage.

in reply to: ↑ 6 ; follow-up: ↓ 8   Changed 23 months ago by cayenne

Thanks to YOU, @ahocevar

Yes, before submitting my next one (geographically corrected polygons), I will learn the test process. Is there a tutorial for that?

in reply to: ↑ 7   Changed 23 months ago by ahocevar

Replying to cayenne:

Yes, before submitting my next one (geographically corrected polygons),

Check #2787 first, there may already be a fix, but the patches there lack tests as well.

I will learn the test process. Is there a tutorial for that?

Unfortunately not. At least none that I'm aware of.

Note: See TracTickets for help on using tickets.