Skip to content

Instantly share code, notes, and snippets.

View mousebird's full-sized avatar

Steve Gifford mousebird

View GitHub Profile
func insertClusteredMarkers(compB : NSArray, theBaseView: MaplyBaseViewController) {
let size = CGSizeMake(32, 32)
let image = UIImage (named: "alcohol-shop-24@2x")
var markers = [MaplyScreenMarker]()
for object in compB {
let marker = MaplyScreenMarker()
marker.image = image
marker.loc = (object as! MaplyVectorObject).center()
marker.size = size
marker.userObject = object.userObject
func insertClusteredMarkers(compB : NSArray, theBaseView: MaplyBaseViewController) {
let size = CGSizeMake(32, 32)
let image = UIImage (named: "alcohol-shop-24@2x")
var markers = [MaplyScreenMarker]()
for object in compB {
let marker = MaplyScreenMarker()
marker.image = image
marker.loc = (object as! MaplyVectorObject).center()
marker.size = size
marker.userObject = object.userObject
/** @brief Interpolate a new state between the given states A and B.
@details This does a simple interpolation (lat/lon, not great circle) between the two animation states.
*/
+ (nonnull WhirlyGlobeViewControllerAnimationState *)Interpolate:(double)t from:(WhirlyGlobeViewControllerAnimationState *__nonnull)stateA to:(WhirlyGlobeViewControllerAnimationState *__nonnull)stateB;
@mousebird
mousebird / bngCoordSys.swift
Created March 10, 2016 21:54
Custom British National Grid projection
let proj4Str = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs"
let coordSys = MaplyProj4CoordSystem(string: proj4Str)
var bbox = MaplyBoundingBox()
bbox.ll.x = 1393.0196
bbox.ll.y = 12494.9764
bbox.ur.x = 671196.3657
bbox.ur.y = 1230275.0454
coordSys.setBounds(bbox)
@mousebird
mousebird / MarkerCluster.m
Last active October 4, 2019 21:32
Marker Cluster Example
NSMutableArray *markers = [NSMutableArray array];
UIImage *pinImage = [UIImage imageNamed:@"map_pin"];
// Work through the locations
for (unsigned int ii=0;ii<howMany;ii++)
{
LocationInfo *location = &locations[ii];
MaplyScreenMarker *marker = [[MaplyScreenMarker alloc] init];
marker.image = pinImage;
nasaLayers =
[{
name: "Mapbox Satellite",
url: "http://a.tiles.mapbox.com/v3/examples.map-zyt2v9k2.json",
base: true
},
{ name: "MODIS/Terra TrueColor",
url: "http://map1.vis.earthdata.nasa.gov/wmts-webmerc/MODIS_Terra_CorrectedReflectance_TrueColor/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg",
minzoom: 1,
maxzoom: 9,
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
// 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];
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;
@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;