Map Coordinate Question...

Discuss maps, trains and other modding topics
Post Reply
User avatar
akmad
Posts: 11
Joined: Thu Oct 26, 2006 6:49 pm
Location: Albany, NY
Contact:

Map Coordinate Question...

Post by akmad » Sat Nov 04, 2006 4:32 pm

Does only here know, or can any from Firaxis tell me, the formula for the conversion from the City StartX and StartY to the map (.tga) pixel coordinates?

For these questions I'm considering the first 601x601 image in a map .tga file to be the "map". Likewise the map coordinates that I'm referencing here are the pixel coordinates on that map.

From what I can gather, a city at StartX=0, StartY=0 will be positioned around point 180, 180 on the map. It may not be exactly this but it's pretty close. However, if I consider that point to be the origin of the city layout coordinates the resulting positions for all the other cities are not correct.

If you look at the map image you'll notice that spots where cities are placed tend to be "smudged"... giving a uniform color and thus a flat terrain. Using these smudges as markers for cities I've been able to calculate that a cities location on the map can be (approximately) calculated via the following formula:

Code: Select all

Map.X = (180 + City.StartX) * .9
Map.Y = (180 + City.StartY) * .9
I don't think that this formula is correct; however I cannot tell if the formula is wrong or the starting location is wrong.

Any help on this would be greatly appreciated.

Thanks,
Wes

Lama
Posts: 19
Joined: Fri Nov 03, 2006 9:05 pm

Post by Lama » Sun Nov 05, 2006 5:19 am

I did some reverse engineering on this. Here are my findings, based on the Germany map.

If you take a thumbnail of your map and resize it to 620x620 pixels, city coordinates (cc) and pixels (px) are congruent, in aspect ratio.
However, the point cc_x,cc_y(0,0) is at px_x,px_y(160,160).
To put a city at the point px_x,px_y(300,400), the city coordinates would read cc_x,cc_y(140,240), where cc=px-160.
This is true only where the px-value is above 160 on either axis.
Any cc below px_x or px_y 160 would be prefaced by a – [minus], where the value would be cc=160-px.

See if that works for other maps, as well.

User avatar
zzbusch
Posts: 39
Joined: Sat Oct 28, 2006 10:47 pm
Location: Palm Coast, Fl

Post by zzbusch » Sun Nov 05, 2006 2:30 pm

Lama wrote:I did some reverse engineering on this. Here are my findings, based on the Germany map.

If you take a thumbnail of your map and resize it to 620x620 pixels, city coordinates (cc) and pixels (px) are congruent, in aspect ratio.
However, the point cc_x,cc_y(0,0) is at px_x,px_y(160,160).
To put a city at the point px_x,px_y(300,400), the city coordinates would read cc_x,cc_y(140,240), where cc=px-160.
This is true only where the px-value is above 160 on either axis.
Any cc below px_x or px_y 160 would be prefaced by a – [minus], where the value would be cc=160-px.

See if that works for other maps, as well.
Huh? :wink: :?:
Remember railroads is sdaorliar spelled backward

Lama
Posts: 19
Joined: Fri Nov 03, 2006 9:05 pm

Post by Lama » Mon Nov 06, 2006 12:48 am

zz,

to translate my previous post, city coordinates do not seem to align with the pixels of the thumbnail. If a point on the thumbnail is at x,y(120,240) pixels ('px'), the city coordinates ('cc') you will want to enter in the sceanrio manager to have a city appear at that point are NOT x,y(120,240).
So how do you figure out what coordinates to enter to have a city appear at a particular point on your map?
Do as I suggested: Take a thumbnail, resize it to 620x620, use this resized map to decide where you want your city to be, then do the calculations to translate pixel-coordinates to in-game city-coordinates.

Example:
On a 620x620 image of the map, I want to place a city at a point of px_x,px_y(120,240).
The zero-point of our grid is at the point of x,y(160,160) PIXELS.

Therefore (and this is actually a simpler formula I just came up with), you always want to subtract 160 from the pixel value of each coordinate point in order to get your city location.

For x: 120-160=-40
For y: 240-160=80

Therefore, city coordinates are x,y(-40,80).

Post Reply