# [Marble-devel] Mercator projection and some related issues

Torsten Rahn torsten.rahn at credativ.de
Tue Jan 29 11:26:51 CET 2008

Hi Carlos,

Thanks for working on this!

On Tuesday 29 January 2008 07:29:45 Carlos Licea wrote:
>         1) There are two ways of checking in
> FlatScanlineTextureMapper.cpp if we're painting a Mercator projection.
> Either every time inside the outer for which will look nicer but will
> have a penalty in the performance (an if evaluated a couple of thousands
> of times, it has to have an impact)

You can safely neglect that "performance problem". The line gets only executed
about 800 times in that for loop. That is something that even the computer
doesn't spend much of a thought on ;-)
Things would be different if the projection check would be done inside the
second loop because that would result in a million checks. So don't worry and
go for the first solution.

>         2)Is this really Mercator projection? it looks at least... weird
> for me. Please give it a look.

Yes it looks squeezed. Actually if you replace the line by

#ifdef MERCATOR
lat = atan( sinh( ((m_imageHeight / 2 + yCenterOffset) - y) /
(double)(2 * radius) * M_PI ) );
#else
lat = M_PI/2 - (y - yTop )* rad2Pixel;
#endif

and compare it against maps.google.com (which is using the same projection
actually) then it will look correct except for the upper and lower side being
cut off. I'm not exactly sure why that factor 2 is needed but it looks so
amazingly correct then that I suppose it's what we need.

>         3)We need to introduce a way in the methods so that we can know
> if we can represent a given point with the current projection, say
> anything upper than 85 degrees cannot be represented in Mercator
> projection so all the nodes above that point should not be painted and
> skipped somehow. I think we might return a 'true' or 'false' at the
> method 'geoCoordinates' so to react properly.

Yes. I think we do something like that for the "inverse" method
called "screencoordinates". So please change it accordingly. :-)

Best Regards,

Torsten

>     So, what do you think we should do?
>
>
> _________________________________________________________________
> ¡Actúa tu película favorita y gana fabulosos premios!
> http://cine.prodigymsn.com/nanometraje

--
Torsten Rahn

Tel.: 0 21 61 - 46 43 - 192