Polygon grabber tool issues with islands inside a single territory



  • In my current experience, it seems that I am having issues with the polygon grabber making the correct boundaries for a big territory that contains others in 3 instances:

    • A "island" territory inside of a single land territory.
      I dont have a in-game screenshot of this as I fixed it by rearranging the borders slightly, but I do have a old screenshot of what it looked like. In this case, the enclave wasnt selectable and hovering over it selected the territory that enclosed it.
      ss1.png
    • A island that is split into two or more territories inside a single sea territory.
      Same as above, as it was near the coast I joined it to the "mainland" to fix it. In this case, the sea territory was over the two island territories and the two of them werent selectable.
      ss2.png
    • Two or more different island territories inside a single sea territory. In this case I have 2 screenshots from in-game;
      Print screen doesnt capture the mouse cursor, but in the first screenshot my cursor is over "Fenris Keep" and the polygon grabber has put all this as being part of "Lordamere Lake" sea territory. Strangely tho, "The Dawning Isles" territory is properly done and is selectable.
      ss3.png
      In this screenshot, it doesnt matter where I move my mouse cursor all 3 land territories come up as being part of "SZ21" sea territory.
      ss4.png

    Is it just something im doing wrong or do other people have issues with these scenarios?


  • Moderators Admin

    @Zaroph It is not possible to exclude any enclave from a zone's polygon. Therefore, when you have a zone fully inside another zone, the smaller zone will be selectable only if it happens to be prioritized (I don't know how that is determined), which is something you should never rely upon (as it is wrong mapmaking anyway, no matter if it happens to work). As now, to the extent of my knowledge, the only way to define priority when zones are overlapping is having the deprioritized zone's name ending or starting exactly as "Sea Zone" (yes, it is a dumb naming hack you are supposed always to follow if you want to have any zone within an other zone being properly supported by the program).

    Long story short, you need to name every zone inside of which one or more other zones are so that it starts or ends exactly as "Sea Zone" (I suggest ending over starting).

    Alternatively, you can draw a line between the borders of the zone within an other zone and the other zone (this will avoid overlapping), but this is substantially a graphic hack that arguably looks bad (and it is usually hidden by the map's details, which is an other hack, and one that works only as long as the details are not switched off by the user).

    The best, of course, would be that a developer allows for supporting such cases in a better manner. So, maybe, you want to open a feature request, about it.



  • Thanks for responding. These issues were plaguing me from finishing up my map but I see how to fix them now.

    Alternatively, you can draw a line between the borders of the zone within an other zone and the other zone (this will avoid overlapping), but this is substantially a graphic hack that arguably looks bad (and it is usually hidden by the map's details, which is an other hack, and one that works only as long as the details are not switched off by the user).

    I think I prefer this to naming as its less noticable then a territory name, and I can do it in my case by hiding the lines behind the bridges.


  • Admin

    Island detection is looking exclusively at 'water' tiles, ie: sea zones.

    Sea Zones are identified by their name suffix (arguably a poor design). Hence the naming hack works, but you could see other issues as the engine is likely to think the land territory is a SZ.


  • Moderators Admin

    @LaFayette said in Polygon grabber tool issues with islands inside a single territory:

    Sea Zones are identified by their name suffix (arguably a poor design). Hence the naming hack works, but you could see other issues as the engine is likely to think the land territory is a SZ.

    @LaFayette I don't think so. What does you make believe that calling a land territory with a name starting or ending, or both, as "Sea Zone" might give any issue?

    As far as I know, you can call a land territory with a name starting or ending, or both, as "Sea Zone", and it will be a fully functional land territory anyway. As far as I know, calling a zone (territory or not) as "Sea Zone" is only for deprioritizing the drawing of it at the skin level, and has absolutely nothing to do with the zone being land or sea (water) (meaning it can be indifferently applied for islands within sea zones called as "Sea Zone" or lakes within land zones called as "Sea Zone").


  • Admin

    The logic for finding islands in question is in IslandTerritoryFinder.java. You can follow the call chain:

      static Map<String, Set<String>> findIslands(final Map<String, List<Polygon>> polygons) {
        final Set<String> seaTerritories = filterSeaTerritories(polygons.keySet());
        final Set<String> landTerritories = filterNotSeaTerritories(polygons.keySet());
    
      private static Set<String> filterSeaTerritories(final Set<String> territoryNames) {
        return filterTerritories(territoryNames, Util::isTerritoryNameIndicatingWater);
      }
    
      /**
       * Checks whether name indicates water or not (meaning name starts or ends with default text).
       *
       * @param territoryName - territory name
       * @return true if yes, false otherwise
       */
      public static boolean isTerritoryNameIndicatingWater(final String territoryName) {
        return territoryName.endsWith(TERRITORY_SEA_ZONE_INFIX)
            || territoryName.startsWith(TERRITORY_SEA_ZONE_INFIX);
      }
    

    So essentially it finds all sea territories by looking for any territory that starts with "Sea Zone" or ends with "Sea Zone". Whether that territory is actually a sea zone or not is immaterial. The above is certainly very poor design by relying on a magic naming convention, but be what it may, that is the case.

    There are additional usages of the territory name checking for "Sea Zone" in the name, so island finding is not the only case.


  • Moderators Admin

    @LaFayette I don't know what you are referring to, here.

    Mapmaking utilities aside, the only behaviour I'm aware of related to a name starting or ending, or both, as "Sea Zone" is to draw the zone undernead any other zone (thus making the other zone or zones "clickable").

    If I'm not aware of any other ones, I dare to presume not a lot of persons are, either, which is probably a case of bad or missing documentation, unless I'm missing something.


  • Admin

    I'm pointing you @Cernel to the code that detects 'islands' and it looks at Sea Zones based on their name. You asked me why I thought that, that code is the reason/answer (because it does look at name). Hence, you can still have a land territory, but if you name it right, that is why the island finding code will pick it up even though it's still functioning as a land. It's certainly a hack because the land/sea-zone detection is inconsistent so you can have a 'land' territory be detected as a sea zone based on name in other cases as well.


  • Moderators Admin

    @LaFayette As far as I know, a zone called "Sea Zone" should not be "detected as a sea zone", but just deprioritized when overlapping with another zone not called "Sea Zone".

    As far as I know, how it should work is that a land territory called "Sea Zone" should overlap under a sea zone not called as "Sea Zone", the first being a land territory at all effects (no mater if called as "Sea Zone") and the second being a sea zone at all effects. Would this not work or have other consequences?

    I'm still not understanding what are these "additional usages" you are mentioning.


  • Admin

    The SZ name in territory is used as part of:

    • territory click detection
    • relief image breaker
    • center picker
    • placement picker

    That list is not fully exhaustive, it gets pretty complex to go down the tree of everything that uses that functionality and then everything that relies on that and so on.. It's a mess that the name of a territory is used at all to determine the territory type, in particular because it is not consistently done in that manner either.


  • Moderators Admin

    @LaFayette said in Polygon grabber tool issues with islands inside a single territory:

    The SZ name in territory is used as part of:

    • territory click detection
    • relief image breaker
    • center picker
    • placement picker

    That list is not fully exhaustive, it gets pretty complex to go down the tree of everything that uses that functionality and then everything that relies on that and so on.. It's a mess that the name of a territory is used at all to determine the territory type, in particular because it is not consistently done in that manner either.

    Right, that is why I said "mapmaking utilities aside". So, once you have made the map, the only one of these points that matters is the "territory click detection" one, which is the only one I'm aware of, as well, if that comprises hovering the cursor to get information, as well.


Log in to reply