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

Torsten Rahn rahn at kde.org
Sun Nov 21 16:17:05 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 
> >     ****
> 
> Torsten Rahn wrote:
>     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? :-)
>

I forgot to tell where this kind of stuff is needed: If you look at a certain point (e.g. close to the dateline or close to the poles and describe a movement of that point by a certain amount of degrees then your calculation might result in a value that is out of the -180/180 or -90/90 range. To avoid this situation you can apply the normalize methods. 
Another example are different planets: For other planets a similar coordinate system as the one used for our earth is used. However some databases use ranges for the longitude between [0...360] (instead of [-180...180]). We normalize these values so that our painting methods still work accurately with flat map projections. 


- 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/a12b011a/attachment.htm 


More information about the Marble-devel mailing list