Author Topic: Territories Importer issues  (Read 1353 times)

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Territories Importer issues
« on: July 05, 2021, 10:24:57 PM »
I have a few issues when using this feature. I've added the image Province_01.png which contains provinces that should be created.
I've also attached the matching texture and watermap (used in Earth settings).

First, I add a WMSK_Editor component (to WorldMapStrategyKit object). I use these settings:
  Show layers: Countries + Provinces
  Country File: High Definition Geodata File
 
I click New Map. After that provinces10.txt and countries10.txt are empty. cities10.txt still contain its data (not sure if this is intentional or not).

I learned (after some time) that I then have to click 'Create Background/Pool Country', which creates this entry in countries10.txt:
|Pool$<Background>$2500000,2500000;2500000,-2500000;-2500000,-2500000;-2500000,2500000$1$1$$$$

Then I use Territories Importer with Provinces_01.png (Creation mode: Provinces, Detail: Coarse). It completes without any visible errors.
provinces10.txt then contains new data (683 kb) and countries10.txt is unchanged.

When I select Pool in the dropdown and then select a province I can see that it now contains regions.

[[File:Kronnect1.png]]

So, the first error is that most of the provinces doesn't contain a main-region. mainRegionIndex is -1

« Last Edit: July 06, 2021, 07:19:09 AM by Pollyfun »

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #1 on: July 05, 2021, 10:32:34 PM »
Then, after clicking Play and running the game, and then stopping all the regions in the provinces have been lost.


Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #2 on: July 06, 2021, 11:17:46 AM »
Hello,

Just imported your map as countries, not provinces, and works fine:



A few notes:
- The Texture Importer will automatically select if the texture map is for countries or provinces. If the filename contains the word "province", it automatically suggests "provinces". However, you should only import a province map if you have previously imported a countries map because provinces are second-level entities. If there're no matching countries when you import a provinces map, the provinces will not be generated correctly or you can end with a mix of a previous countries map (ie. the Earth countries) and your fictional map.
- So, in the texture importer I chose "Countries" and clicked "Import". This operation imported the texture correctly and replaced all countries with your new map.
- Cities are preserved. In general, the import tools are quite conservative, in case you want to add extra parts of the world. So if you don't want to preserve the old cities nor the previous countries, just select "New Map" before clicking "Territory Importer". You can also remove the cities.txt file from the WMSK/Resources/Geodata folder or use the Map Editor to remove the cities using the Erase tool.
- Don't forget to click "Save" after the import or any other manual change.



Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #3 on: July 06, 2021, 11:19:53 AM »
Forgot to mention that, after the import, I also assigned your world texture to the inspector field:

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #4 on: July 06, 2021, 01:19:46 PM »
Thanks for the feedback. I created a new texture, Countries_01.png and imported as countries which seems to work. But after that when I import provinces I still get the same problem. Most provinces are missing a main-region. When I select a province in the dropdown-list it's not highlighted on the map (which seems to be because an exception is raised when there's no mainRegion).

I've attached the countries texture and a slightly updated provinces texture.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #5 on: July 06, 2021, 04:26:38 PM »
I fixed an issue with the cities being reloaded after clicking "New Map". This fix will be included in next beta.

However, I managed to import the countries and provinces correctly. The steps were:
1) Create a New Map.
2) Import the countries textures.
3) Save the map.
4) Import the provinces textures.
5) Save the map again.
6) Run the scene.

Highlight seems to work fine as well. I'm sending you the geodata produced by pm so you can replace the Geodata folder.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #6 on: July 06, 2021, 10:25:14 PM »
Thanks, using that sequence it does seem to work. :D

A related question, I will probably only have one country in the Countries_01.png, and then when loading the game I will loop through the provinces and
assign each to a country using data from a separate database. This is to easily support save/load games without changing any Geodata files.
Do you think CountryTransferProvinceRegion() is the best method for setting the owner?

Also, is there a best practice for handling sea provinces? I don't wan't them to have an owner, but I guess they must have one?

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #7 on: July 06, 2021, 11:55:02 PM »
In addition, what's the difference between Coarse and Fine? Is it for the shape of the regions?
countries10.txt and provinces10.txt looks to be the same size with either choice.


Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #8 on: July 07, 2021, 09:04:50 AM »
CountryTransferProvinceRegion() method will do that but it will also expand the country borders.
In WMSK, countries are mandatory, even if there's only one country. A province must belong to a country.

