Avoid_polygons - Are There MultiPolygon Restrictions?

Are there any restrictions related to the number of polygons and/or number of polygon points per polygon when requesting directions with avoid_polygons? I programmatically create avoid_polygons with numerous (typically >100) polygon points, and sequentially add these polygons to a multipolygon. From the second polygon onward, the avoid_polygons no longer get honored.

To elaborate on the idea, I would like ORS to provide a route to the starting point (black dot) of a predefined mountain bike descent (blue line), avoiding the potentially shortest way up which is the descent itself. The avoid_polygon is shown in the picture, but it does not make ORS propose a route different from the descent (ORS route: red line).

grafik

The actual admittely lengthy request string is attached for reference.

Thx for your help

{"coordinates":[[8.169100396335125,49.37458114698529],[8.121388759464025,49.37592074275017]],"options":{"avoid_features":["steps"],"avoid_polygons":{"type":"MultiPolygon","coordinates":[[[[8.159613843806158,49.37577356349516],[8.15982243832471,49.37580114083777],[8.162059747158649,49.375307867809184],[8.165879191609028,49.37568832113566],[8.166150382282785,49.375684149703915],[8.167475159947069,49.37534334031571],[8.167663485464075,49.37520427113783],[8.16778425608436,49.375003718915536],[8.167819085575774,49.37477221590666],[8.167762671463977,49.37454500634572],[8.167623602286099,49.37435668082871],[8.167423050063803,49.37423591020843],[8.167191547054925,49.374201080717015],[8.165996324488335,49.374485964957906],[8.16512686347042,49.37430494937758],[8.161880932055427,49.374118123638205],[8.159357186607947,49.374432864153505],[8.159124527955893,49.37440685092194],[8.158899624556456,49.37447185244126],[8.158716715913448,49.37461797281939],[8.158603648209693,49.37482296655334],[8.158577634978128,49.37505562520539],[8.158642636497447,49.37528052860483],[8.158788756875575,49.37546343724784],[8.158993750609527,49.375576504951596],[8.159613843806158,49.37577356349516]],[[8.123157528443942,49.376804214484004],[8.123966907464292,49.377018673188964],[8.124515106118002,49.37707184341674],[8.125658173481192,49.377015166757225],[8.126656442999765,49.376882746358916],[8.128060977929891,49.37682621771471],[8.1299282737798,49.37697896985496],[8.131912027815243,49.37712778928051],[8.132622238129585,49.3771209128506],[8.135777189826301,49.376359604525746],[8.141816274935398,49.3752889434011],[8.142183064163348,49.3753025878855],[8.143381370635733,49.374873046557],[8.143943741555942,49.37484957338091],[8.144662713480509,49.3746604518254],[8.144898663418475,49.374514168447824],[8.14498909200964,49.37449355294604],[8.144694130425172,49.37472956316426],[8.143843044335672,49.37513209495931],[8.14365146131939,49.375278276760284],[8.143532847171336,49.375488047718584],[8.143506336057373,49.37572756876547],[8.14357620460099,49.37595820171558],[8.143729577071356,49.376159837486725],[8.14391666206939,49.3763085854179],[8.144146970234884,49.37637249858106],[8.144849872507336,49.37645810539108],[8.144932831421412,49.37667702216789],[8.145093251287715,49.37684752789532],[8.145306709635813,49.37694366462201],[8.145540709367213,49.37695079640281],[8.145759626144018,49.37686783748873],[8.146880060940495,49.37632230650245],[8.147076719944833,49.37618787644583],[8.14720556961217,49.37598751685076],[8.147246299582726,49.37575281006857],[8.147192489658655,49.37552075254083],[8.147052621809225,49.37532792311153],[8.146848743172022,49.37520471716442],[8.146516242483818,49.37514447046571],[8.146176284162761,49.37516259298121],[8.14626813007281,49.37486185047439],[8.1462867509101,49.37462163017862],[8.146207932117147,49.37435116793032],[8.146327022757488,49.374197083268115],[8.14639255123955,49.37398156131918],[8.146373984490742,49.37375706417381],[8.146273939581594,49.37355523576008],[8.146106518312383,49.37340452474172],[8.145273660041308,49.372914380346586],[8.144296788713284,49.3725744784417],[8.144063899099175,49.37258499640618],[8.143852597675197,49.372683484517964],[8.143694784030343,49.372855074300396],[8.143614282852178,49.3730738613207],[8.143610240250394,49.37321192245745],[8.143561260882729,49.373426237705836],[8.143603168453847,49.3736661124726],[8.143256528164613,49.373675235785676],[8.143059552577636,49.37371254260441],[8.141838753223725,49.374087263157975],[8.14013180232692,49.3743281733338],[8.13554060710797,49.37518303252823],[8.132530058532778,49.375922633630005],[8.130615182822684,49.375722039171364],[8.129864060784953,49.37577935790156],[8.12803985600992,49.37562566792578],[8.126543721065,49.37563951731701],[8.126301049819027,49.37564313520718],[8.12451066067081,49.375871001614215],[8.123338472455954,49.37560947044455],[8.123062347669064,49.37559960057267],[8.122357283845146,49.37575179014018],[8.122162663264467,49.375881903806516],[8.122032649637802,49.37607659123157],[8.121987036361238,49.37630621301972],[8.122032767642645,49.376535811335245],[8.122162881308983,49.376730431915924],[8.122357568734035,49.37686044554259],[8.122587190522186,49.37690605881915],[8.123157528443942,49.376804214484004],[8.123157528443942,49.376804214484004]]],[[[8.159613843806158,49.37577356349516],[8.15982243832471,49.37580114083777],[8.162059747158649,49.375307867809184],[8.165879191609028,49.37568832113566],[8.166150382282785,49.375684149703915],[8.167475159947069,49.37534334031571],[8.167663485464075,49.37520427113783],[8.16778425608436,49.375003718915536],[8.167819085575774,49.37477221590666],[8.167762671463977,49.37454500634572],[8.167623602286099,49.37435668082871],[8.167423050063803,49.37423591020843],[8.167191547054925,49.374201080717015],[8.165996324488335,49.374485964957906],[8.16512686347042,49.37430494937758],[8.161880932055427,49.374118123638205],[8.159357186607947,49.374432864153505],[8.159124527955893,49.37440685092194],[8.158899624556456,49.37447185244126],[8.158716715913448,49.37461797281939],[8.158603648209693,49.37482296655334],[8.158577634978128,49.37505562520539],[8.158642636497447,49.37528052860483],[8.158788756875575,49.37546343724784],[8.158993750609527,49.375576504951596],[8.159613843806158,49.37577356349516]],[[8.123157528443942,49.376804214484004],[8.123966907464292,49.377018673188964],[8.124515106118002,49.37707184341674],[8.125658173481192,49.377015166757225],[8.126656442999765,49.376882746358916],[8.128060977929891,49.37682621771471],[8.1299282737798,49.37697896985496],[8.131912027815243,49.37712778928051],[8.132622238129585,49.3771209128506],[8.135777189826301,49.376359604525746],[8.141816274935398,49.3752889434011],[8.142183064163348,49.3753025878855],[8.143381370635733,49.374873046557],[8.143943741555942,49.37484957338091],[8.144662713480509,49.3746604518254],[8.144898663418475,49.374514168447824],[8.14498909200964,49.37449355294604],[8.144694130425172,49.37472956316426],[8.143843044335672,49.37513209495931],[8.14365146131939,49.375278276760284],[8.143532847171336,49.375488047718584],[8.143506336057373,49.37572756876547],[8.14357620460099,49.37595820171558],[8.143729577071356,49.376159837486725],[8.14391666206939,49.3763085854179],[8.144146970234884,49.37637249858106],[8.144849872507336,49.37645810539108],[8.144932831421412,49.37667702216789],[8.145093251287715,49.37684752789532],[8.145306709635813,49.37694366462201],[8.145540709367213,49.37695079640281],[8.145759626144018,49.37686783748873],[8.146880060940495,49.37632230650245],[8.147076719944833,49.37618787644583],[8.14720556961217,49.37598751685076],[8.147246299582726,49.37575281006857],[8.147192489658655,49.37552075254083],[8.147052621809225,49.37532792311153],[8.146848743172022,49.37520471716442],[8.146516242483818,49.37514447046571],[8.146176284162761,49.37516259298121],[8.14626813007281,49.37486185047439],[8.1462867509101,49.37462163017862],[8.146207932117147,49.37435116793032],[8.146327022757488,49.374197083268115],[8.14639255123955,49.37398156131918],[8.146373984490742,49.37375706417381],[8.146273939581594,49.37355523576008],[8.146106518312383,49.37340452474172],[8.145273660041308,49.372914380346586],[8.144296788713284,49.3725744784417],[8.144063899099175,49.37258499640618],[8.143852597675197,49.372683484517964],[8.143694784030343,49.372855074300396],[8.143614282852178,49.3730738613207],[8.143610240250394,49.37321192245745],[8.143561260882729,49.373426237705836],[8.143603168453847,49.3736661124726],[8.143256528164613,49.373675235785676],[8.143059552577636,49.37371254260441],[8.141838753223725,49.374087263157975],[8.14013180232692,49.3743281733338],[8.13554060710797,49.37518303252823],[8.132530058532778,49.375922633630005],[8.130615182822684,49.375722039171364],[8.129864060784953,49.37577935790156],[8.12803985600992,49.37562566792578],[8.126543721065,49.37563951731701],[8.126301049819027,49.37564313520718],[8.12451066067081,49.375871001614215],[8.123338472455954,49.37560947044455],[8.123062347669064,49.37559960057267],[8.122357283845146,49.37575179014018],[8.122162663264467,49.375881903806516],[8.122032649637802,49.37607659123157],[8.121987036361238,49.37630621301972],[8.122032767642645,49.376535811335245],[8.122162881308983,49.376730431915924],[8.122357568734035,49.37686044554259],[8.122587190522186,49.37690605881915],[8.123157528443942,49.376804214484004],[8.123157528443942,49.376804214484004]]]]}}}

