Exemplo n.º 1
0
def build_curv_tol_weight_map(tile, weight_array):
    if tile.apt_curv_tol != tile.curvature_tol and tile.apt_curv_tol > 0:
        UI.vprint(
            1,
            "-> Modifying curv_tol weight map according to runway locations.")
        try:
            f = open(FNAMES.apt_file(tile), 'rb')
            dico_airports = pickle.load(f)
            f.close()
        except:
            UI.vprint(
                1, "   WARNING: File", FNAMES.apt_file(tile),
                "is missing (erased after Step 1?), cannot check airport info for upgraded zoomlevel."
            )
            dico_airports = {}
        for airport in dico_airports:
            (xmin, ymin, xmax,
             ymax) = dico_airports[airport]['boundary'].bounds
            x_shift = 1000 * tile.apt_curv_ext * GEO.m_to_lon(tile.lat)
            y_shift = 1000 * tile.apt_curv_ext * GEO.m_to_lat
            colmin = max(round((xmin - x_shift) * 1000), 0)
            colmax = min(round((xmax + x_shift) * 1000), 1000)
            rowmax = min(round(((1 - ymin) + y_shift) * 1000), 1000)
            rowmin = max(round(((1 - ymax) - y_shift) * 1000), 0)
            weight_array[rowmin:rowmax + 1, colmin:colmax +
                         1] = tile.curvature_tol / tile.apt_curv_tol
    if tile.coast_curv_tol != tile.curvature_tol:
        UI.vprint(
            1,
            "-> Modifying curv_tol weight map according to coastline location."
        )
        sea_layer = OSM.OSM_layer()
        queries = ['way["natural"="coastline"]']
        tags_of_interest = []
        if not OSM.OSM_queries_to_OSM_layer(queries,
                                            sea_layer,
                                            tile.lat,
                                            tile.lon,
                                            tags_of_interest,
                                            cached_suffix='coastline'):
            return 0
        for nodeid in sea_layer.dicosmn:
            (lonp, latp) = [float(x) for x in sea_layer.dicosmn[nodeid]]
            if lonp < tile.lon or lonp > tile.lon + 1 or latp < tile.lat or latp > tile.lat + 1:
                continue
            x_shift = 1000 * tile.coast_curv_ext * GEO.m_to_lon(tile.lat)
            y_shift = tile.coast_curv_ext / (111.12)
            colmin = max(round((lonp - tile.lon - x_shift) * 1000), 0)
            colmax = min(round((lonp - tile.lon + x_shift) * 1000), 1000)
            rowmax = min(round((tile.lat + 1 - latp + y_shift) * 1000), 1000)
            rowmin = max(round((tile.lat + 1 - latp - y_shift) * 1000), 0)
            weight_array[rowmin:rowmax + 1, colmin:colmax + 1] = numpy.maximum(
                weight_array[rowmin:rowmax + 1, colmin:colmax + 1],
                tile.curvature_tol / tile.coast_curv_tol)
        del (sea_layer)
    # It could be of interest to write the weight file as a png for user editing
    #from PIL import Image
    #Image.fromarray((weight_array!=1).astype(numpy.uint8)*255).save('weight.png')
    return
def discard_unwanted_airports(tile, dico_airports):
    # A bit of cleaning (aeromodelism, helipads, should be removed here)
    for airport in list(dico_airports.keys()):
        apt = dico_airports[airport]
        #if apt['key_type'] in ('icao','iata','local_ref'): continue
        if apt['boundary']:
            if apt['boundary'].area < 5000 * GEO.m_to_lat * GEO.m_to_lon(
                    tile.lat):
                # too small, skip it
                dico_airports.pop(airport, None)
            continue
        if apt['runway'][0].area < 2500 * GEO.m_to_lat * GEO.m_to_lon(
                tile.lat):
            # too small, skip it
            dico_airports.pop(airport, None)
            continue
