检查给定 dpi 和打印尺寸的矢量对象在打印时是否可见

发布于 2024-08-17 19:35:57 字数 182 浏览 9 评论 0原文

我有文件(GIS 中使用的 *.shp),其中包含多边形的集合,也许还有其他矢量对象(但多边形对我来说最重要)。我需要删除不可打印的对象。

不知道选择的标准是什么。我认为删除边框长度较小的对象会比删除面积较小的对象更好(这样长的对象会减少为线)。但也许有特殊的算法呢?

换句话说,我只想查找在给定缩放级别下可见的对象。

I have file (*.shp used in GIS) that contains collection of polygons and maybe other vector objects (but polygons are most important for me). I need to remove non printable objects it.

I don't know what criteria chose. I think removing objects with small border length would be better then removing objects with small area (so long objects will reduce to line). But maybe there is special algorithm for that?

In other words I want to find only that objects that are visible at given zoom level.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵强ㄟ 2024-08-24 19:35:57

那很简单。由于您没有提及任何语言,请考虑以下伪代码,

drawRect = myDevice.GetDrawRect();
for(oneShape in allShapes)
{
    shapeRect = oneShape.GetRect()
    if(! drawRect.Contains(shapeRect))
         oneShape.MarkAsInvisible(); 
    else
         oneShape.Draw();
}

Contains() 函数看起来像这样,假设 y 值从下到上增加:

bool Rect::Contains(OtherRect)

{
    if(left   <=  OtherRect.right  &&
       right  >=  OtherRect.left   &&
       top    >=  OtherRect.bottom &&
       bottom <=  OtherRect.top)
       return true

    return false;
}

Thats quite simple. As you dont mention any language consider the following pseudocode

drawRect = myDevice.GetDrawRect();
for(oneShape in allShapes)
{
    shapeRect = oneShape.GetRect()
    if(! drawRect.Contains(shapeRect))
         oneShape.MarkAsInvisible(); 
    else
         oneShape.Draw();
}

the Contains() function would look something like that, assuming that y-values increase from bottom to top:

bool Rect::Contains(OtherRect)

{
    if(left   <=  OtherRect.right  &&
       right  >=  OtherRect.left   &&
       top    >=  OtherRect.bottom &&
       bottom <=  OtherRect.top)
       return true

    return false;
}
起风了 2024-08-24 19:35:57

要消除的多边形取决于您要创建的图像的 dpi。如果一条线仅填充一个像素,则应将其消除或替换为点表示。当然,这会受到线宽的影响。许多此类问题可以通过使用专用的地图库来解决,例如 mapnik.org

The polygons to eliminate would depend on the dpi of the image you wish to create. If a line is only going to fill one pixel it should be eliminated or replaced with a point representation. Of course this will be effected by the width of the line. A lot of these sort of problems would be solved by using a dedicated mapping library such as mapnik.org

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文