Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
whirlyviz://script?js=http://foo.bar.com/myscript.js
// 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];
<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">
"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}}"
},
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
whirlyviz://display?
@mousebird
mousebird / gist:6816008
Created October 3, 2013 19:49
MicroStyles Example
"styles" :
[
{
"name": "fire station",
"type": "marker",
"color": "#FFFFFFFF",
"sizeX": 20.0,
"sizeY": 20.0,
"fade": 0.5,
"icon": "fire_station.png"
/** The Elevation Source Delegate provides elevation data on demand for
a given tile. It returns a MaplyElevationChunk or nil if no data
is available. Your delegate may be called on a random thread, act accordingly.
*/
@protocol MaplyElevationSourceDelegate
/// Coordinate system we're providing the data in (and extents)
- (MaplyCoordinateSystem *)getCoordSystem;
/// Minimum zoom level (e.g. 0)
// For elevation mode, we need to do some other stuff
if (startupMapType == MaplyGlobeWithElevation)
{
// Tilt, so we can see it
if (globeViewC)
[globeViewC setTiltMinHeight:0.001 maxHeight:0.04 minTilt:1.21771169 maxTilt:0.0];
globeViewC.frameInterval = 2; // 30fps
// An elevation source. This one just makes up sine waves to get some data in there
elevSource = [[MaplyElevationDatabase alloc] initWithName:@"world_web_mercator"];
// Set up the vertex array (note this can only be done on the main thread)
- (void)makeVertexArray
{
// Create a vertex array object and set up its internal state
glGenVertexArraysOES(1, &_vertexArray);
glBindVertexArrayOES(_vertexArray);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
// Normally you'd have to do this each time