def flatten_helipads(airport_layer, vector_map, tile, patches_area):
    multipol = []
    seeds = []
    total = 0
    # helipads whose boundary is encoded in OSM
    for wayid in (x for x in airport_layer.dicosmw
                  if x in airport_layer.dicosmtags['w']
                  and 'aeroway' in airport_layer.dicosmtags['w'][x] and
                  airport_layer.dicosmtags['w'][x]['aeroway'] == 'helipad'):
        if airport_layer.dicosmw[wayid][0] != airport_layer.dicosmw[wayid][-1]:
            continue
        way = numpy.round(
            numpy.array([
                airport_layer.dicosmn[nodeid]
                for nodeid in airport_layer.dicosmw[wayid]
            ]) - numpy.array([[tile.lon, tile.lat]]), 7)
        pol = geometry.Polygon(way)
        if (pol.is_empty) or (not pol.is_valid) or (not pol.area) or (
                pol.intersects(patches_area)):
            continue
        multipol.append(pol)
        alti_way = numpy.ones(
            (len(way), 1)) * numpy.mean(tile.dem.alt_vec(way))
        vector_map.insert_way(numpy.hstack([way, alti_way]),
                              'INTERP_ALT',
                              check=True)
        seeds.append(numpy.array(pol.representative_point()))
        total += 1
    helipad_area = ops.cascaded_union(multipol)
    # helipads that are only encoded as nodes, they will be grown into hexagons
    for nodeid in (x for x in airport_layer.dicosmn
                   if x in airport_layer.dicosmtags['n']
                   and 'aeroway' in airport_layer.dicosmtags['n'][x] and
                   airport_layer.dicosmtags['n'][x]['aeroway'] == 'helipad'):
        center = numpy.round(
            numpy.array(airport_layer.dicosmn[nodeid]) -
            numpy.array([tile.lon, tile.lat]), 7)
        if geometry.Point(center).intersects(helipad_area) or geometry.Point(
                center).intersects(patches_area):
            continue
        way = numpy.round(
            center + numpy.array([[
                cos(k * pi / 3) * 7 * GEO.m_to_lon(tile.lat),
                sin(k * pi / 3) * 7 * GEO.m_to_lat
            ] for k in range(7)]), 7)
        alti_way = numpy.ones(
            (len(way), 1)) * numpy.mean(tile.dem.alt_vec(way))
        vector_map.insert_way(numpy.hstack([way, alti_way]),
                              'INTERP_ALT',
                              check=True)
        seeds.append(center)
        total += 1
    if seeds:
        if 'INTERP_ALT' in vector_map.seeds:
            vector_map.seeds['INTERP_ALT'] += seeds
        else:
            vector_map.seeds['INTERP_ALT'] = seeds
    if total:
        UI.vprint(1, "   Flattened", total, "helipads.")
def build_airport_array(tile, dico_airports):
    airport_array = numpy.zeros((1001, 1001), dtype=numpy.bool)
    for airport in dico_airports:
        (xmin, ymin, xmax, ymax) = dico_airports[airport]['boundary'].bounds
        x_shift = 1500 * GEO.m_to_lon(tile.lat)
        y_shift = 1500 * GEO.m_to_lat
        colmin = max(round((xmin - x_shift) * 1000), 0)
        colmax = min(round((xmax + x_shift) * 1000), 1000)
        rowmax = min(round(((1 - ymin) + y_shift) * 1000), 1000)
        rowmin = max(round(((1 - ymax) - y_shift) * 1000), 0)
        airport_array[rowmin:rowmax + 1, colmin:colmax + 1] = True
    return airport_array
