Exemple #1
0
    def create_cached_source(self):
        map_tile_url = "https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/256/#Z#/#X#/#Y#"
        map_tile_url += "?access_token=pk.eyJ1IjoiZGVsdGFmb3h0cm90IiwiYSI6ImNramg2OXo1ZzRpd2Qyem5"
        map_tile_url += "wOXR5Mm01MWUifQ.5KGdqcPnw-SPU8dfn29a_Q"

        factory = Champlain.MapSourceFactory.dup_default()
        tile_source = Champlain.NetworkTileSource.new_full(
            "mapbox", "mapbox", " (c) mapbox (c) openstreet map contributors",
            "https://www.mapbox.com/tos", 2, 19, 256,
            Champlain.MapProjection.MERCATOR, map_tile_url,
            Champlain.ImageRenderer())

        tile_size = tile_source.get_tile_size()
        error_source = factory.create_error_source(tile_size)
        file_cache = Champlain.FileCache.new_full(CACHE_SIZE, None,
                                                  Champlain.ImageRenderer())

        memory_cache = Champlain.MemoryCache.new_full(
            MEMORY_CACHE_SIZE, Champlain.ImageRenderer())

        source_chain = Champlain.MapSourceChain()
        source_chain.push(error_source)
        source_chain.push(tile_source)
        source_chain.push(file_cache)
        source_chain.push(memory_cache)

        return source_chain
Exemple #2
0
def create_cached_source():
    factory = Champlain.MapSourceFactory.dup_default()

    tile_source = Champlain.NetworkTileSource.new_full(
        "mapbox", "mapbox", LICENSE_TEXT, LICENSE_URI, MIN_ZOOM, MAX_ZOOM,
        TILE_SIZE, Champlain.MapProjection.MERCATOR,
        "https://a.tiles.mapbox.com/v4/mapbox.streets/#Z#/#X#/#Y#.png?access_token="
        + ACCESS_TOKEN, Champlain.ImageRenderer())

    tile_size = tile_source.get_tile_size()

    error_source = factory.create_error_source(tile_size)
    file_cache = Champlain.FileCache.new_full(CACHE_SIZE, None,
                                              Champlain.ImageRenderer())
    memory_cache = Champlain.MemoryCache.new_full(MEMORY_CACHE_SIZE,
                                                  Champlain.ImageRenderer())

    source_chain = Champlain.MapSourceChain()
    # tile is retrieved in this order:
    # memory_cache -> file_cache -> tile_source -> error_source
    # the first source that contains the tile returns it
    source_chain.push(error_source)
    source_chain.push(tile_source)
    source_chain.push(file_cache)
    source_chain.push(memory_cache)

    return source_chain
Exemple #3
0
    [
        'mapquest-osm', 'MapQuest OSM', 0, 17, 256,
        'Map data provided by MapQuest, Open Street Map and contributors',
        'http://creativecommons.org/licenses/by-sa/2.0/',
        'http://otile1.mqcdn.com/tiles/1.0.0/osm/#Z#/#X#/#Y#.png'
    ],
    [
        'mff-relief', 'Maps for Free Relief', 0, 11, 256,
        'Map data available under GNU Free Documentation license, v1.2 or later',
        'http://www.gnu.org/copyleft/fdl.html',
        'http://maps-for-free.com/layer/relief/z#Z#/row#Y#/#Z#_#X#-#Y#.jpg'
    ],
]:
    mapid, name, min_zoom, max_zoom, size, lic, lic_uri, tile_uri = map_desc

    c = Champlain.MapSourceChain()
    c.push(Champlain.MapSourceFactory.dup_default().create_error_source(size))

    c.push(
        Champlain.NetworkTileSource.new_full(
            mapid, name, lic, lic_uri, min_zoom, max_zoom, size,
            Champlain.MapProjection.MAP_PROJECTION_MERCATOR, tile_uri,
            Champlain.ImageRenderer()))

    c.push(Champlain.FileCache.new_full(1e8, None, Champlain.ImageRenderer()))
    c.push(Champlain.MemoryCache.new_full(100, Champlain.ImageRenderer()))
    MAP_SOURCES[mapid] = c


@memoize
class RadioMenuItem(Gtk.RadioMenuItem):