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

Commit c0d6aad

Browse files
authored
Merge pull request #348 from Esri/v.next
100.2.1 samples
2 parents 52b4e62 + 6a5eb94 commit c0d6aad

File tree

52 files changed

+3261
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3261
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The ```master``` branch of this repository contains samples configured for the l
2020
* Scenes - Display scenes, 3D symbols, and scene layers
2121

2222
## Requirements
23-
* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/en/ios/) 100.2 (or higher).
23+
* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/en/ios/) 100.2.1 (or higher).
2424
* XCode 9 (or higher)
2525
* iOS 11 SDK (or higher)
2626

arcgis-ios-sdk-samples.xcodeproj/project.pbxproj

Lines changed: 151 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="beF-yn-MU6">
3+
<device id="retina5_9" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
9+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11+
</dependencies>
12+
<scenes>
13+
<!--Line Of Sight Location View Controller-->
14+
<scene sceneID="uVV-jY-ewq">
15+
<objects>
16+
<viewController id="beF-yn-MU6" customClass="LineOfSightLocationViewController" customModule="arcgis_ios_sdk_samples" customModuleProvider="target" sceneMemberID="viewController">
17+
<view key="view" contentMode="scaleToFill" id="7gX-cs-H6x">
18+
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
19+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20+
<subviews>
21+
<view contentMode="scaleToFill" placeholderIntrinsicWidth="infinite" placeholderIntrinsicHeight="34" translatesAutoresizingMaskIntoConstraints="NO" id="yMh-oN-h6N" userLabel="Instructions Container">
22+
<rect key="frame" x="0.0" y="44" width="375" height="34"/>
23+
<subviews>
24+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="DOk-3h-gKt">
25+
<rect key="frame" x="0.0" y="8" width="375" height="18"/>
26+
<subviews>
27+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tap on the map to set the observer location" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qgh-ab-wUm">
28+
<rect key="frame" x="0.0" y="0.0" width="375" height="18"/>
29+
<fontDescription key="fontDescription" type="system" pointSize="15"/>
30+
<color key="textColor" red="0.0" green="0.36862745099999999" blue="0.58431372550000005" alpha="1" colorSpace="calibratedRGB"/>
31+
<nil key="highlightedColor"/>
32+
</label>
33+
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Tap-and-hold to drag the line of sight target" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jHc-7B-FsF">
34+
<rect key="frame" x="0.0" y="-52" width="375" height="0.0"/>
35+
<fontDescription key="fontDescription" type="system" pointSize="15"/>
36+
<color key="textColor" red="0.0" green="0.36862745099999999" blue="0.58431372550000005" alpha="1" colorSpace="calibratedRGB"/>
37+
<nil key="highlightedColor"/>
38+
</label>
39+
</subviews>
40+
</stackView>
41+
</subviews>
42+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
43+
<constraints>
44+
<constraint firstAttribute="bottom" secondItem="DOk-3h-gKt" secondAttribute="bottom" constant="8" id="48f-E0-Fb3"/>
45+
<constraint firstItem="DOk-3h-gKt" firstAttribute="top" secondItem="yMh-oN-h6N" secondAttribute="top" constant="8" id="ZTX-Hc-u47"/>
46+
</constraints>
47+
</view>
48+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YLS-ms-81h" customClass="AGSSceneView">
49+
<rect key="frame" x="0.0" y="78" width="375" height="734"/>
50+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
51+
</view>
52+
</subviews>
53+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
54+
<constraints>
55+
<constraint firstAttribute="trailing" secondItem="YLS-ms-81h" secondAttribute="trailing" id="4JD-Hc-i8w"/>
56+
<constraint firstItem="YLS-ms-81h" firstAttribute="bottom" secondItem="7gX-cs-H6x" secondAttribute="bottom" id="6p8-oz-atx"/>
57+
<constraint firstItem="YLS-ms-81h" firstAttribute="leading" secondItem="7gX-cs-H6x" secondAttribute="leading" id="72h-w0-ibb"/>
58+
<constraint firstItem="YLS-ms-81h" firstAttribute="top" secondItem="yMh-oN-h6N" secondAttribute="bottom" id="H0c-YF-ggi"/>
59+
<constraint firstItem="bDJ-YQ-Fba" firstAttribute="trailing" secondItem="yMh-oN-h6N" secondAttribute="trailing" id="LlD-gz-Qxg"/>
60+
<constraint firstItem="bDJ-YQ-Fba" firstAttribute="top" secondItem="yMh-oN-h6N" secondAttribute="top" symbolic="YES" id="Lyf-dh-JpZ"/>
61+
<constraint firstItem="DOk-3h-gKt" firstAttribute="leading" secondItem="bDJ-YQ-Fba" secondAttribute="leading" id="Pot-p2-KQq"/>
62+
<constraint firstItem="DOk-3h-gKt" firstAttribute="trailing" secondItem="bDJ-YQ-Fba" secondAttribute="trailing" id="dsL-sF-9B8"/>
63+
<constraint firstItem="yMh-oN-h6N" firstAttribute="leading" secondItem="bDJ-YQ-Fba" secondAttribute="leading" id="uQr-PE-lfP"/>
64+
</constraints>
65+
<viewLayoutGuide key="safeArea" id="bDJ-YQ-Fba"/>
66+
</view>
67+
<connections>
68+
<outlet property="observerInstructionLabel" destination="qgh-ab-wUm" id="FNy-gu-voB"/>
69+
<outlet property="sceneView" destination="YLS-ms-81h" id="siT-TH-Arp"/>
70+
<outlet property="targetInstructionLabel" destination="jHc-7B-FsF" id="wlz-FY-Txb"/>
71+
</connections>
72+
</viewController>
73+
<placeholder placeholderIdentifier="IBFirstResponder" id="xV7-CA-qW6" userLabel="First Responder" sceneMemberID="firstResponder"/>
74+
</objects>
75+
<point key="canvasLocation" x="799" y="10"/>
76+
</scene>
77+
</scenes>
78+
</document>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright 2018 Esri.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import UIKit
16+
import ArcGIS
17+
18+
class LineOfSightLocationViewController: UIViewController, AGSGeoViewTouchDelegate {
19+
20+
@IBOutlet weak var sceneView: AGSSceneView!
21+
@IBOutlet weak var observerInstructionLabel: UILabel!
22+
@IBOutlet weak var targetInstructionLabel: UILabel!
23+
24+
private var lineOfSight: AGSLocationLineOfSight? {
25+
willSet {
26+
sceneView.analysisOverlays.removeAllObjects()
27+
}
28+
didSet {
29+
guard let lineOfSight = lineOfSight else {
30+
targetInstructionLabel.isHidden = true
31+
return
32+
}
33+
34+
targetInstructionLabel.isHidden = false
35+
36+
// create an analysis overlay using a single Line of Sight and add it to the scene view
37+
let analysisOverlay = AGSAnalysisOverlay()
38+
analysisOverlay.analyses.add(lineOfSight)
39+
sceneView.analysisOverlays.add(analysisOverlay)
40+
}
41+
}
42+
43+
private let ELEVATION_SERVICE_URL = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
44+
45+
override func viewDidLoad() {
46+
super.viewDidLoad()
47+
48+
// add the source code button item to the right of navigation bar
49+
(navigationItem.rightBarButtonItem as! SourceCodeBarButtonItem).filenames = ["LineOfSightLocationViewController"]
50+
51+
// initialize the scene with an imagery basemap
52+
let scene = AGSScene(basemap: AGSBasemap.imagery())
53+
54+
// assign the scene to the scene view
55+
sceneView.scene = scene
56+
57+
// initialize the elevation source with the service URL and add it to the base surface of the scene
58+
let elevationSrc = AGSArcGISTiledElevationSource(url: ELEVATION_SERVICE_URL)
59+
scene.baseSurface?.elevationSources.append(elevationSrc)
60+
61+
// set the viewpoint specified by the camera position
62+
let camera = AGSCamera(location: AGSPoint(x: -73.0815, y: -49.3272, z: 4059, spatialReference: AGSSpatialReference.wgs84()), heading: 11, pitch: 62, roll: 0)
63+
sceneView.setViewpointCamera(camera)
64+
65+
// set touch delegate on scene view as self
66+
sceneView.touchDelegate = self
67+
68+
// set the line width (default 1.0). This setting is applied to all line of sight analysis in the view
69+
AGSLineOfSight.setLineWidth(2.0)
70+
}
71+
72+
// MARK: - AGSGeoViewTouchDelegate
73+
74+
func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
75+
// user tapped to place Line of Sight observer. Create Line of Sight analysis if need be
76+
if (lineOfSight == nil) {
77+
// set initial Line of Sight analysis with tapped point
78+
lineOfSight = AGSLocationLineOfSight(observerLocation: mapPoint, targetLocation: mapPoint)
79+
} else {
80+
// update the observer location
81+
lineOfSight?.observerLocation = mapPoint
82+
}
83+
}
84+
85+
func geoView(_ geoView: AGSGeoView, didLongPressAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
86+
// update the target location
87+
lineOfSight?.targetLocation = mapPoint
88+
}
89+
90+
func geoView(_ geoView: AGSGeoView, didMoveLongPressToScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
91+
// update the target location
92+
lineOfSight?.targetLocation = mapPoint
93+
}
94+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Line of sight (location)
2+
3+
This sample demonstrates how to interactively place a line of sight between two locations.
4+
5+
![](image1.png)
6+
7+
## How it works
8+
9+
`AGSLocationLineOfSight` is created using the `init(observerLocation:targetLocation:)` initializer that takes observer and target locations. As a result of the analysis, a line is rendered between the observer and target with green color representing visible segment and red color representing obstructed segment. Analysis overlay is used to render the results of visual analysis on the scene view.
10+
11+
The line width used to render analysis results is set using the `setLineWidth()` method on the base class for the line of sight analysis called `AGSLineOfSight`. This setting is applied to all line of sight analyses in the view.
12+
13+
`AGSGeoViewTouchDelegate` is used for capturing user's interaction on map and updating the `observerLocation` and `targetLocation`. The observer location is set in the `geoView(_:didTapAtScreenPoint:mapPoint:)` method when user taps on the map. The target location is updated in the `geoView(_:didLongPressAtScreenPoint:mapPoint:)` method when user performs long-pressed gesture at a specified location and in the `geoView(_:didMoveLongPressToScreenPoint:mapPoint:)` method when user drags the target location during a long press interaction.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//
2+
// Copyright 2018 Esri.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
import UIKit
17+
import ArcGIS
18+
19+
protocol AddStatisticDefinitionsViewControllerDelegate: class {
20+
func addStatisticDefinitions(_ statisticDefinitions: [AGSStatisticDefinition])
21+
}
22+
23+
class AddStatisticDefinitionsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
24+
25+
@IBOutlet private var tableView: UITableView!
26+
@IBOutlet private weak var fieldNamePicker: HorizontalPicker!
27+
@IBOutlet private weak var statisticTypePicker: HorizontalPicker!
28+
@IBOutlet private var tableNavigationItem: UINavigationItem!
29+
30+
public var fieldNames = [String]()
31+
public var statisticDefinitions = [AGSStatisticDefinition]()
32+
private var statisticTypes = ["Average", "Count", "Maximum", "Minimum", "StandardDeviation", "Sum", "Variance"]
33+
34+
// Delegate
35+
weak var delegate: AddStatisticDefinitionsViewControllerDelegate?
36+
37+
override func viewDidLoad() {
38+
super.viewDidLoad()
39+
40+
// Setup UI Controls
41+
setupUI()
42+
}
43+
44+
private func setupUI() {
45+
//
46+
// Add picker options
47+
fieldNamePicker.options = fieldNames
48+
statisticTypePicker.options = statisticTypes
49+
50+
// Set fieldNamePicker's selected field
51+
if fieldNamePicker.options.contains("POP2007"), let index = fieldNamePicker.options.index(of: "POP2007") {
52+
fieldNamePicker.selectedIndex = index
53+
}
54+
}
55+
56+
//MARK: - TableView data source
57+
58+
func numberOfSections(in tableView: UITableView) -> Int {
59+
return 1
60+
}
61+
62+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
63+
return statisticDefinitions.count
64+
}
65+
66+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
67+
let cell = tableView.dequeueReusableCell(withIdentifier: "StatisticDefinitionCell", for: indexPath)
68+
if statisticDefinitions.count > 0 {
69+
let statisticDefinition = statisticDefinitions[indexPath.row]
70+
let statisticTypeString = statisticTypes[statisticDefinition.statisticType.rawValue]
71+
let text = "\(statisticDefinition.onFieldName) (\(statisticTypeString))"
72+
cell.textLabel?.text = text
73+
}
74+
return cell
75+
}
76+
77+
// MARK: - Actions
78+
79+
@IBAction func addStatisticDefinitionAction(_ sender: Any) {
80+
//
81+
// Add statistic definition
82+
if let statisticType = AGSStatisticType(rawValue: statisticTypePicker.selectedIndex) {
83+
let fieldName = fieldNamePicker.options[fieldNamePicker.selectedIndex]
84+
let statisticDefinition = AGSStatisticDefinition(onFieldName: fieldName, statisticType: statisticType, outputAlias: nil)
85+
statisticDefinitions.append(statisticDefinition)
86+
87+
// Reload table
88+
tableView.reloadData()
89+
}
90+
else {
91+
print("Unable to determine AGSStatisticType from raw value \(statisticTypePicker.selectedIndex).")
92+
}
93+
}
94+
95+
@IBAction private func doneAction() {
96+
//
97+
// Fire delegate
98+
delegate?.addStatisticDefinitions(statisticDefinitions)
99+
100+
// Dismiss view controller
101+
dismiss(animated: true, completion: nil)
102+
}
103+
}

0 commit comments

Comments
 (0)