Exemplo n.º 5
0
def zone_list_to_ortho_dico(tile):
    # tile.zone_list is a list of 3-uples of the form ([(lat0,lat0),...(latN,lonN),zoomlevel,provider_code)
    # where higher lines have priority over lower ones.
    masks_im = Image.new("L", (4096, 4096), 'black')
    masks_draw = ImageDraw.Draw(masks_im)
    airport_array = numpy.zeros((4096, 4096), dtype=numpy.bool)
    if tile.cover_airports_with_highres in ['True', 'ICAO']:
        UI.vprint(1, "-> Checking airport locations for upgraded zoomlevel.")
        try:
            f = open(FNAMES.apt_file(tile), 'rb')
            dico_airports = pickle.load(f)
            f.close()
        except:
            UI.vprint(
                1, "   WARNING: File", FNAMES.apt_file(tile),
                "is missing (erased after Step 1?), cannot check airport info for upgraded zoomlevel."
            )
            dico_airports = {}
        if tile.cover_airports_with_highres == 'ICAO':
            airports_list = [
                airport for airport in dico_airports
                if dico_airports[airport]['key_type'] == 'icao'
            ]
        else:
            airports_list = dico_airports.keys()
        for airport in airports_list:
            (xmin, ymin, xmax,
             ymax) = dico_airports[airport]['boundary'].bounds
            # extension
            xmin -= 1000 * tile.cover_extent * GEO.m_to_lon(tile.lat)
            xmax += 1000 * tile.cover_extent * GEO.m_to_lon(tile.lat)
            ymax += 1000 * tile.cover_extent * GEO.m_to_lat
            ymin -= 1000 * tile.cover_extent * GEO.m_to_lat
            # round off to texture boundaries at tile.cover_zl zoomlevel
            (til_x_left,
             til_y_top) = GEO.wgs84_to_orthogrid(ymax + tile.lat,
                                                 xmin + tile.lon,
                                                 tile.cover_zl)
            (ymax, xmin) = GEO.gtile_to_wgs84(til_x_left, til_y_top,
                                              tile.cover_zl)
            ymax -= tile.lat
            xmin -= tile.lon
            (til_x_left2,
             til_y_top2) = GEO.wgs84_to_orthogrid(ymin + tile.lat,
                                                  xmax + tile.lon,
                                                  tile.cover_zl)
            (ymin, xmax) = GEO.gtile_to_wgs84(til_x_left2 + 16,
                                              til_y_top2 + 16, tile.cover_zl)
            ymin -= tile.lat
            xmax -= tile.lon
            xmin = max(0, xmin)
            xmax = min(1, xmax)
            ymin = max(0, ymin)
            ymax = min(1, ymax)
            # mark to airport_array
            colmin = round(xmin * 4095)
            colmax = round(xmax * 4095)
            rowmax = round((1 - ymin) * 4095)
            rowmin = round((1 - ymax) * 4095)
            airport_array[rowmin:rowmax + 1, colmin:colmax + 1] = 1
    dico_customzl = {}
    dico_tmp = {}
    til_x_min, til_y_min = GEO.wgs84_to_orthogrid(tile.lat + 1, tile.lon,
                                                  tile.mesh_zl)
    til_x_max, til_y_max = GEO.wgs84_to_orthogrid(tile.lat, tile.lon + 1,
                                                  tile.mesh_zl)
    i = 1
    base_zone = ((tile.lat, tile.lon, tile.lat, tile.lon + 1, tile.lat + 1,
                  tile.lon + 1, tile.lat + 1, tile.lon, tile.lat, tile.lon),
                 tile.default_zl, tile.default_website)
    for region in [base_zone] + tile.zone_list[::-1]:
        dico_tmp[i] = (region[1], region[2])
        pol = [(round((x - tile.lon) * 4095), round((tile.lat + 1 - y) * 4095))
               for (x, y) in zip(region[0][1::2], region[0][::2])]
        masks_draw.polygon(pol, fill=i)
        i += 1
    for til_x in range(til_x_min, til_x_max + 1, 16):
        for til_y in range(til_y_min, til_y_max + 1, 16):
            (latp, lonp) = GEO.gtile_to_wgs84(til_x + 8, til_y + 8,
                                              tile.mesh_zl)
            lonp = max(min(lonp, tile.lon + 1), tile.lon)
            latp = max(min(latp, tile.lat + 1), tile.lat)
            x = round((lonp - tile.lon) * 4095)
            y = round((tile.lat + 1 - latp) * 4095)
            (zoomlevel, provider_code) = dico_tmp[masks_im.getpixel((x, y))]
            if airport_array[y, x]:
                zoomlevel = max(zoomlevel, tile.cover_zl)
            til_x_text = 16 * (int(til_x / 2**(tile.mesh_zl - zoomlevel)) //
                               16)
            til_y_text = 16 * (int(til_y / 2**(tile.mesh_zl - zoomlevel)) //
                               16)
            dico_customzl[(til_x, til_y)] = (til_x_text, til_y_text, zoomlevel,
                                             provider_code)
    if tile.cover_airports_with_highres == 'Existing':
        # what we find in the texture folder of the existing tile
        for f in os.listdir(os.path.join(tile.build_dir, 'textures')):
            if f[-4:] != '.dds': continue
            items = f.split('_')
            (til_y_text, til_x_text) = [int(x) for x in items[:2]]
            zoomlevel = int(items[-1][-6:-4])
            provider_code = '_'.join(items[2:])[:-6]
            for til_x in range(til_x_text * 2**(tile.mesh_zl - zoomlevel),
                               (til_x_text + 16) *
                               2**(tile.mesh_zl - zoomlevel)):
                for til_y in range(til_y_text * 2**(tile.mesh_zl - zoomlevel),
                                   (til_y_text + 16) *
                                   2**(tile.mesh_zl - zoomlevel)):
                    if ((til_x, til_y) not in dico_customzl) or dico_customzl[
                        (til_x, til_y)][2] <= zoomlevel:
                        dico_customzl[(til_x,
                                       til_y)] = (til_x_text, til_y_text,
                                                  zoomlevel, provider_code)
    return dico_customzl
