## News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

## Great Britain simulation in Simutrans Experimental

Started by Carl, May 25, 2011, 03:43:48 PM

0 Members and 1 Guest are viewing this topic.

#### Lewis

QuoteOn the pak.64-britain idea - it's not a bad idea! It would take a lot of work. It would probably mean painting a lot of new trains for historical times (plus new liveries).

I could do that.

#### Jack Rudd

A quick question, Carl: I'm making my own Britain map, and having a bit of a problem placing the cities properly. How did you go about doing that?

#### NoMorePacers

I recommend you watch his video diaries; on the first episode he explained this.

#### Jack Rudd

He explained how he sourced the data, which is useful stuff, but not what I needed to know. What I'm trying to work out is, having got that data, how to translate it into co-ordinates on the map.

(Linear interpolations seem just to be failing for me, so I think I need something more complex. Not sure what, though.)

#### NoMorePacers

Why not use geographical features to help you? Like the Thames for London, the Clyde for Glasgow, the Mersey for Liverpool etc. Does your map have things like rivers?

#### Jack Rudd

It does, yes.

(The Thames is where I first started having problems, because my formula was placing things on the wrong side of the Thames.)

#### NoMorePacers

OK then. What do you mean by the wrong side?

#### Jack Rudd

I mean that the co-ordinates my formula was giving for the location of Trafalgar Square put it south of the Thames, that sort of thing.

(I have a lot of locations to place, and am trying to find some sort of automatic method of finding the co-ordinates for those locations to save myself time.)

#### Carl

Sounds like an interesting time-saving idea.

Using the scale of the heightmap (i.e. metres per tile) and measuring distances on Google Earth was the method for me. Any heightmap will require some correction - the curvature of the earth means that things get a bit out of whack over long distances, I think. Because of that I would never use one single point for calculating *all* locations. Rather I'd pick something that's reasonably nearby - a geographical feature like distinct points on Sheppey, or Flamborough Head - to minimise the distortion over long distances. This might make it difficult to place everything in a formulaic way.

Which heightmap are you using?

#### NoMorePacers

Afraid I can't help you with that then, as I'm more of a network builder or graphics painter than a map builder. I thought you were engaged in real life things (as you do), Carl. Nice surprise to see you again.

#### Jack Rudd

#570
Quote from: Carl on September 10, 2016, 08:51:49 PM
Using the scale of the heightmap (i.e. metres per tile) and measuring distances on Google Earth was the method for me. Any heightmap will require some correction - the curvature of the earth means that things get a bit out of whack over long distances, I think. Because of that I would never use one single point for calculating *all* locations. Rather I'd pick something that's reasonably nearby - a geographical feature like distinct points on Sheppey, or Flamborough Head - to minimise the distortion over long distances. This might make it difficult to place everything in a formulaic way.
That was the approach I was trying - doing it county by county - but it seems to be breaking down, and I'm not sure why.

Quote
Which heightmap are you using?
A map I found on these forums, scaled so it's just about small enough to work with. Turns out it's actually yours.

-----------------------------

So I'd get a wodge of data for a county like so:

Plymouth      -4.142593   50.375923
Exeter      -3.533594   50.718544
Torquay      -3.525339   50.461933
Paignton      -3.564236   50.435188
Exmouth      -3.384131   50.625582
Newton Abbot      -3.608396   50.529049
Barnstaple      -4.058376   51.078297
Tiverton      -3.492539   50.901941
Brixham      -3.513991   50.395353
Teignmouth      -3.496709   50.547352
Bideford      -4.206774   51.01681
Sidmouth      -3.237478   50.67876
Dawlish      -3.464221   50.582666
Ivybridge      -3.920458   50.390254
Honiton      -3.188819   50.799758
Northam      -4.21321   51.039868
Tavistock      -4.143353   50.555026
Ilfracombe      -4.126848   51.205305
Kingsteignton      -3.598556   50.549485
Totnes      -3.685286   50.433768
Okehampton      -4.004339   50.738284
Crediton      -3.65162   50.792511
Axminster      -2.994943   50.782711
South Molton      -3.832365   51.016534

