Author Topic: Cities and rivers placement with heightmaps  (Read 10100 times)

0 Members and 1 Guest are viewing this topic.

Offline mad_genius

  • *
  • Posts: 33
  • Total likes: 1
  • Helpful: 1
  • Languages: PT, EN, Java, XML, ...
Cities and rivers placement with heightmaps
« on: April 23, 2012, 10:25:14 AM »
The map creation window could have the option to choose a citylist to be used on that map. Something like a drop down list or a combo box.

That way we could avoid having to change the name of the citylist file in order for it to match the language we're using in the game (citylist_de.txt, citylist_en.txt, etc).

This separation between the game language and the city list would allow for "mixing localization" in the game on the fly. Like playing the game in german with a map of italian cities for example.

In order to improve the readability of the drop down list, the format of the citylist file would have to include some tag to specify a label to be used for display (in case the file didn't had the label tag, the name of the file would be used for display).
« Last Edit: November 05, 2012, 07:09:51 PM by Fabio »

Offline Isaac.Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3386
  • Total likes: 254
  • Helpful: 90
  • PanamaCityPC.com/support/
    • Facebook Profile
  • Languages: EN
Re: Select citylist at map creation.
« Reply #1 on: April 23, 2012, 12:54:04 PM »
I always forget to go change out the citylist before I play. Love this idea.

Offline yorkeiser

Re: Select citylist at map creation.
« Reply #2 on: April 23, 2012, 02:37:00 PM »
Good idea, I strongly support this.

Not strictly related, but I add here also another idea, I don't know if it already was asked for: it would be nice to have the feature of loading, together with map, the cities to place on it. By example, if I want to play a map of Europe, it would be good to have the height-map but also the city list, loaded from a file.
Reading the code, I see there's already the function welt->add_stadt(), so maybe this could already be achievable.
By example, I think cities could be loaded specifying in the main screen (the one with map parameters) a file with rows in this format: [cityname - X coordinate - Y coordinate - population]. When user specifies city file, default city generation would be skipped, and the one specified by the file would be used. This coud lead to create maps that really simulate real regions, rather than having to place the cities by hand.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8656
  • Total likes: 283
  • Helpful: 226
  • Languages: De,EN,JP
Re: Select citylist at map creation.
« Reply #3 on: April 23, 2012, 02:46:26 PM »
The second one has been often request and is easy to code. But no one took this up yet ...

kalipatria

  • Guest
Re: Select citylist at map creation.
« Reply #4 on: April 24, 2012, 05:29:19 AM »
I always forget to go change out the citylist before I play. Love this idea.
I like it



The second one has been often request and is easy to code. But no one took this up yet ...
I like it


Mod note: please do not double-post. Edit your last comment instead.
~IgorEliezer

« Last Edit: April 24, 2012, 05:45:29 AM by IgorEliezer »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8656
  • Total likes: 283
  • Helpful: 226
  • Languages: De,EN,JP
Standard for city etc. placement with heightmaps
« Reply #5 on: May 30, 2012, 09:46:51 PM »
OpenTTD has proposed a system for city placement, which seems quite useful: http://wiki.openttd.org/Terkhen/Scenario_format

Offline IgorEliezer

  • Devotee
  • Administrator
  • *
  • Posts: 3913
  • Total likes: 117
  • Helpful: 68
  • Minister of Silly Posts
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
Re: Standard for city etc. placement with heightmaps
« Reply #6 on: May 31, 2012, 04:10:55 AM »
Yep! I pretty welcome this topic. That's a feature I always missed in the heightmaps (the so-called PPM files).

I think people here have talked "a lot" about heightmaps that were capable of defining the position of cities, touristic attractions and factories, but no one has "formally" opened an extension request topic about it, if I'm not wrong.  ???

If I, for example, wanted to create a heightmap of my state or country, the first thing I'd like to define would be the position of the cities and its names. Next, the touristic attractions, and then the factories. If I want something "fancier": the rivers and the biomes (i.e. the climates, which are currently an altitude-based feature, not a region-based feature, like in this game. But this is another subject).

Right to the point, those are my thoughts about the new heightmap, which I'd like to call map file:

- map files would be provided as today's pak files. A single file that you load and play. (instead of *.ppm, why not *.map?)
- a map file would be made of PNGs and DAT files, which are merged and converted by a tool similar to Makeobj. Perhaps a map editor would be welcome.
- the PNG files store the "form" of the terrain: heights and climates (if it were possible).
- the DAT files store the position of the objects in the map: cities,  touristic attractions, factories and rivers.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4121
  • Total likes: 125
  • Helpful: 147
  • Languages: EN, DE, AT
Re: Standard for city etc. placement with heightmaps
« Reply #7 on: May 31, 2012, 06:35:55 AM »
I would rather do this with scripts: take a heightmap and a script. The script controls all the map settings (water level etc). It would place cities, industries, rivers.
Parsley, sage, rosemary, and maggikraut.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 23
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Standard for city etc. placement with heightmaps
« Reply #8 on: May 31, 2012, 08:53:09 AM »
Scripts will allow everything, so... yes :) However, it might be nice to allow import of this format, too.