Exemplo n.º 6
0
def zone_list_to_ortho_dico(tile):
    # tile.zone_list is a list of 3-uples of the form ([(lat0,lat0),...(latN,lonN),zoomlevel,provider_code)
    # where higher lines have priority over lower ones.
    masks_im = Image.new("L", (4096, 4096), 'black')
    masks_draw = ImageDraw.Draw(masks_im)
    airport_array = numpy.zeros((4096, 4096), dtype=numpy.bool)
    if tile.cover_airports_with_highres:
        UI.vprint(1, "-> Checking airport locations for upgraded zoomlevel.")
        try:
            f = open(FNAMES.apt_file(tile), 'rb')
            dico_airports = pickle.load(f)
            f.close()
        except:
            UI.vprint(
                1, "   WARNING: File", FNAMES.apt_file(tile),
                "is missing (erased after Step 1?), cannot check airport info for upgraded zoomlevel."
            )
            dico_airports = {}
        for airport in dico_airports:
            (xmin, ymin, xmax,
             ymax) = dico_airports[airport]['boundary'].bounds
            # extension
            xmin -= 1000 * tile.cover_extent * GEO.m_to_lon(tile.lat)
            xmax += 1000 * tile.cover_extent * GEO.m_to_lon(tile.lat)
            ymax += 1000 * tile.cover_extent * GEO.m_to_lat
            ymin -= 1000 * tile.cover_extent * GEO.m_to_lat
            # round off to texture boundaries at tile.cover_zl zoomlevel
            (til_x_left,
             til_y_top) = GEO.wgs84_to_orthogrid(ymax + tile.lat,
                                                 xmin + tile.lon,
                                                 tile.cover_zl)
            (ymax, xmin) = GEO.gtile_to_wgs84(til_x_left, til_y_top,
                                              tile.cover_zl)
            ymax -= tile.lat
            xmin -= tile.lon
            (til_x_left2,
             til_y_top2) = GEO.wgs84_to_orthogrid(ymin + tile.lat,
                                                  xmax + tile.lon,
                                                  tile.cover_zl)
            (ymin, xmax) = GEO.gtile_to_wgs84(til_x_left2 + 16,
                                              til_y_top2 + 16, tile.cover_zl)
            ymin -= tile.lat
            xmax -= tile.lon
            xmin = max(0, xmin)
            xmax = min(1, xmax)
            ymin = max(0, ymin)
            ymax = min(1, ymax)
            # mark to airport_array
            colmin = round(xmin * 4095)
            colmax = round(xmax * 4095)
            rowmax = round((1 - ymin) * 4095)
            rowmin = round((1 - ymax) * 4095)
            airport_array[rowmin:rowmax + 1, colmin:colmax + 1] = 1
    dico_tmp = {}
    dico_customzl = {}
    i = 1
    base_zone = ((tile.lat, tile.lon, tile.lat, tile.lon + 1, tile.lat + 1,
                  tile.lon + 1, tile.lat + 1, tile.lon, tile.lat, tile.lon),
                 tile.default_zl, tile.default_website)
    for region in [base_zone] + tile.zone_list[::-1]:
        dico_tmp[i] = (region[1], region[2])
        pol = [(round((x - tile.lon) * 4095), round((tile.lat + 1 - y) * 4095))
               for (x, y) in zip(region[0][1::2], region[0][::2])]
        masks_draw.polygon(pol, fill=i)
        i += 1
    til_x_min, til_y_min = GEO.wgs84_to_orthogrid(tile.lat + 1, tile.lon,
                                                  tile.mesh_zl)
    til_x_max, til_y_max = GEO.wgs84_to_orthogrid(tile.lat, tile.lon + 1,
                                                  tile.mesh_zl)
    for til_x in range(til_x_min, til_x_max + 1, 16):
        for til_y in range(til_y_min, til_y_max + 1, 16):
            (latp, lonp) = GEO.gtile_to_wgs84(til_x + 8, til_y + 8,
                                              tile.mesh_zl)
            lonp = max(min(lonp, tile.lon + 1), tile.lon)
            latp = max(min(latp, tile.lat + 1), tile.lat)
            x = round((lonp - tile.lon) * 4095)
            y = round((tile.lat + 1 - latp) * 4095)
            (zoomlevel, provider_code) = dico_tmp[masks_im.getpixel((x, y))]
            if airport_array[y, x]:
                zoomlevel = max(zoomlevel, tile.cover_zl)
            til_x_text = 16 * (int(til_x / 2**(tile.mesh_zl - zoomlevel)) //
                               16)
            til_y_text = 16 * (int(til_y / 2**(tile.mesh_zl - zoomlevel)) //
                               16)
            dico_customzl[(til_x, til_y)] = (til_x_text, til_y_text, zoomlevel,
                                             provider_code)
    return dico_customzl
