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

Edit features with feature-linked annotation implementation #928

Merged
merged 75 commits into from
Aug 25, 2020
Merged
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1bbc6e3
Added foundation files
vquach2404 Jul 28, 2020
b140492
Added loudoun_anno geodatabase
vquach2404 Jul 28, 2020
3f27b13
Added all functions
vquach2404 Jul 30, 2020
1cc0da1
Updated view controller class
vquach2404 Jul 31, 2020
5f7979c
Fixed edit features alert
vquach2404 Aug 4, 2020
25daa78
Fixed text editing
vquach2404 Aug 4, 2020
c5abfcf
Moved geodatabase reference
vquach2404 Aug 4, 2020
63eddb2
Updated move point process
vquach2404 Aug 4, 2020
f9c430d
Added confirmation to move polyline process
vquach2404 Aug 4, 2020
6595fad
Updated comments
vquach2404 Aug 5, 2020
410084d
Guarded values
vquach2404 Aug 5, 2020
d95a628
Updated readme and metadata
vquach2404 Aug 5, 2020
b622150
Updated image, readme, metadata
vquach2404 Aug 5, 2020
150c59f
Merge branch 'v.next' into Viv/EditFeaturesWFeatureLinkedAnnotation_v…
vquach2404 Aug 5, 2020
ebae001
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 5, 2020
ec28ae4
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 5, 2020
e17badd
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 5, 2020
bd9df50
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 5, 2020
75c22ce
Updated readme
vquach2404 Aug 5, 2020
1477a26
Addressed suggestions
vquach2404 Aug 5, 2020
7d32ff9
Moved guard statement
vquach2404 Aug 5, 2020
844abee
Updated identify layers function
vquach2404 Aug 6, 2020
628651d
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 6, 2020
1bea262
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 6, 2020
db6599e
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 6, 2020
a7f6637
Updated wording in readme
vquach2404 Aug 7, 2020
a6abbbc
Moved mapView touch delegate
vquach2404 Aug 7, 2020
3d90888
Removed extra period
vquach2404 Aug 7, 2020
102f493
Array method changed
vquach2404 Aug 7, 2020
0a98c0c
Removed extra self
vquach2404 Aug 7, 2020
5616824
Added extra space
vquach2404 Aug 7, 2020
ced713b
Used contains(where:)
vquach2404 Aug 7, 2020
ee87d0a
Removed extra self
vquach2404 Aug 7, 2020
50b3f0d
Removed extra self
vquach2404 Aug 7, 2020
047b9b6
Removed extra self
vquach2404 Aug 7, 2020
b769a2c
Moved geodatabase and used compact map function
vquach2404 Aug 7, 2020
687a310
Edited clear selection
vquach2404 Aug 7, 2020
f44e3cb
Fixed moving polyline issue
vquach2404 Aug 10, 2020
7d8adda
Renamed movePolylineVertex
vquach2404 Aug 11, 2020
adca625
Fixed map view top constraint
vquach2404 Aug 11, 2020
28ed1b8
Changed geoview to an extension
vquach2404 Aug 11, 2020
8acbd7e
Removed selectedFeatureIsPolyline
vquach2404 Aug 11, 2020
626b004
Renamed selecteFeature function
vquach2404 Aug 11, 2020
d6df63f
Renamed movePoint
vquach2404 Aug 11, 2020
b1c24f4
Reworded alerts
vquach2404 Aug 11, 2020
525fb35
Strongly captured completion handlers
vquach2404 Aug 11, 2020
9d039ab
Updated function name
vquach2404 Aug 11, 2020
6ec649c
Used configuration handlers for text fields
vquach2404 Aug 11, 2020
18455f7
Updated readme and stored cancellable
vquach2404 Aug 11, 2020
a677b6e
Added text field observers
vquach2404 Aug 11, 2020
c83bfcb
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 12, 2020
e875a4f
Removed extra self
vquach2404 Aug 12, 2020
3bb2e94
Removed extra space
vquach2404 Aug 12, 2020
bab6b69
Changed forEach to for loop
vquach2404 Aug 13, 2020
8ccc75f
Merge branch 'v.next' into Viv/EditFeaturesWFeatureLinkedAnnotation_v…
vquach2404 Aug 13, 2020
c053871
Updated PortalItems
vquach2404 Aug 17, 2020
da20a90
Checked out geodatabase
vquach2404 Aug 17, 2020
869f84d
Updated readme
vquach2404 Aug 18, 2020
57870a4
Changed guard to if else
vquach2404 Aug 18, 2020
3c06c10
Updated text fields
vquach2404 Aug 18, 2020
72ff77b
Renamed identifyLayers
vquach2404 Aug 18, 2020
c76ec79
Updated comments
vquach2404 Aug 18, 2020
638ebd9
Updated geodatabase property
vquach2404 Aug 18, 2020
15405a5
Updated shorthand in load function
vquach2404 Aug 18, 2020
a9ac96f
Moved geodatabase
vquach2404 Aug 19, 2020
1823f30
Fix geodatabase directory issue.
yo1995 Aug 20, 2020
686e98c
Removed extra return
vquach2404 Aug 20, 2020
326e604
Update arcgis-ios-sdk-samples/Edit data/Edit features with feature-li…
vquach2404 Aug 20, 2020
cb74b98
Removed observer in cancel
vquach2404 Aug 20, 2020
7683d24
Renamed selectFeature
vquach2404 Aug 20, 2020
67e3fd2
Moved textFieldObserver
vquach2404 Aug 20, 2020
7aa83d5
Polish readme
vquach2404 Aug 24, 2020
b94fcc6
Added line breaks
vquach2404 Aug 24, 2020
8a9fa2f
Changed spacing
vquach2404 Aug 24, 2020
ae816e6
Updated load geodatabase
vquach2404 Aug 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressed suggestions
  • Loading branch information