Eventually, there might be other problems caused by Kieron's project, though ;)

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4121
  • Total likes: 125
  • Helpful: 147
  • Languages: EN, DE, AT
Re: Standard for city etc. placement with heightmaps
« Reply #9 on: May 31, 2012, 08:58:19 AM »
However, it might be nice to allow import of this format, too.
What do you mean?
Parsley, sage, rosemary, and maggikraut.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 23
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Standard for city etc. placement with heightmaps
« Reply #10 on: May 31, 2012, 09:26:08 AM »
Well, if OpenTTD implements this, being able to import that into Simutrans would be nice... More ways to get maps!

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline kierongreen

Re: Standard for city etc. placement with heightmaps
« Reply #11 on: May 31, 2012, 12:41:40 PM »
PPMs load fine with double heights and any placement of towns, tourist attractions etc would be 2d anyway unless I'm mistaken? I tried loading city data from a file a few years back but didn't get far.

Offline sdog

Re: Standard for city etc. placement with heightmaps
« Reply #12 on: May 31, 2012, 03:18:13 PM »
common standards are usually a good thing, it sounds very desirable from a users perspective prissi.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4502
  • Total likes: 151
  • Helpful: 105
  • Languages: EN, NO
Re: Standard for city etc. placement with heightmaps
« Reply #13 on: May 31, 2012, 03:27:41 PM »
I would rather do this with scripts: take a heightmap and a script. The script controls all the map settings (water level etc). It would place cities, industries, rivers.

If the script is easy enough for common people, but the more powerful and flexible they become, the more of a developer's mind one needs to read and write them.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4121
  • Total likes: 125
  • Helpful: 147
  • Languages: EN, DE, AT
Re: Standard for city etc. placement with heightmaps
« Reply #14 on: May 31, 2012, 03:51:04 PM »
If the script is easy enough for common people, but the more powerful and flexible they become, the more of a developer's mind one needs to read and write them.
I'd love to find any advice as to make the scripting as easy as possible for non-developers.
Parsley, sage, rosemary, and maggikraut.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4502
  • Total likes: 151
  • Helpful: 105
  • Languages: EN, NO
Re: Standard for city etc. placement with heightmaps
« Reply #15 on: May 31, 2012, 03:57:55 PM »
Statements like
Code: [Select]
city(name, x, y, population)might be understandable for non-developers. Attractions would be similar, but I imagine factories and rivers are a bit harder to reduce to such a simple statement.

Offline wlindley

Re: Standard for city etc. placement with heightmaps
« Reply #16 on: May 31, 2012, 05:27:25 PM »
If there were a layer for each industry type, that would be a marvelous way of separating the logic ("Where can this type of industry go? On a shore? Near a mountain?") from the positioning of each factory. 

Preferably there will be no new binary formats other than a "zip" (or tgz, what have you) of the requisite text and image files.  Eventually, paksets and savegames should likewise be simply archives of textfiles+images.  (see also: "In praise of text files and protocols" and "Textuality" (Eric Raymond))

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8656
  • Total likes: 283
  • Helpful: 226
  • Languages: De,EN,JP
Re: Standard for city etc. placement with heightmaps
« Reply #17 on: May 31, 2012, 07:48:53 PM »
Since this is only a suggestion so far (as I know) easy scripting as suggested above is maybe also ok for non-players. Otherwise one could have both, either a nut or a txt ...

Offline isidoro

