[Marble-devel] Re: Review Request: Unittest for GeoDataCoordinates-class.

Torsten Rahn rahn at kde.org
Sun Nov 21 16:07:59 CET 2010



> On 2010-11-20 15:23:41, Matias Kallio wrote:
> > /trunk/KDE/kdeedu/marble/tests/unittest_geodatacoordinates.cpp, line 160
> > <http://svn.reviewboard.kde.org/r/5825/diff/1/?file=41107#file41107line160>
> >
> >     Could you explain first of all what is the purpose of this normalize-methods? Where that functionality is needed? I have some difficulties to understand...
> >     
> >     Then shouldn't normalizeLon and normalizeLat produce similar output as normalizeLonLat? Because now I'm getting different values. Or Am I just doing something wrong:
> >     
> >     ****
> >     qreal lon = 200;
> >     qreal lat = 130;
> >     
> >     qDebug() << "lon" << GeoDataCoordinates::normalizeLon(lon, GeoDataCoordinates::Degree);
> >     qDebug() << "lat" << GeoDataCoordinates::normalizeLat(lat, GeoDataCoordinates::Degree);
> >     
> >     qreal normalized_lon = lon;
> >     qreal normalized_lat = lat;
> >     
> >     GeoDataCoordinates::normalizeLonLat( normalized_lon, normalized_lat, GeoDataCoordinates::Degree);
> >     qDebug() << "Normalize_lon " << normalized_lon << "normalize_lat " << normalized_lat;
> >     
> >     gives me:
> >     
> >     lon -160 
> >     lat 50 
> >     Normalize_lon  20 normalize_lat  50 
> >     ****

This looks correct to me.

GeoDataCoordinates::normalizeLon() "normalizes" whatever coordinates are provided to the range of [-180 (west) ... +180 (east)]. -180/180 marks the earths dateline. So if you go beyond that value (e.g. 200) then you end up on the other side of the dateline and get a value of -160.

The same applies with GeoDataCoordinates::normalizeLat(): The "valid" Latitude range goes from [-90 (south) ... +90 (north)]. So imagine you'd go from Tampere north: The latitude would rise until you reach the northpole (90). If you go beyond the pole you could argue that you e.g. reach 100 degrees latitude - which actually equals 80 degs north. So the normalized value would be 80. 

Now imagine you do that for real: Tampere is at 24 degrees Longitude and 62 degrees latitude. You head north towards the northpole and once you cross it you are on the other side. So if you had a latitude of "100" that would certainly equal the "normalized" value "80". But since you are on the other side of the equator your longitude would be a different one: it would have shifted by 180 degs since you are on the other half of the globe. That's what GeoDataCoordinates::normalizeLonLat takes into account: Entering lon=200 and lat=130 would result in "50" for the latitude. But the longitude would at the same time change by 180: So we could either add those 180 or subtract them. And by subtracting we end up at lon=20.

So GeoDataCoordinates::normalizeLonLat takes both coordinates into account at the same time. GeoDataCoordinates::normalizeLon() and GeoDataCoordinates::normalizeLat() only take a single coordinate component into account. Therefore GeoDataCoordinates::normalizeLonLat() yields results that are different from what you get if you just execute GeoDataCoordinates::normalizeLon() and GeoDataCoordinates::normalizeLat() one after each other.

Got the idea? :-)


- Torsten


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://svn.reviewboard.kde.org/r/5825/#review8864
-----------------------------------------------------------


On 2010-11-10 17:33:24, Matias Kallio wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://svn.reviewboard.kde.org/r/5825/
> -----------------------------------------------------------
> 
> (Updated 2010-11-10 17:33:24)
> 
> 
> Review request for marble.
> 
> 
> Summary
> -------
> 
> First version of unittest for GeoDataCoordinates-class. 
> 
> 
> Diffs
> -----
> 
>   /trunk/KDE/kdeedu/marble/tests/CMakeLists.txt 1194752 
>   /trunk/KDE/kdeedu/marble/tests/unittest_geodatacoordinates.cpp PRE-CREATION 
> 
> Diff: http://svn.reviewboard.kde.org/r/5825/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Matias
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/marble-devel/attachments/20101121/6207cad3/attachment.htm 


More information about the Marble-devel mailing list