This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) { | |
self.mapView.identifyLayers(atScreenPoint: screenPoint, tolerance: 10, returnPopupsOnly: false) { (results, error) in | |
guard let results = results else { return } | |
if self.lastQuery != nil { | |
self.lastQuery.cancel() | |
} | |
let tolerance = 10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getFeatureLayer(from url: String) -> AGSFeatureLayer? { | |
guard let url = NSURL(string: url) as? URL else { return nil } | |
let featureTable = AGSServiceFeatureTable(url: url) | |
let featureLayer = AGSFeatureLayer(featureTable: featureTable) | |
featureLayer.selectionColor = UIColor.black | |
featureLayer.selectionWidth = 5 | |
return featureLayer | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getFeatureLayer(from table: AGSGeodatabaseFeatureTable) -> AGSFeatureLayer? { | |
if table.featureLayer == nil { | |
let layer = AGSFeatureLayer(featureTable: table) | |
layer.selectionWidth = 5 | |
layer.selectionColor = UIColor.black | |
return layer | |
} else { | |
return table.featureLayer | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func generateSyncTask(completion: @escaping (AGSGeodatabaseSyncTask?) -> Void) { | |
var featureServerURL = URL(string: "https://arcgis.dtespes.co.uk")! | |
let featureServerPathComponents = ["arcgis", "rest", "services", "Mubaloo", "PES_v1", "FeatureServer"] | |
for component in featureServerPathComponents { | |
featureServerURL.appendPathComponent(component) | |
} | |
let syncTask = AGSGeodatabaseSyncTask(url: featureServerURL as URL) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func generateDatabase(with extent: AGSEnvelope, syncTask: AGSGeodatabaseSyncTask, userDataController: UserDataController, fileName: String, completion: @escaping (Bool) -> Void) { | |
let parameters = AGSGenerateGeodatabaseParameters() | |
let layersToSync = [0, 1, 2, 3] | |
for id in layersToSync { | |
parameters.layerOptions.append(AGSGenerateLayerOption(layerID: id)) | |
} | |
parameters.extent = extent | |
parameters.returnAttachments = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geodatabase: AGSGeodatabase { | |
let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] | |
let fullPath = "\(path)/\(GeodatabaseFileName.database.rawValue).geodatabase" | |
return AGSGeodatabase(fileURL: NSURL(string: fullPath) as! URL) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sync(geodatabase: AGSGeodatabase, syncDirection: AGSSyncDirection, completion: @escaping (Bool) -> Void = { _ in }) { | |
var syncLayerOptions = [AGSSyncLayerOption]() | |
generateSyncTask() { (syncTask) in | |
guard let syncTask = syncTask else { | |
completion(false) | |
return | |
} | |
for layerInfo in syncTask.featureServiceInfo!.layerInfos { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func submit(_ object: ArcGISDictionaryRepresentational) { | |
guard let featureAttributes = object.dictionaryRepresentation, | |
let x = object.geomerty?.x, | |
let y = object.geomerty?.y else { | |
return | |
} | |
let featureTable = AGSServiceFeatureTable(url: NSURL(string: object.layerName.rawValue)! as URL) | |
let mapPoint = AGSPoint(x: x, y: y, spatialReference: AGSSpatialReference(wkid: SpatialReference.nationalGrid.rawValue /*27700*/)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate func submitToGeodatabase(_ object: ArcGISDictionaryRepresentational, toLayer layer: FeatureTableName) { | |
geodatabase.load { (error) in | |
guard let featureTable = self.geodatabase.geodatabaseFeatureTable(withName: layer.rawValue), | |
let x = object.geomerty?.x, | |
let y = object.geomerty?.y else { return } | |
guard let featureAttributes = object.dictionaryRepresentation else { | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getFeature(from parameter: QueryParameter, by attribute: String, in layer: FeatureTableName, completion: @escaping ([AGSFeature]?) -> Void) { | |
let query = AGSQueryParameters() | |
let queryWhere = "\(parameter.rawValue) LIKE '" | |
query.whereClause = "\(queryWhere)\(attribute)'" | |
geodatabase.load { (error) in | |
guard let table = self.geodatabase.geodatabaseFeatureTable(withName: layer.rawValue) else { | |
fatalError("ArcGISController.getFeature - table does not exist in geodatabase") |
OlderNewer