Re: Standard for city etc. placement with heightmaps
« Reply #18 on: May 31, 2012, 09:56:15 PM »
My opinion is that if you adopt the OTTD standard and, since you don't have control over it, you are sold.  On the other hand, if you decide to build your own, an importer would be a nice idea, but I'm more for an external tool.  You give it the OTTD files and it generates the ST ones.

Talking about the OTTD standard prissi linked in the first post, I don't like one thing.  If you make the city position to refer to direct coordinates of the map, that list is pretty much not reusable.  A better approach, imho, is that the whole map has a property saying what are the geographical coordinates of the map and the city list refer to geographical coordinates too.

And last, why that ugly property format and not XML?


Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4502
  • Total likes: 151
  • Helpful: 105
  • Languages: EN, NO
Re: Standard for city etc. placement with heightmaps
« Reply #19 on: June 01, 2012, 04:49:17 AM »
And last, why that ugly property format and not XML?

Just a guess: because it's easier to parse. One can put together a property file parser in no time, while XML parsers are big and relatively complicated beasts, both to write and link against. It might not be worth it as long as the data has a simple flat structure. That might also apply to human readability, because the small amount of data won't drown in XML syntax overhead.

Offline sdog

Re: Standard for city etc. placement with heightmaps
« Reply #20 on: June 01, 2012, 05:57:23 AM »
good reads, thanks wlindley!

Offline el_slapper

Re: Standard for city etc. placement with heightmaps
« Reply #21 on: June 01, 2012, 08:28:06 AM »
Just a guess: because it's easier to parse. One can put together a property file parser in no time, while XML parsers are big and relatively complicated beasts, both to write and link against. It might not be worth it as long as the data has a simple flat structure. That might also apply to human readability, because the small amount of data won't drown in XML syntax overhead.

IIRC, the purpose of XML is to be an average between ease of code & ease of hand-manipulation. A property format is much easier to code, but much tougher to hand-modify. somethig like city(name, x, y, population) is the exact reverse : easy to hand-manage, complex to code.

In other words, there is no silver bullet. If you make an "easy" property format, you'll probably have to also build tools to manipulate them. Kind of modding tools, map editor, whatever.

OTOH, if you go the way of users modifying an easy-to-understand .txt file (like paradox mod files, for those of you who did play & mod Europa Universalis), you'll have to build a complex parser first. But those files are easy to understand & modify by hand, you don't need a **** tool.

XML is midway between both. Best of both worlds, of worse of both? Well, opinions vary greatly. I tend to think it's both of both worlds, but it's probably a question of experiences.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4502
  • Total likes: 151
  • Helpful: 105
  • Languages: EN, NO
Re: Standard for city etc. placement with heightmaps
« Reply #22 on: June 01, 2012, 02:59:23 PM »
If a property file is difficult to hand edit, then it has been abused for something more complex than they are meant for. Even XML will greatly benefit from tools for editing at that point, and a schema to define how it's supposed to be structured. An advantage of XML with a schema is that it can be validated using existing tools, both when editing and parsing.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 5
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Standard for city etc. placement with heightmaps
« Reply #23 on: June 05, 2012, 11:19:50 AM »
See also this request: http://forum.simutrans.com/index.php?topic=7298.0

(they might eventually be merged...)

Offline asaphxiix

saving city location data for height maps
« Reply #24 on: November 05, 2012, 06:08:43 PM »
I couldn't find a similar topic, so here goes:

currently only height maps can be saved - which is very cool for simulating a reality scenario, but this can be a tedious task in placing and sizing the cities etc., and the joyful fruit of it is usually not playable in other paksets or much later versions of pak/engine, I believe.

This is because of the way the game is built - this I understand, with so much going on with the pakset. But maybe a workaround can be found - for instance, enhancing the ppm file or adding a dat file with minimal data such as city hall coordinates, probably not even city size. City locations are the hardest task in creating such a map.

So to sum, just being able to reproduce city hall coordinates for the same height map between paksets and engines would be quite beneficial for some players, I think.

Offline Carl

Re: saving city location data for height maps
« Reply #25 on: November 05, 2012, 06:12:03 PM »
I recall this being discussed before in a favourable tone -- I think it's just one of the many great ideas that nobody has gotten around to making yet.

