Probably a really simple question, converting a C app to VB6, don't know a command!

Soldato
Joined
18 Oct 2002
Posts
8,016
Before anyone starts - I program in VB6, I don't want this to turn into an arguement as to which is best.

Anyways, I've found some code which is in C or C#, and i'm just a little confused as to what a couple of lines are, and how I'd re-write it in VB6.

Searching is proving very difficult, as it involves =, < and + symbols, which search engines don't like! ;)

The lines are as follows, I've highlighted the bits VB6 is failing on in red:

mask = 1 << (i - 1);
arc = earthCircum / ((1 << zoom) * 256)
quad += cell;

(not all one after the other in a procedure)

I'm sure they're some kind of maths or comparison commands, but I'm not sure what they are/do!


Thanks in advance for any help! :)


Garry
 
Thanks Jono :)


"zoom" is a zoom level from 1 to 19. It's basically for getting images from the Microsoft VirtualEarth servers for displaying in an app based on longitude/latitude.


The complete C code for the procedure(s) where there is the << are as follows:

Code:
		private int LatitudeToYAtZoom(double lat, int zoom)
		{
			double arc = earthCircum / ((1 << zoom) * 256);
			double sinLat = Math.Sin(DegToRad(lat));
			double metersY = earthRadius / 2 * Math.Log((1 + sinLat) / (1 - sinLat));
			int y = (int)Math.Round((earthHalfCirc - metersY) / arc);
			return y;
		}

		private static string TileToQuadKey(int tx, int ty, int zl)
		{
			string quad = "";
			for (int i = zl; i > 0; i--)
			{
				int mask = 1 << (i - 1);
				int cell = 0;
				if ((tx & mask) != 0)
				{
					cell++;
				}
				if ((ty & mask) != 0)
				{
					cell += 2;
				}
				quad += cell;
			}
			return quad;
		}
 
xyphic,

Brilliant, that is it exactly :cool:

That part of it is now working perfectly, confirmed with a few known bits of data :)

Many, many thanks! :D


Garry
 
Back
Top Bottom