...and then do a linear interpolation formula to convert all those grid references to places on the map, having found two fixed points that form the corners of a box surrounding the county.

#### Carl

Interesting. I think the most likely cause is as follows. The heightmap in question was adapted from SRTM data, but I did adjust it to make distances consistent across the country. If I remember correctly this involved separately adjusting the y-axis scale of different slices of the map (e.g. squashing Scotland and extending the South), so that the height of one pixel corresponded with a consistent value at each point in the map.

I think this would affect the lat/long approach you're taking and lead to discrepancies. However I would have thought that using a single point for each county (rather than one for the whole country), as you are, would mostly alleviate this. As a result I think you're running up against the limits of how accurate it is possible to be with Simutrans heightmaps.

Your approach might work better with Easting and Northing, if you're able to get those coordinates?

#### Jack Rudd

#572
What seems to be happening is that I'm getting problems near the edges of counties. I put in most of Essex and it's fine, and then there's stuff near the Hertfordshire border that's obviously wrong when I compare it with the Hertfordshire towns.

Ah well, back to the drawing board. Maybe the problem is with linear interpolation and I need a non-linear interpolation on the North-South axis.

ETA: Let's try with a county that's pretty big and see what's going on...

Cumbria.

The southern tip of Cumbria seems to be at (-3.195910, 54.044276) and at (1072, 2976)
The western tip of Cumbria seems to be at (-3.640176, 54.514060) and at (909, 2676)
A northern point just below the strait separating Cumbria from Annan and Gretna seems to be at (-3.213980, 54.953477) and at (1067, 2395)

Hmmm, no help there.

#### Carl

I would say that on all the real-world-simulation maps I've done, I've had to triangulate the position of difficult locations (e.g. those in the middle of the country or not near any geographical features) based on several already known points. So I might measure from multiple coastlines or elevation peaks to find where the location most fits - and they don't always agree, so you have to come to some kind of compromise.

#574
Class 66

#### Carl

Thanks Lewis - looks like a good start on those. Could probably use a bit more colour differentiation on the roof, and between the front and the side.

#### fam621

#576
Carl, I am working on a UK map with fictional cities. It'll feature as much routes and lines as possible. The map will include a plane service and Coach (Long Distance) bus services. Also an Airport shuttle in-game. Photo's will be posted on a Discord page soon. Watch this space! xD

Link to the Discord page: https://discordapp.com/channels/227891198520459264/227891198520459264

#### NoMorePacers

Carl, just to let you know, you know the long class 90 sets you did for the London map. They've overwritten the originals for the UK map, which renders the UK map practically unplayable, because of the excessive 'train too long to fit in x station platform'. Could you have a look at this please.

#### Carl

#578
Thanks - I have noticed this and will fix it.

Edit: here's an updated pak.ngb folder and London.sve which should do the trick:
https://dl.dropboxusercontent.com/u/61716/London-sep16.rar

#### fam621

Can you maybe give us the updated version of UK2016 .sve please? Even though the map is finished.

#### Jack Rudd

I just put some fixed points in and the correlation coefficients were:

e-w axis: 0.998
n-s axis: 1

Hah, screw doing it county by county, that's what's introducing the errors. I'll try again and see whether doing things on the whole map scale makes things work...

Trafalgar Square ends up at 2263, 4598...

Yes! It's north of the Thames, it's just west of the bit where the Thames goes north for a bit.

Problem solved by zooming out. Go figure.

#### fam621

Carl, can you maybe give us the updated version of UK2016 .sve please? Even though the map is finished.

#### Carl

fam621, I saw your post above from yesterday - no need to repeat I need to make one more tweak to the folder I uploaded last time. I'll add the savegame to it if that will help.

Jack - that's really interesting. Does that work everywhere in the map? I wonder why that is...?

#### Jack Rudd

#583
Calibrating north-south has worked very well. East-west was slightly trickier, but I think I've now got it right: Richmond is now east of the Thames, and Margate has not fallen into the sea.