Offline Combuijs

  • Web Team
  • Devotee
  • *
  • Posts: 1379
  • Total likes: 20
  • Helpful: 53
  • Maintainer of maps.simutrans.com
    • Combuijs
  • Languages: EN, NL
Bob Marley: No woman, no cry

Programmer: No user, no bugs



Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 23
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Standard for city etc. placement with heightmaps
« Reply #27 on: November 05, 2012, 07:07:22 PM »
Could this work as a scenario? It's easy to see as a sequence of scripted commands:
set climates
load heightmap
place cities
etc...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 5
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Standard for city etc. placement with heightmaps
« Reply #28 on: November 05, 2012, 07:07:50 PM »
Thank you Combuijs, I merged the 3 threads together...

Offline isidoro

Re: Cities and rivers placement with heightmaps
« Reply #29 on: November 06, 2012, 12:14:56 AM »
I've been thinking about that more than once and I've come to the conclusion that better than an additional .dat file would be a general xml .map format.  This would be backwards compatible since you can load an old .ppm with previous behavior or a new .map format.

Being xml makes the format naturally extensible.  This could be the aspect of one of such .map files:

Code: [Select]
<map version="1.0" ppm="europe.ppm" waterlevel="7" east="-35" south="35" west="10.2" north="70">
  <cities>
    <city name="Ulm" latitude="48.3" longitude="-10" population="123000"/>
    <city name="Bonn" latitude="50.8" longitude="-7.1" population="327000"/>
  </cities>
</map>

It is better to have the positions of the cities in latitude and longitude instead of the absolute position in the map so that that information could be reusable...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8656
  • Total likes: 283
  • Helpful: 226
  • Languages: De,EN,JP
Re: Cities and rivers placement with heightmaps
« Reply #30 on: November 06, 2012, 09:01:34 AM »
THe XML reader in simutrans would rather expect something like

Code: [Select]
<city>
<string>Bonn</string>
<i16>2500</i16>
<koord>
<i16>256</i16>
<i16>151</i16>
</koord>
...
</city>

Dwachs has a scripting approach
Code: [Select]
city("Bonn",2500,(256,151));

which anyway looks more appealing to my human eyes ...

Offline mad_genius

  • *
  • Posts: 33
  • Total likes: 1
  • Helpful: 1
  • Languages: PT, EN, Java, XML, ...
Re: Cities and rivers placement with heightmaps
« Reply #31 on: November 06, 2012, 09:29:06 AM »
In the case of following an XML approach, there are some usefull tools to deal with the mapping between XML data structures and object oriented languages.

You can use trang (command line tool) to generate XSD from XML and then use tools like CodeSynthesis XSD to convert XML data into c++ objects at runtime (and vice-versa) the same way JAXB does for java objects.

These tools can reduce the amount of code needed to read/write XML files without losing significant amounts of performance.

Offline isidoro

Re: Cities and rivers placement with heightmaps
« Reply #32 on: November 06, 2012, 10:51:17 PM »
@prissi: yes, I saw Dwachs' post just after I have written mine.

Offline yorkeiser

Re: Cities and rivers placement with heightmaps
« Reply #33 on: November 06, 2012, 11:34:45 PM »
I love to see this thread still up, I always supported this feature.
In my opinion map&city file would have to be a single file, with no distinction between ppm and dat/xml/txt/otherExtension city definition file, otherwise new users could experience trouble in merging them.

I imagine a simple file structure:

<standard dimension>
dim_x dim_y
</standard dimension>
<ppm>
hex ppm raw data (heightmap)
</ppm>
<cities>
cityname1 coordX coordY population
cityname2 coordX coordY population
...
</cities>
<eventually other sections, as rivers, factories or attractions>

Standard dimension x and y parameters would be reference coordinates for that map definition file (as actually width and height of a ppm heightmap are) : simutrans map creation engine would have to be able to interpolate them (as it already does) to allow creation of bigger/smaller maps using the same city/map definition file.
I don't think file format is really interesting in this phase, but its content is the key

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4502
  • Total likes: 151
  • Helpful: 105
  • Languages: EN, NO
Re: Cities and rivers placement with heightmaps
« Reply #34 on: November 07, 2012, 05:56:03 AM »
Having all that height data in the XML takes a lot of space. It should at least be at the end to make it easier to get to and edit the human readable (and writable) parameters, though some editors may be sluggish with so big files anyway.