I've added a new CountryTransferProvince() method which is a simplified version of the above which just updates the link between a province and a country without messing with the country borders. This is a more convenient method to prepare your provinces when loading a new game. Use CountryTransferProvinceRegion() when you actually want the borders to be modified when one country is conquering provinces from another country. But if you want to keep the province shapes (ie. just coloring them to show ownership), then just use CountryTransferProvince() or simply color the provinces and don't change ownership at all.

The "Fine" vs "Coarse" option determines the radius of the kernel when finding different colors in the texture. Each different color represent a different territory (country or province, depending on what you're importing). The Fine option will use a kernel of 3x3 while a Coarse uses a 5x5 area to determine if a color is enough represented in the texture. This usually has no effect when you have large land areas with solid colors but if you have very small land patches, like tiny islands of less than 5x5 pixels in the textures, those could be ignored unless "Fine" is used.

 


Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #9 on: July 08, 2021, 12:11:33 AM »
Sounds great. CountryTransferProvince() will be in the next release?

I haven't fully got how borders work yet, I'll have to look more into that to determine the best way to handle province ownership.
Regarding sea regions, I'll create a hidden country that contains them, and is handled with special logic.


Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #10 on: July 11, 2021, 09:22:03 PM »
I've continued and created a mostly complete map that's intended to be used. But I can't get it to import correctly.
There are errors on both the country level and the province level.

The country texture contains 2 colors, one used for land and one used for water. When importing the sea area is ignored,
and the land area is split incorrectly into two countries, and the polygons are incorrect.



Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #11 on: July 12, 2021, 04:04:24 PM »
I've been able to reproduce the issue with the countries map. It seems that the right continent has too much detail for what the algorithm is designed and it fails to extract that region.

EDIT: it's related to a rogue white pixel in the original country texture. Still investigating...
« Last Edit: July 12, 2021, 04:50:57 PM by Kronnect »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 7262
    • View Profile
Re: Territories Importer issues
« Reply #12 on: July 12, 2021, 06:40:44 PM »
I've sent the geodata by pm with the fixed version which will be released as beta shortly.

A few notes:
1) The error was produced by a rogue white pixel which was producing a division in the borders of the right side continent. This has been fixed.
2) Territories must always be enclosed. This means that one can't create a territory that comprimes the non-land areas of the world map (ie. the ocean surrounding the continents).
3) Currently, the territory importer will import all provinces as long as they fall inside a country region. Overseas provinces are not supported - next beta will allow you to specify a country for overseas regions, so you will be able to specify it in the territory importer when you're importing provinces. Then, when sea provinces will be linked to that country (or be ignored if that field is not set in the form).

So, next beta will include the fix and also the abitlity to specify a country for overseas provinces. You could create this country after importing the country texture or choose any existing country if you wish (or leave this in blank which will produce overseas provinces will be ignored).

Regards

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #13 on: July 12, 2021, 10:21:33 PM »
Great that you found the white pixel. The import worked better here after removing it.  :)

It sounds good that the next version will support sea provinces. What I tried to do here was to create all regions as land regions and then use the watermap
to make some of them look like sea regions. Since the textures doesn't specify which regions are land and which regions are sea I don't see how the importer knows about that (?)

Two of the sea provinces were imported (although with the wrong owner). What I need for the game is for them to render with white borders (as in the image), to be able to highlight them
(separately since in the gameplay they will have no owner), and using tooltip to show additional information about them. Optimally, it wouldn't highlight land regions inside them but I know that's a separate issue.

Thanks for the quick feedback. If I get this importer to work it will save me a ton of time.

Pollyfun

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Re: Territories Importer issues
« Reply #14 on: July 13, 2021, 11:33:09 PM »
I had some progress with the sea provinces after adding a white frame in both the Countries and the Provinces textures. That seems to build around the problem that territories must be enclosed.
Two of the sea provinces and one of the land regions don't work, but hopefully I can update the textures somehow and fix that.