Those fixed points in full:

 Lizard Point -5.20646 49.9576 251 5596 Land's End -5.70806 50.0594 49 5531 Portland Bill -2.45631 50.5134 1370 5234 Sandbanks -1.94747 50.6833 1574 5126 Selsey Bill -0.78916 50.7219 2038 5102 Beachy Head 0.24143 50.7338 2449 5093 Dungeness 0.977418 50.9121 2738 4980 Hartland Point -4.52588 51.0218 543 4912 Folkestone Harbour 1.19485 51.076 2866 4855 Lundy -4.65502 51.1617 494 4824 Fayrneness 1.44166 51.387 2899 4674 Foulness Point 0.958945 51.6201 2701 4525 Skomer -5.29567 51.7426 251 4449 Bradwell Point 0.92355 51.748 2683 4443 Cardigan Island -4.69021 52.1314 494 4193 Lowestoft Point 1.76285 52.4811 2976 3969 Uwchmynnydd Point -4.73219 52.7817 487 3777 Spern Nature Reserve 0.107989 53.5727 2308 3278 Roa Island -3.17364 54.062 1080 2964 Flamborough Head -0.07616 54.1146 2224 2930 Mullach Mor -5.07021 55.5227 401 2027 Cape Wrath -5.00207 58.6262 468 40 Duncansby Head -3.02516 58.6436 1129 31

EDIT: I spoke too soon, having checked the south and not the north. Scarborough appears to have fallen into the sea. Back to the drawing board.

#### fam621

It will Carl, but when will I be able to run 800's again on the GB map?

#### Carl

I'm not surprised that you've found a south/north discrepancy Jack. I think the error introduced by the curvature of the earth will mean that the east-west distances are different up there. The north/south values may also be influenced by the corrections I had to add to ensure consistency.

#### Jack Rudd

Hmmm. Seems to be 1 degree in the east-west direction is 380.95 tiles at latitude 51, and only 352.18 tiles at latitude 58. That could be something to work with.

#### Carl

That is intended behaviour, I think. The size of a tile is supposed to remain constant in terms of metres across the map, whereas the number of metres in a degree will change at different latitudes (I think?)

#### Jack Rudd

Quote from: Carl on October 07, 2016, 12:39:15 PM
That is intended behaviour, I think. The size of a tile is supposed to remain constant in terms of metres across the map, whereas the number of metres in a degree will change at different latitudes (I think?)
Yes - it'll be zero at 90 degrees North. Now to see whether the reduction is linear or something more interesting.

I would guess it is not linear, but something like const*cos(latitude)

Const is km/degree at equator (lat 0)

#### Carl

I think I made the manual adjustments in chunks, so it's likely it will be less regular than that.

#### Jack Rudd

cos 51 deg = 0.62932039
cos 58 deg = 0.52991926

Hmmm, ratio is 1.18 rather than the 1.08 for the numbers themselves, but it might be good enough.

The function with cos is just my guess, based on the fact that it is at max on equator and 0 on poles, and that earth is approximately spherical. But it may be something more complex...

#### Combuijs

See http://williams.best.vwh.net/avform.htm#flat

If you stay in the vicinity of a given fixed point (lat0,lon0), it may be a good enough approximation to consider the earth as "flat", and use a North, East, Down rectangular coordinate system with origin at the fixed point. If we call the changes in latitude and longitude dlat=lat-lat0, dlon=lon-lon0 (Here treating North and East as positive!), then

distance_North=R1*dlat
distance_East=R2*cos(lat0)*dlon

R1 and R2 are called the meridional radius of curvature and the radius of curvature in the prime vertical, respectively.

R1=a(1-e^2)/(1-e^2*(sin(lat0))^2)^(3/2)
R2=a/sqrt(1-e^2*(sin(lat0))^2)

a is the equatorial radius of the earth (=6378.137000km for WGS84), and e^2=f*(2-f) with the flattening f=1/298.257223563 for WGS84.

Bob Marley: No woman, no cry

Programmer: No user, no bugs

#### fam621

Carl, I've waited long enough for a Sept. or EVEN an Oct. 16 update of the GB map... xD