__init__.py 文件源码

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

项目:dati-ckan-docker 作者: italia 项目源码 文件源码
def _bbox_2_wkt(bbox, srid):
    '''
    Given a bbox dictionary, return a WKTSpatialElement, transformed
    into the database\'s CRS if necessary.

    returns e.g. WKTSpatialElement("POLYGON ((2 0, 2 1, 7 1, 7 0, 2 0))", 4326)
    '''
    db_srid = int(config.get('ckan.spatial.srid', '4326'))

    bbox_template = Template('POLYGON (($minx $miny, $minx $maxy, $maxx $maxy, $maxx $miny, $minx $miny))')

    wkt = bbox_template.substitute(minx=bbox['minx'],
                                        miny=bbox['miny'],
                                        maxx=bbox['maxx'],
                                        maxy=bbox['maxy'])

    if srid and srid != db_srid:
        # Input geometry needs to be transformed to the one used on the database
        input_geometry = ST_Transform(WKTElement(wkt,srid),db_srid)
    else:
        input_geometry = WKTElement(wkt,db_srid)
    return input_geometry
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号