vquach2404 committed Aug 5, 2020
commit 1477a26867cb4e07dabf1a1f4f3806927f64a751
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import ArcGIS
class EditFeaturesWithFeatureLinkedAnnotationViewController: UIViewController, AGSGeoViewTouchDelegate {
@IBOutlet weak var mapView: AGSMapView! {
didSet {
// Set the touch delegate.
self.mapView.touchDelegate = self
// Create the map with a light gray canvas basemap centered on Loudoun, Virginia.
let map = AGSMap(basemapType: .lightGrayCanvasVector, latitude: 39.0204, longitude: -77.4159, levelOfDetail: 18)
mapView.map = map
Expand Down Expand Up @@ -82,28 +84,31 @@ class EditFeaturesWithFeatureLinkedAnnotationViewController: UIViewController, A
if let featureLayer = result.layerContent as? AGSFeatureLayer {
// Get a reference to the identified feature
self.selectedFeature = result.geoElements[0] as? AGSFeature
guard let selectedFeature = self.selectedFeature else { return }
// If the selected feature is a polyline with any part containing more than one segment (i.e. a curve).
if let polyline = self.selectedFeature?.geometry as? AGSPolyline {
if let polyline = selectedFeature.geometry as? AGSPolyline {
let polylineArray = polyline.parts.array()
polylineArray.forEach { part in
if part.pointCount > 2 {
// Set selected feature to nil.
self.selectedFeature = nil
// Show a message to select straight (single segment) polylines only.
self.presentAlert(title: "Make a different selection", message: "Select straight (single segment) polylines only.")
return
}
}
return
}
// Ensure the feature is not nil and select it.
guard let selectedFeature = self.selectedFeature else { return }
// Select the feature.
featureLayer.select(selectedFeature)
// If the selected feature is a point, prompt the edit attributes alert.
if selectedFeature.geometry?.geometryType.rawValue == 1 {
switch selectedFeature.geometry?.geometryType {
case .point:
// If the selected feature is a point, prompt the edit attributes alert.
self.showEditableAttributes(selectedFeature: selectedFeature)
} else if selectedFeature.geometry?.geometryType.rawValue == 3 {
case .polyline:
// If the selected feature is a polyline, set the value to true.
self.selectedFeatureIsPolyline = true
default:
return
}
}
}
Expand All @@ -113,7 +118,6 @@ class EditFeaturesWithFeatureLinkedAnnotationViewController: UIViewController, A

// Create an alert dialog with edit texts to allow editing of the given feature's 'AD_ADDRESS' and 'ST_STR_NAM' attributes.
func showEditableAttributes(selectedFeature: AGSFeature) {
guard let selectedFeature = self.selectedFeature else { return }
// Create an alert controller and customize the title and message.
let alert = UIAlertController(title: "Edit feature attributes", message: "Edit the 'AD_ADDRESS' and 'ST_STR_NAM' attributes.", preferredStyle: .alert)
// Add text fields to prompt user input.
Expand All @@ -123,8 +127,8 @@ class EditFeaturesWithFeatureLinkedAnnotationViewController: UIViewController, A
alert.textFields?[0].text = (selectedFeature.attributes["AD_ADDRESS"] as! NSNumber).stringValue
alert.textFields?[1].text = selectedFeature.attributes["ST_STR_NAM"] as? String
// Prompt the appropriate keyboard types.
alert.textFields?[0].keyboardType = .asciiCapableNumberPad
alert.textFields?[1].keyboardType = .asciiCapable
alert.textFields?[0].keyboardType = .numberPad
alert.textFields?[1].keyboardType = .default
// Add a "Cancel" option and clear the selection if cancel is selected.
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { _ in
self.clearSelection()
Expand Down Expand Up @@ -186,12 +190,13 @@ class EditFeaturesWithFeatureLinkedAnnotationViewController: UIViewController, A
// Get the selected feature's geometry as a polyline nearest to the map point.
guard let polyline = selectedFeature.geometry as? AGSPolyline else { return }
// Get the nearest vertex to the map point on the selected feature polyline.
let nearestVertex = AGSGeometryEngine.nearestVertex(in: polyline, to: (AGSGeometryEngine.projectGeometry(mapPoint, to: (polyline.spatialReference)!) as? AGSPoint)!)
guard let nearestVertex = AGSGeometryEngine.nearestVertex(in: polyline, to:
(AGSGeometryEngine.projectGeometry(mapPoint, to: (polyline.spatialReference)!) as? AGSPoint)!) else { return }
let polylineBuilder = AGSPolylineBuilder(polyline: polyline)
// Get the part of the polyline nearest to the map point.
polylineBuilder.parts[nearestVertex!.partIndex].removePoint(at: nearestVertex!.partIndex)
polylineBuilder.parts[nearestVertex.partIndex].removePoint(at: nearestVertex.partIndex)
// Add the map point as the new point on the polyline.
polylineBuilder.parts[nearestVertex!.partIndex].addPoint(AGSGeometryEngine.projectGeometry(mapPoint, to: polylineBuilder.parts[nearestVertex!.partIndex].spatialReference!) as! AGSPoint)
polylineBuilder.parts[nearestVertex.partIndex].addPoint(AGSGeometryEngine.projectGeometry(mapPoint, to: polylineBuilder.parts[nearestVertex.partIndex].spatialReference!) as! AGSPoint)
// Set the selected feature's geometry to the new polyline.
selectedFeature.geometry = polylineBuilder.toGeometry()
// Update the selected feature's feature table.
Expand Down Expand Up @@ -220,8 +225,6 @@ class EditFeaturesWithFeatureLinkedAnnotationViewController: UIViewController, A

override func viewDidLoad() {
super.viewDidLoad()
// Set the touch delegate.
self.mapView.touchDelegate = self
// Add the source code button item to the right of navigation bar.
(self.navigationItem.rightBarButtonItem as! SourceCodeBarButtonItem).filenames = ["EditFeaturesWithFeatureLinkedAnnotationViewController"]
}
Expand Down