tasmod

- 5th March 2014, 21:29

Hi all,

I have some idea but maths is not my strong point. I have written what I considered to be the process but not a working code. Am I on the right lines ?(See end)

This is the relevant information to achieve the locator.

.

Longitude is always the first, followed by latitude, for each pair. For simplicity, let's assume that West and South are negative lat/long, as is a common convention. For example purposes, I'm going to use 32.123 W, 14.321 N. The key thing is to do the following.:

Longitude

1. Add 180 to the longitude, and take the integer value /20, and add one. Then figure out which letter of the alphabet that corresponds to, usually written in upper case. The example will be 147.877/20=7. Adding one will give the 8th letter of the alphabet, or G. Note 7.877 is remaining.

2. Take the remainder of what is left, and divide by 2, rounding down. This is the number, no conversion required. The example will give a value of 3. Note 1.877 is remaining.

3. Take the remainder that is left, and multiply by 12, and add one. Round down to the nearest integer.. This is the letter of the alphabet, usually written in lower case. The example gives a value of 22+1=23. This will be the letter w.

Latitude

1. Add 90 to the latitude, and take the integer value /10, and add one. Then figure out which letter of the alphabet that corresponds to, usually written in upper case. The example will be 104.321/10=10. Adding one will give the 8th letter of the alphabet, or J. Note 4.321 is remaining.

2. Take the remainder of what is left, and round down. This is the number, no conversion required. The example will give a value of 4. Note 0.321 is remaining.

3. Take the remainder that is left, and multiply by 24, and add one. Round down to the nearest integer.. This is the letter of the alphabet, usually written in lower case. The example gives a value of 7+1=8. This will be the letter g.

Putting them together by pairs, and alternating first longitude then latitude, gives the grid square for 32.123 W, 14.321 N to be GJ34wg.

I have the info from the RMC string as :-

latdeg VAR BYTE 'degrees latitude

latmin VAR BYTE 'minutes latitude

NS VAR BYTE 'north or south

londeg VAR BYTE 'degrees longitude

lonmin VAR BYTE 'minutes longitude

EO VAR BYTE 'east or west

My idea of the process is something like this :-

locator:

lonloc1=londeg + lonmin + 180

lonloc2=lonloc1/20

lonloc3=lonloc1//20

maid1=lonloc2+1

lookup maid1 ; first main letter

lonloc4=lonloc3//2

maid3=lonloc3/2 ;first number

maid5=lonloc4*12+1

lookup maid5 ; 1st 2nd letter

latloc1=latdeg + latmin + 90

latloc2=latloc1/10+1

latloc3=latloc1//10

maid1=latloc2+1

lookup maid2 ; second main letter

maid4=latloc3 ; second number

maid6=latloc3*24+1

lookup maid6 ; 2nd 2nd letter

maidenhead=maid1, maid2, maid3, maid4, maid5, maid6

I have some idea but maths is not my strong point. I have written what I considered to be the process but not a working code. Am I on the right lines ?(See end)

This is the relevant information to achieve the locator.

.

Longitude is always the first, followed by latitude, for each pair. For simplicity, let's assume that West and South are negative lat/long, as is a common convention. For example purposes, I'm going to use 32.123 W, 14.321 N. The key thing is to do the following.:

Longitude

1. Add 180 to the longitude, and take the integer value /20, and add one. Then figure out which letter of the alphabet that corresponds to, usually written in upper case. The example will be 147.877/20=7. Adding one will give the 8th letter of the alphabet, or G. Note 7.877 is remaining.

2. Take the remainder of what is left, and divide by 2, rounding down. This is the number, no conversion required. The example will give a value of 3. Note 1.877 is remaining.

3. Take the remainder that is left, and multiply by 12, and add one. Round down to the nearest integer.. This is the letter of the alphabet, usually written in lower case. The example gives a value of 22+1=23. This will be the letter w.

Latitude

1. Add 90 to the latitude, and take the integer value /10, and add one. Then figure out which letter of the alphabet that corresponds to, usually written in upper case. The example will be 104.321/10=10. Adding one will give the 8th letter of the alphabet, or J. Note 4.321 is remaining.

2. Take the remainder of what is left, and round down. This is the number, no conversion required. The example will give a value of 4. Note 0.321 is remaining.

3. Take the remainder that is left, and multiply by 24, and add one. Round down to the nearest integer.. This is the letter of the alphabet, usually written in lower case. The example gives a value of 7+1=8. This will be the letter g.

Putting them together by pairs, and alternating first longitude then latitude, gives the grid square for 32.123 W, 14.321 N to be GJ34wg.

I have the info from the RMC string as :-

latdeg VAR BYTE 'degrees latitude

latmin VAR BYTE 'minutes latitude

NS VAR BYTE 'north or south

londeg VAR BYTE 'degrees longitude

lonmin VAR BYTE 'minutes longitude

EO VAR BYTE 'east or west

My idea of the process is something like this :-

locator:

lonloc1=londeg + lonmin + 180

lonloc2=lonloc1/20

lonloc3=lonloc1//20

maid1=lonloc2+1

lookup maid1 ; first main letter

lonloc4=lonloc3//2

maid3=lonloc3/2 ;first number

maid5=lonloc4*12+1

lookup maid5 ; 1st 2nd letter

latloc1=latdeg + latmin + 90

latloc2=latloc1/10+1

latloc3=latloc1//10

maid1=latloc2+1

lookup maid2 ; second main letter

maid4=latloc3 ; second number

maid6=latloc3*24+1

lookup maid6 ; 2nd 2nd letter

maidenhead=maid1, maid2, maid3, maid4, maid5, maid6