Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
whirlyviz://display?
whirlyviz://display?name=Chicago Zip Codes&basemap=http://a.tiles.mapbox.com/v3/examples.map-zq0f1vuc.json&vecwidth=4.0&veccolor=8B0000AA&vecfilled=no&geojson=https://raw.github.com/smartchicago/chicago-atlas/master/db/import/zipcodes.geojson&vecfilled=yes&veccolor=8B000066&geojson=https://raw.github.com/smartchicago/chicago-atlas/master/db/import/zipcodes.geojson&clearcolor=82CAFAFF
"queries": [
{
"name": "main_query",
"display name": "Stats By Country",
"styles": ["outline_style","loft_style"],
"query": "http://mousebird.cartodb.com/api/v2/sql?format=GeoJSON&q=SELECT ne_110m_admin_0_map_units.the_geom,(0.1*(une_measurements.measurement-({{data_set_min}}))/({{data_set_max}}-({{data_set_min}}))+0.01) as height, une_measurements.measurement as measurement,((une_measurements.measurement-({{data_set_min}}))/({{data_set_max}}-({{data_set_min}}))) as color_ramp, ne_110m_admin_0_map_units.name FROM ne_110m_admin_0_map_units inner join une_nations on ne_110m_admin_0_map_units.adm0_a3 = une_nations.iso3 inner join une_measurements on une_nations.id = une_measurements.nation_id WHERE ST_Intersects(ne_110m_admin_0_map_units.the_geom,ST_SetSRID(ST_Point({{taplon}},{{taplat}}),4326)) AND une_measurements.data_set_id = {{data_set}}"
},
<Style name="landuselow" filter-mode="first" >
<Rule>
<MaxScaleDenominator>3000000</MaxScaleDenominator>
<MinScaleDenominator>750000</MinScaleDenominator>
<Filter>([AREA] &gt; 1000000000) and ([TYPE] = 'water')</Filter>
<PolygonSymbolizer fill="#c4dff6" />
</Rule>
</Style>
<Layer name="landuselow"
srs="+proj=longlat +ellps=WGS84 +no_defs">
// This knows how read and set up vector tiles
MaplyVectorTiles *vecTiles =
[[MaplyVectorTiles alloc] initWithDatabase:filePath viewC:baseViewC];
// This knows how to page data in
MaplyQuadPagingLayer *layer =
[[MaplyQuadPagingLayer alloc]
initWithCoordSystem:[[MaplySphericalMercator alloc] initWebStandard]
delegate:vecTiles];
whirlyviz://script?js=http://foo.bar.com/myscript.js
@mousebird
mousebird / gist:10012359
Created April 6, 2014 23:07
GeoTrellis WhirlyViz Example
// Polluting the global name space with spherical mercator extents
var xMin = -20037508.34;
var yMin = -20037508.34;
var xMax = 20037508.34;
var yMax = 20037508.34;
var xSpan = xMax - xMin;
var ySpan = yMax - yMin;
// Current center of the queries
var centerLon = -75.20896911621094;
NSString *tileCacheDir = [NSString stringWithFormat:@"%@/%@",self.home.appCacheDir,cacheName];
[MaplyVectorTiles StartRemoteVectorTiles:tileURL cacheDir:tileCacheDir viewC:self.home.baseViewC block:
^(MaplyVectorTiles *vecTiles)
{
if (vecTiles)
{
MaplyQuadPagingLayer *layer = [[MaplyQuadPagingLayer alloc]
initWithCoordSystem:[[MaplySphericalMercator alloc] initWebStandard]
delegate:vecTiles];
layer.numSimultaneousFetches = 8;
// Test a ground overlay-like thing
{
UIImage *imgImage = [[UIImage alloc]
initWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString:@"http://radar.weather.gov/ridge/RadarImg/N0Z/MUX_N0Z_0.gif"]]];
MaplySticker *mstick = [[MaplySticker alloc] init];
mstick.image = imgImage;
mstick.ll = MaplyCoordinateMakeWithDegrees(-126.253365, 33.147724);
mstick.ur = MaplyCoordinateMakeWithDegrees(-117.526093, 41.147724);
[theViewC addStickers:@[mstick] desc:nil];
NSData *styleData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MapzenGLStyle" ofType:@"json"]];
thisCacheDir = [NSString stringWithFormat:@"%@/mapzen-vectiles",cacheDir];
MapzenSource *mzSource = [[MapzenSource alloc]
initWithBase:@"http://vector.mapzen.com/osm"
layers:@[@"all"]
// Note: Go get your own API key
apiKey:@"vector-tiles-05s8a-0"
sourceType:MapzenSourcePBF
styleData:styleData