Exemplo n.º 7
0
def zone_list_to_ortho_dico(tile):
        # tile.zone_list is a list of 3-uples of the form ([(lat0,lat0),...(latN,lonN),zoomlevel,provider_code)
        # where higher lines have priority over lower ones.
        masks_im=Image.new("L",(4096,4096),'black')
        masks_draw=ImageDraw.Draw(masks_im)
        airport_array=numpy.zeros((4096,4096),dtype=numpy.bool)
        if tile.cover_airports_with_highres:
            UI.vprint(1,"-> Checking airport locations for upgraded zoomlevel.")
            airport_layer=OSM.OSM_layer()
            queries=[('rel["aeroway"="runway"]','rel["aeroway"="taxiway"]','rel["aeroway"="apron"]',
              'way["aeroway"="runway"]','way["aeroway"="taxiway"]','way["aeroway"="apron"]')]
            tags_of_interest=["all"]
            if not OSM.OSM_queries_to_OSM_layer(queries,airport_layer,tile.lat,tile.lon,tags_of_interest,cached_suffix='airports'): 
                return 0
            runway_network=OSM.OSM_to_MultiLineString(airport_layer,tile.lat,tile.lon)
            runway_area=VECT.improved_buffer(runway_network,0.0003,0.0001,0.00001)
            runway_area=VECT.ensure_MultiPolygon(runway_area)
            for polygon in runway_area.geoms:
                (xmin,ymin,xmax,ymax)=polygon.bounds
                # extension
                xmin-=1000*tile.cover_extent*GEO.m_to_lon(tile.lat)
                xmax+=1000*tile.cover_extent*GEO.m_to_lon(tile.lat)
                ymax+=1000*tile.cover_extent*GEO.m_to_lat
                ymin-=1000*tile.cover_extent*GEO.m_to_lat
                # round off to texture boundaries at tile.cover_zl zoomlevel
                (til_x_left,til_y_top)=GEO.wgs84_to_orthogrid(ymax+tile.lat,xmin+tile.lon,tile.cover_zl)
                (ymax,xmin)=GEO.gtile_to_wgs84(til_x_left,til_y_top,tile.cover_zl)
                ymax-=tile.lat; xmin-=tile.lon
                (til_x_left,til_y_top)=GEO.wgs84_to_orthogrid(ymin+tile.lat,xmax+tile.lon,tile.cover_zl)
                (ymin,xmax)=GEO.gtile_to_wgs84(til_x_left+16,til_y_top+16,tile.cover_zl)
                ymin-=tile.lat; xmax-=tile.lon
                # mark to airport_array
                colmin=round(xmin*4095)
                colmax=round(xmax*4095)
                rowmax=round((1-ymin)*4095)
                rowmin=round((1-ymax)*4095)
                airport_array[rowmin:rowmax+1,colmin:colmax+1]=1 
            del(airport_layer)
            del(runway_network) 
            del(runway_area)
        dico_tmp={}
        dico_customzl={}
        i=1
        base_zone=((tile.lat,tile.lon,tile.lat,tile.lon+1,tile.lat+1,tile.lon+1,tile.lat+1,tile.lon,tile.lat,tile.lon),tile.default_zl,tile.default_website)
        for region in [base_zone]+tile.zone_list[::-1]:
            dico_tmp[i]=(region[1],region[2])
            pol=[(round((x-tile.lon)*4095),round((tile.lat+1-y)*4095)) for (x,y) in zip(region[0][1::2],region[0][::2])]
            masks_draw.polygon(pol,fill=i)
            i+=1
        til_x_min,til_y_min=GEO.wgs84_to_orthogrid(tile.lat+1,tile.lon,tile.mesh_zl)
        til_x_max,til_y_max=GEO.wgs84_to_orthogrid(tile.lat,tile.lon+1,tile.mesh_zl)
        for til_x in range(til_x_min,til_x_max+1,16):
            for til_y in range(til_y_min,til_y_max+1,16):
                (latp,lonp)=GEO.gtile_to_wgs84(til_x+8,til_y+8,tile.mesh_zl)
                lonp=max(min(lonp,tile.lon+1),tile.lon) 
                latp=max(min(latp,tile.lat+1),tile.lat) 
                x=round((lonp-tile.lon)*4095)
                y=round((tile.lat+1-latp)*4095)
                (zoomlevel,provider_code)=dico_tmp[masks_im.getpixel((x,y))]
                if airport_array[y,x]: 
                    zoomlevel=max(zoomlevel,tile.cover_zl)
                til_x_text=16*(int(til_x/2**(tile.mesh_zl-zoomlevel))//16)
                til_y_text=16*(int(til_y/2**(tile.mesh_zl-zoomlevel))//16)
                dico_customzl[(til_x,til_y)]=(til_x_text,til_y_text,zoomlevel,provider_code)
        return dico_customzl
Exemplo n.º 8
0
def build_curv_tol_weight_map(tile, weight_array):
    if tile.apt_curv_tol != tile.curvature_tol:
        UI.vprint(
            1,
            "-> Modifying curv_tol weight map according to runway locations.")
        airport_layer = OSM.OSM_layer()
        queries = [('rel["aeroway"="runway"]', 'rel["aeroway"="taxiway"]',
                    'rel["aeroway"="apron"]', 'way["aeroway"="runway"]',
                    'way["aeroway"="taxiway"]', 'way["aeroway"="apron"]')]
        tags_of_interest = ["all"]
        if not OSM.OSM_queries_to_OSM_layer(queries,
                                            airport_layer,
                                            tile.lat,
                                            tile.lon,
                                            tags_of_interest,
                                            cached_suffix='airports'):
            return 0
        runway_network = OSM.OSM_to_MultiLineString(airport_layer, tile.lat,
                                                    tile.lon)
        runway_area = VECT.improved_buffer(runway_network, 0.0003, 0.0001,
                                           0.00001)
        if not runway_area: return 0
        runway_area = VECT.ensure_MultiPolygon(runway_area)
        for polygon in runway_area.geoms if (
                'Multi' in runway_area.geom_type
                or 'Collection' in runway_area.geom_type) else [runway_area]:
            (xmin, ymin, xmax, ymax) = polygon.bounds
            x_shift = 1000 * tile.apt_curv_ext * GEO.m_to_lon(tile.lat)
            y_shift = 1000 * tile.apt_curv_ext * GEO.m_to_lat
            colmin = round((xmin - x_shift) * 1000)
            colmax = round((xmax + x_shift) * 1000)
            rowmax = round(((1 - ymin) + y_shift) * 1000)
            rowmin = round(((1 - ymax) - y_shift) * 1000)
            weight_array[
                rowmin:rowmax + 1, colmin:colmax +
                1] = tile.curvature_tol / tile.apt_curv_tol if tile.apt_curv_tol > 0 else 1
        del (airport_layer)
        del (runway_network)
        del (runway_area)
    if tile.coast_curv_tol != tile.curvature_tol:
        UI.vprint(
            1,
            "-> Modifying curv_tol weight map according to coastline location."
        )
        sea_layer = OSM.OSM_layer()
        queries = ['way["natural"="coastline"]']
        tags_of_interest = []
        if not OSM.OSM_queries_to_OSM_layer(queries,
                                            sea_layer,
                                            tile.lat,
                                            tile.lon,
                                            tags_of_interest,
                                            cached_suffix='coastline'):
            return 0
        for nodeid in sea_layer.dicosmn:
            (lonp, latp) = [float(x) for x in sea_layer.dicosmn[nodeid]]
            x_shift = 1000 * tile.coast_curv_ext * GEO.m_to_lon(tile.lat)
            y_shift = tile.coast_curv_ext / (111.12)
            colmin = round((lonp - tile.lon - x_shift) * 1000)
            colmax = round((lonp - tile.lon + x_shift) * 1000)
            rowmax = round((tile.lat + 1 - latp + y_shift) * 1000)
            rowmin = round((tile.lat + 1 - latp - y_shift) * 1000)
            weight_array[
                rowmin:rowmax + 1, colmin:colmax +
                1] = tile.curvature_tol / tile.coast_curv_tol if tile.coast_curv_tol > 0 else 1
        del (sea_layer)
    # It could be of interest to write the weight file as a png for user editing
    #Image.fromarray((weight_array!=1).astype(numpy.uint8)*255).save('weight.png')
    return