Hi @UliE,

The restrictions are not related to the number of polygons but to their area which can be a maximum of 200.000 square kilometers. (there is another restriction where you can’t pass really thin and long polygons e.g. 0.002 x 100.000.000 km rectangles as this would slow processing down)

It is sufficient to place a small avoid polygon on top of a way segment for it to be avoided.

I think your Multipolygon is not properly formatted.

  1. make sure to not use these quotes “coordinates” but these"coordinates"
  2. make sure you are passing a correct MultiPolygon. check that you are not accidentally passing a Polygon with an inner ring instead of 2 Polygons.

In you request above you also have each polygon twice.
A body similar to this should work:

{
  "elevation": true,
  "options": {
    "avoid_polygons": {
      "type": "MultiPolygon",
      "coordinates": [
        [
          [
            [
              "8.12265",
              "49.37668"
            ],
            [
              "8.12344",
              "49.37699"
            ],
            [
              "8.12649",
              "49.37696"
            ],
            [
              "8.13202",
              "49.37682"
            ],
            [
              "8.13651",
              "49.37624"
            ],
            [
              "8.14037",
              "49.37545"
            ],
            [
              "8.13981",
              "49.3774"
            ],
            [
              "8.14430",
              "49.37684"
            ],
            [
              "8.14597",
              "49.37656"
            ],
            [
              "8.14825",
              "49.37619"
            ],
            [
              "8.14644",
              "49.37562"
            ],
            [
              "8.1428",
              "49.37586"
            ],
            [
              "8.14657",
              "49.37499"
            ],
            [
              "8.14640",
              "49.37351"
            ],
            [
              "8.14387",
              "49.37257"
            ],
            [
              "8.14140",
              "49.37417"
            ],
            [
              "8.13245",
              "49.37584"
            ],
            [
              "8.12383",
              "49.37563"
            ],
            [
              "8.12282",
              "49.37596"
            ],
            [
              "8.12265",
              "49.37668"
            ]
          ]
        ],
        [
          [
            [
              "8.15924",
              "49.37481"
            ],
            [
              "8.15904",
              "49.37531"
            ],
            [
              "8.16024",
              "49.37560"
            ],
            [
              "8.16743",
              "49.37532"
            ],
            [
              "8.16824",
              "49.37494"
            ],
            [
              "8.16784",
              "49.37440"
            ],
            [
              "8.16239",
              "49.37449"
            ],
            [
              "8.15924",
              "49.37481"
            ]
          ]
        ]
      ]
    }
  },
  "coordinates": [
    [
      8.1216,
      49.375863
    ],
    [
      8.148272,
      49.376722
    ]
  ],
  "extra_info": [
    "steepness",
    "waytype",
    "surface"
  ]
}

Best regards

Thanks for your quick reply and your advice, I will try and implement it accordingly

There was a conceptual mistake in the model that builds the nested multipolygon array. Now that it is fixed it works like a charm.

Many thanks again for pointing me in the right direction.

Best regards Uli