Skip to content

Instantly share code, notes, and snippets.

@mousebird
Last active July 22, 2016 18:12
Show Gist options
  • Save mousebird/3737cfb213ca84d51b82d02da1920513 to your computer and use it in GitHub Desktop.
Save mousebird/3737cfb213ca84d51b82d02da1920513 to your computer and use it in GitHub Desktop.
// A test case that displays an animated weather layer on top of
// the standard Geography Class basemap.
// This is part of the AutoTester in the WhirlyGlobe-Maply repo.
class AnimatedBasemapTestCase: MaplyTestCase {
// Use Geography Class as the base layer
let geographyClass = GeographyClassTestCase()
let cacheDir = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)[0]
var tileSources = [MaplyRemoteTileInfo]()
override init() {
super.init()
self.name = "Animated basemap"
self.captureDelay = 2
self.implementations = [.Globe, .Map]
}
// Collect up the various precipitation sources
func buildTileSources() {
for i in 0...4 {
let precipTileSource = MaplyRemoteTileInfo(
baseURL: "http://a.tiles.mapbox.com/v3/mousebird.precip-example-layer\(i)/",
ext: "png",
minZoom: 0,
maxZoom: 6)
precipTileSource.cacheDir = "\(cacheDir)/forecast_io_weather_layer\(i)/"
tileSources.append(precipTileSource)
}
}
// Create the animation layer
func createLayer(baseView: MaplyBaseViewController) -> (MaplyQuadImageTilesLayer) {
let precipTileSource = MaplyMultiplexTileSource(sources: tileSources)
// Create a precipitation layer that animates
let precipLayer = MaplyQuadImageTilesLayer(tileSource: precipTileSource!)
precipLayer?.imageDepth = UInt32(tileSources.count)
precipLayer?.animationPeriod = 1.0
precipLayer?.imageFormat = MaplyQuadImageFormat.ImageUByteRed
precipLayer?.numSimultaneousFetches = 4
precipLayer?.handleEdges = false
precipLayer?.coverPoles = false
precipLayer?.shaderProgramName = WeatherShader.setupWeatherShader(baseView)
precipLayer?.fade = 0.5
return precipLayer!
}
// Globe test case
override func setUpWithGlobe(globeVC: WhirlyGlobeViewController) {
geographyClass.setUpWithGlobe(globeVC)
buildTileSources()
globeVC.addLayer(createLayer(globeVC))
}
// Map test case
override func setUpWithMap(mapVC: MaplyViewController) {
geographyClass.setUpWithMap(mapVC)
buildTileSources()
mapVC.addLayer(createLayer(mapVC))
}
}
@johndpope
Copy link

Nice. Steve, I'd like to speak with you - do you have a minute?
347 515 8848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment