source: trunk/npemap.org.uk/scripts/gmc-london/convert.py @ 537

Last change on this file since 537 was 537, checked in by Nick Burch, 13 years ago

For working with gmc maps

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/python
2
3import sys, math
4gmc_e = int(sys.argv[1])
5gmc_n = int(sys.argv[2])
6
7# The OS made up a very nice national grid
8# The Geographers' map company licenced some OS data to produce their map
9# Unfortunately, they didn't copy the grid :(
10
11# The further east we go, the smaller the slant is
12# (Near left edge, is 1.32 degrees, near right, 0.67 degrees)
13#slant = 0.90 + 0.10 * ((26000.0 - gmc_e) / 26000.0)
14slant = 1.08
15slant_rad = slant / 360 * 2 * math.pi
16print "The slant factor is %0.3f" % slant
17
18# The grid squares are supposed to be 0.5 miles across
19# In actual fact, they are a factor of 1.02 too small
20adj_gmc_e = 1.021 * gmc_e
21adj_gmc_n = 1.021 * gmc_n
22
23# Turn them into meters from the start of the map
24m_e = adj_gmc_e / 2 * 1.6
25m_n = adj_gmc_n / 2 * 1.6
26
27# Apply the slant factor
28real_e = (math.sin(slant_rad) * m_n) + (math.cos(slant_rad) * m_e)
29real_n = (math.cos(slant_rad) * m_n) + (math.sin(slant_rad) * m_e)
30
31print "After slant, e is %d from %d " % (real_e, m_e)
32print "After slant, n is %d from %d " % (real_n, m_n)
33
34# We know that 0,646 2,487 is 520,896 174,936
35# From that, we can figure out 0,0
36ngr_e_0 = 520896 - 580
37ngr_n_0 = 174936 - 2057
38
39easting = int(real_e + ngr_e_0)
40northing = int(real_n + ngr_n_0)
41
42print "%d   %d" % (easting,northing)
Note: See TracBrowser for help on using the repository browser.