我有多边形,用于定义英国的县的轮廓。这些形状非常详细(每次10k到20k点),从而呈现相关计算(是多边形P的点x?)相当计算昂贵。

因此,我想“将”我的多边形“,以获得类似的形状,但点数较少。这样做的不同技术是什么?

琐碎的一个是每种世代古代古代代码点(因此由因子生成的分配),但这感觉太“粗糙”。我宁愿做一些指数的平均,或者那种味道的某些味道。任何指针?

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top