Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicholas Furness nixta

View GitHub Profile
@nixta
nixta / AGSTileInfo+CalculateTiles.swift
Last active Aug 31, 2021
Extension to calculate tile image extents overlapped by a given geometry
View AGSTileInfo+CalculateTiles.swift
extension AGSTileInfo {
func calculateTiles(for geometry: AGSGeometry) -> [AGSTileKey: AGSEnvelope]? {
return calculateTiles(for: geometry.extent)?.filter({ item in
let env = item.value
return AGSGeometryEngine.geometry(geometry, intersects: env)
})
}
// Get the tile extents for the greatest level of detail. This is good for downloading tiles for
// elevation queries, but might not be the desired tile count for a range of LODs.
@nixta
nixta / Bundle+ArcGISRuntimeSDKVersion.swift
Created Sep 2, 2020
Read and output ArcGIS Runtime SDK version text.
View Bundle+ArcGISRuntimeSDKVersion.swift
extension Bundle {
private static let agsBundle = AGSBundle()
/// An end-user printable string representation of the ArcGIS Bundle version shipped with the app.
///
/// For example, "2883"
static var sdkBundleVersion: String {
return (agsBundle?.object(forInfoDictionaryKey: "CFBundleVersion") as? String) ?? "?"
@nixta
nixta / 1-query.swift
Last active Nov 22, 2019
Custom Query
View 1-query.swift
public enum QueryError: LocalizedError {
case couldNotParseJSON
case unexpectedJSONResponse
}
func doQuery(layerURL: URL, mapPoint: AGSPoint, fields: [String] = ["*"], returnGeometry: Bool = true, completion: (([AGSGraphic]?, Error?) -> Void)? = nil) {
var mapPointData: Data?
do {
let mapPointJSON = try mapPoint.toJSON()
mapPointData = try JSONSerialization.data(withJSONObject: mapPointJSON)
@nixta
nixta / ISSLocationDataSource.swift
Created May 1, 2019
A custom AGSLocationDataSource to integrate the International Space Station's realtime location into the ArcGIS Runtime
View ISSLocationDataSource.swift
import Foundation
import ArcGIS
//MARK: - Custom AGSLocationDataSource
/// A custom AGSLocationDataSource that uses the public ISS Location API to return
/// realtime ISS locations at 5 second intervals.
class ISSLocationDataSource: AGSLocationDataSource {
@nixta
nixta / ViewController.swift
Last active Nov 10, 2017
How to drag a graphic with ArcGIS Runtime SDK for iOS
View ViewController.swift
//
// ViewController.swift
// TestDrag
//
// Created by Nicholas Furness on 11/10/17.
// Copyright © 2017 Esri. All rights reserved.
//
import ArcGIS
@nixta
nixta / animatedotwithwebscene.js
Created May 14, 2017
Animate a dot in a graphics layer having loaded a web scene.
View animatedotwithwebscene.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Load a basic web scene - 4.3</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
<script src="https://js.arcgis.com/4.3/"></script>
@nixta
nixta / geofencing.js
Last active May 14, 2017
A PubNub Geofencing Block (See structure of sample services below at lines 16&17).
View geofencing.js
export default (request) => {
let query = require('codec/query_string');
// return if the block does not have anything to analyze
if (!query) {
return request.ok();
}
// Require console to print debug information
let console = require('console');
@nixta
nixta / AGSGraphicsOverlay+Name.swift
Created May 5, 2017
Name an AGSGraphicsOverlay
View AGSGraphicsOverlay+Name.swift
extension AGSGraphicsOverlay {
fileprivate struct AssociatedKeys {
static var referenceNameKey = "geodev_referenceName"
}
var referenceName:String? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.referenceNameKey) as? String
}
set {
@nixta
nixta / ViewController.m
Created Sep 6, 2016
Simulating GPS with the ArcGIS Runtime SDK for iOS
View ViewController.m
#import "ViewController.h"
#import <ArcGIS/ArcGIS.h>
#define kSimulatedMetersPerSecond 2
@interface ViewController () <AGSRouteTaskDelegate>
@property (nonatomic, strong) AGSRouteTaskParameters *defaultParams;
@property (nonatomic, strong) AGSRouteTask *routeTask;
@property (weak, nonatomic) IBOutlet AGSMapView *mapView;
View AGSLocator+suggestSwizzle.swift
//
// AGSLocator+suggestionSwizzle.swift
// SuggestTest
//
// Created by Nicholas Furness on 8/17/16.
// Copyright © 2016 Esri. All rights reserved.
//
import ArcGIS