Domanda

Ho poligoni che definiscono il contorno delle contee nel Regno Unito.Queste forme sono molto dettagliate (10k a 20k punti ciascuno), rendendo così i calcoli correlati (è il punto X in poligono P>) abbastanza computazionalità costoso.

Quindi, vorrei "sottocampivare" i miei poligoni, per ottenere una forma simile ma con meno punti.Quali sono le diverse tecniche da fare?

Il banale sarebbe quello di prendere uno ogni punti N (quindi sollevando con un fattore N), ma questo è troppo "grezzo".Preferirei fare una media di punti, o qualcosa di quel sapore.Qualsiasi puntatore?

È stato utile?

Soluzione

Two solutions spring to mind:

1) since the map of the UK is reasonably squarish, you could choose to render a bitmap with the counties. Assign each a specific colour, and then render the borders with a 1 or 2 pixel thick black line. This means you'll only have to perform the expensive interior/exterior calculation if a sample happens to lie on the border. The larger the bitmap, the less often this will happen.

2) simplify the county outlines. You can use a recursive Ramer–Douglas–Peucker algorithm to recursively simplify the boundaries. Just make sure you cache the results. You may also have to solve this not for entire county boundaries but for shared boundaries only, to ensure no gaps. This might be quite tricky.

Altri suggerimenti

Here you can find a project dealing exactly with your issues. Although it works primarily with an area "filled" by points, you can set it to work with a "perimeter" type definition as yours.

It uses a k-nearest neighbors approach for calculating the region.

Samples:

enter image description here

Here you can request a copy of the paper.

Seemingly they planned to offer an online service for requesting calculations, but I didn't test it, and probably it isn't running.

HTH!

Polygon triangulation should help here. You'll still have to check many polygons, but these are triangles now, so they are easier to check and you can use some optimizations to determine only a small subset of polygons to check for a given region or point.

As it seems you have all the algorithms you need for polygons, not only for triangles, you can also merge several triangles that are too small after triangulation or if triangle count gets too high.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top