Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1164 from Esri/v.next
Browse files Browse the repository at this point in the history
Release 100.14.0
  • Loading branch information
yo1995 authored Apr 27, 2022
2 parents df1f7b4 + fd304b6 commit 8e26956
Show file tree
Hide file tree
Showing 59 changed files with 861 additions and 525 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ The ```main``` branch of this repository contains samples configured for the lat

## Requirements

* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/ios/) 100.13.0 (or newer)
* [ArcGIS Runtime Toolkit for iOS](https://github.com/Esri/arcgis-runtime-toolkit-ios) 100.13.0 (or newer)
* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/ios/) 100.14.0 (or newer)
* [ArcGIS Runtime Toolkit for iOS](https://github.com/Esri/arcgis-runtime-toolkit-ios) 100.14.0 (or newer)
* Xcode 13.0 (or newer)

The *ArcGIS Runtime SDK Samples app* has a *Target SDK* version of *13.0*, meaning that it can run on devices with *iOS 13.0* or newer.
Expand Down
64 changes: 21 additions & 43 deletions arcgis-ios-sdk-samples.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class LineOfSightGeoElementViewController: UIViewController {
observerPoint = AGSPoint(x: -73.984988, y: 40.748131, z: observerZ, spatialReference: .wgs84())

// Initialize the scene with an imagery basemap style.
scene = AGSScene(basemapStyle: .arcGISImageryLabels)
scene = AGSScene(basemapStyle: .arcGISImagery)

/// The url of the Terrain 3D ArcGIS REST Service.
let worldElevationServiceURL = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CollectDataAR: UIViewController {

private func configureSceneForAR() {
// Create scene with imagery basemap
let scene = AGSScene(basemapType: .imageryWithLabels)
let scene = AGSScene(basemapStyle: .arcGISImagery)

// Create an elevation source and add it to the scene
let elevationSource = AGSArcGISTiledElevationSource(url:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ExploreScenesInFlyoverAR: UIViewController {

private func configureSceneForAR() {
// Create scene with imagery basemap
let scene = AGSScene(basemapType: .imagery)
let scene = AGSScene(basemapStyle: .arcGISImagery)

// Create an integrated mesh layer
let meshLayer = AGSIntegratedMeshLayer(url: URL(string: "https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/Girona_Spain/SceneServer")!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class NavigateARNavigatorViewController: UIViewController {
///
/// - Returns: A new `AGSScene` object.
func makeScene() -> AGSScene {
let scene = AGSScene(basemapType: .imagery)
let scene = AGSScene(basemapStyle: .arcGISImagery)
elevationSurface.navigationConstraint = .none
elevationSurface.opacity = 0
elevationSurface.elevationSources = [elevationSource]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ViewHiddenInfrastructureARExplorerViewController: UIViewController {
///
/// - Returns: A new `AGSScene` object.
func makeScene() -> AGSScene {
let scene = AGSScene(basemapType: .imagery)
let scene = AGSScene(basemapStyle: .arcGISImagery)
elevationSurface.navigationConstraint = .none
elevationSurface.opacity = 0
elevationSurface.elevationSources = [elevationSource]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,6 @@ extension ViewHiddenInfrastructureARPipePlacingViewController: AGSLocationChange
setStatus(message: "Tap add button to add pipes.")
sketchBarButtonItem.isEnabled = true
locationDataSource.locationChangeHandlerDelegate = nil
locationDataSource.stop()
locationDataSource.stop(completion: nil)
}
}
12 changes: 11 additions & 1 deletion arcgis-ios-sdk-samples/Content Display Logic/ContentPList.plist
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<key>displayName</key>
<string>Show device location using indoor positioning</string>
<key>descriptionText</key>
<string>Show your device's real-time location while inside a building by using signals from indoor positioning beacons.</string>
<string>Show your device&apos;s real-time location while inside a building by using signals from indoor positioning beacons.</string>
<key>storyboardName</key>
<string>ShowDeviceLocationUsingIndoorPositioning</string>
</dict>
Expand Down Expand Up @@ -784,6 +784,14 @@
<string>EdinburghPylonsDimensionsMMPK</string>
</array>
</dict>
<dict>
<key>storyboardName</key>
<string>QueryRelatedFeaturesNonSpatialTable</string>
<key>descriptionText</key>
<string>Find features in a spatial table related to features in a non-spatial table.</string>
<key>displayName</key>
<string>Query related features from non-spatial table</string>
</dict>
</array>
</dict>
<dict>
Expand Down Expand Up @@ -911,6 +919,8 @@
<key>dependency</key>
<array>
<string>scottishWildlifeTrust</string>
<string>AuroraCOGeopackage</string>
<string>LATrailsGeodatabase</string>
</array>
<key>displayName</key>
<string>Display feature layers</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,81 +16,92 @@ import UIKit
import ArcGIS

class AddFeaturesViewController: UIViewController, AGSGeoViewTouchDelegate {
@IBOutlet private var mapView: AGSMapView!
@IBOutlet var mapView: AGSMapView! {
didSet {
mapView.map = AGSMap(basemapStyle: .arcGISStreets)
// Set touch delegate on map view as self.
mapView.touchDelegate = self
}
}

private var featureTable: AGSServiceFeatureTable!
private var lastQuery: AGSCancelable!
/// The service geodatabase that contains damaged property features.
var serviceGeodatabase: AGSServiceGeodatabase!
/// The feature table to add features to.
var featureTable: AGSServiceFeatureTable!

override func viewDidLoad() {
super.viewDidLoad()
// Add the source code button item to the right of navigation bar.
(navigationItem.rightBarButtonItem as? SourceCodeBarButtonItem)?.filenames = ["AddFeaturesViewController"]

// add the source code button item to the right of navigation bar
(self.navigationItem.rightBarButtonItem as! SourceCodeBarButtonItem).filenames = ["AddFeaturesViewController"]

// assign the map to the map view
let map = AGSMap(basemapStyle: .arcGISStreets)
self.mapView.map = map
self.mapView.setViewpoint(AGSViewpoint(center: AGSPoint(x: 544871.19, y: 6806138.66, spatialReference: .webMercator()), scale: 2e6))
// set touch delegate on map view as self
self.mapView.touchDelegate = self

// instantiate service feature table using the url to the service
self.featureTable = AGSServiceFeatureTable(url: URL(string: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0")!)
// create a feature layer using the service feature table
let featureLayer = AGSFeatureLayer(featureTable: self.featureTable)

// add the feature layer to the operational layers on map
map.operationalLayers.add(featureLayer)
// Load the service geodatabase.
let damageFeatureService = URL(string: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer")!
loadServiceGeodatabase(from: damageFeatureService)
}

/// Load and set a service geodatabase from a feature service URL.
/// - Parameter serviceURL: The URL to the feature service.
func loadServiceGeodatabase(from serviceURL: URL) {
let serviceGeodatabase = AGSServiceGeodatabase(url: serviceURL)
serviceGeodatabase.load { [weak self] error in
guard let self = self else { return }
if let error = error {
self.presentAlert(error: error)
} else {
let featureTable = serviceGeodatabase.table(withLayerID: 0)!
self.featureTable = featureTable
self.serviceGeodatabase = serviceGeodatabase
// Add the feature layer to the operational layers on map.
let featureLayer = AGSFeatureLayer(featureTable: featureTable)
self.mapView.map?.operationalLayers.add(featureLayer)
self.mapView.setViewpoint(AGSViewpoint(center: AGSPoint(x: 544871.19, y: 6806138.66, spatialReference: .webMercator()), scale: 2e6))
}
}
}

func addFeature(at mappoint: AGSPoint) {
// disable interaction with map view
/// Add a feature at the tapped point.
/// - Parameter mapPoint: The point where user tapped.
func addFeature(at mapPoint: AGSPoint) {
// Disable interaction with map view.
mapView.isUserInteractionEnabled = false

// normalize geometry
let normalizedGeometry = AGSGeometryEngine.normalizeCentralMeridian(of: mappoint)!
// Normalize geometry.
let normalizedGeometry = AGSGeometryEngine.normalizeCentralMeridian(of: mapPoint)!

// attributes for the new feature
// Attributes for the new feature.
let featureAttributes = ["typdamage": "Minor", "primcause": "Earthquake"]
// create a new feature
// Create a new feature.
let feature = featureTable.createFeature(attributes: featureAttributes, geometry: normalizedGeometry)

// show the progress hud
UIApplication.shared.showProgressHUD(message: "Adding..")

// add the feature to the feature table
// Add the feature to the feature table.
featureTable.add(feature) { [weak self] (error: Error?) in
UIApplication.shared.hideProgressHUD()
guard let self = self else { return }
// Enable interaction with map view.
self.mapView.isUserInteractionEnabled = true

if let error = error {
self?.presentAlert(message: "Error while adding feature: \(error.localizedDescription)")
self.presentAlert(message: "Error while adding feature: \(error.localizedDescription)")
} else {
// applied edits on success
self?.applyEdits()
// Applied edits on success.
self.applyEdits()
}
// enable interaction with map view
self?.mapView.isUserInteractionEnabled = true
}
}

/// Apply local edits to the geodatabase.
func applyEdits() {
self.featureTable.applyEdits { [weak self] (featureEditResults: [AGSFeatureEditResult]?, error: Error?) in
guard serviceGeodatabase.hasLocalEdits() else { return }
serviceGeodatabase.applyEdits { [weak self] _, error in
if let error = error {
self?.presentAlert(message: "Error while applying edits :: \(error.localizedDescription)")
} else {
if let featureEditResults = featureEditResults,
featureEditResults.first?.completedWithErrors == false {
self?.presentAlert(message: "Edits applied successfully")
}
UIApplication.shared.hideProgressHUD()
self?.presentAlert(message: "Error while applying edits: \(error.localizedDescription)")
}
}
}

// MARK: - AGSGeoViewTouchDelegate

func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
// add a feature at the tapped location
self.addFeature(at: mapPoint)
// Add a feature at the tapped location.
addFeature(at: mapPoint)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ Tap on a location on the map to add a feature at that location.

## How it works

An `AGSFeature` instance is added to an `AGSServiceFeatureTable` which then pushes that new feature to the server.
An `AGSFeature` instance is added to an `AGSServiceFeatureTable`. Apply edits on the `ServiceGeodatabase` which contains the feature table to push the edits to the server.

1. Create an `AGSServiceFeatureTable` from a URL.
2. Create an `AGSFeatureLayer` derived from the `AGSServiceFeatureTable` instance.
3. Create an `AGSFeature` with attributes and a location using the `AGSServiceFeatureTable`.
4. Add the `AGSFeature` to the `AGSServiceFeatureTable`.
5. Use `AGSServiceFeatureTable.applyEdits(completion:)` to apply edits to the `AGSServiceFeatureTable`, which will upload the new feature to the online service.
1. Create and load an `AGSServiceFeatureTable` with a feature service URL.
2. Get the `AGSServiceFeatureTable` from the service geodatabase.
3. Create an `AGSFeatureLayer` from the service feature table.
4. Create an `AGSFeature` with attributes and a location using the `AGSServiceFeatureTable`.
5. Add the `AGSFeature` to the `AGSServiceFeatureTable`.
6. Apply edits to the `AGSServiceGeodatabase` by calling `AGSServiceFeatureTable.applyEdits(completion:)`, which will upload the new feature to the online service.

## Relevant API

* AGSFeature
* AGSFeatureEditResult
* AGSFeatureLayer
* AGSServiceFeatureTable
* AGSServiceGeodatabase

## Tags

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"AGSFeature",
"AGSFeatureEditResult",
"AGSFeatureLayer",
"AGSServiceFeatureTable"
"AGSServiceFeatureTable",
"AGSServiceGeodatabase"
],
"redirect_from": [
"/ios/latest/swift/sample-code/add-features-feature-service-.htm"
Expand All @@ -21,7 +22,8 @@
"AGSFeature",
"AGSFeatureEditResult",
"AGSFeatureLayer",
"AGSServiceFeatureTable"
"AGSServiceFeatureTable",
"AGSServiceGeodatabase"
],
"snippets": [
"AddFeaturesViewController.swift"
Expand Down
Loading

0 comments on commit 8e26956

Please sign in to comment.