qgis_hal.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:albion 作者: Oslandia 项目源码 文件源码
def intersect_point_layer_with_wkt(layer, wkt, buffer_width):
    """ Return all features from given layer that intersects with wkt """

    assert QgsWKBTypes.geometryType(
            int(layer.wkbType())) == QgsWKBTypes.PointGeometry

    line = loads(wkt.replace('Z', ' Z'))

    if not line.is_valid:
        logging.warning('Invalid feature geometry wkt={}'.format(wkt))
        return

    # square cap style for the buffer -> less points
    buf = line.buffer(buffer_width, cap_style=2)
    bbox = QgsRectangle(
        buf.bounds[0], buf.bounds[1], buf.bounds[2], buf.bounds[3])

    # request features inside bounding-box
    for feature in layer.getFeatures(QgsFeatureRequest(bbox)):
        p = feature.geometry().asPoint()
        if buf.contains(Point(p.x(), p.y())):
            yield feature
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号