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 #348 from Esri/v.next
Browse files Browse the repository at this point in the history
100.2.1 samples
  • Loading branch information
dg0yal authored Feb 22, 2018
2 parents 52b4e62 + 6a5eb94 commit c0d6aad
Show file tree
Hide file tree
Showing 52 changed files with 3,261 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The ```master``` branch of this repository contains samples configured for the l
* Scenes - Display scenes, 3D symbols, and scene layers

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

Expand Down
151 changes: 151 additions & 0 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
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<device id="retina5_9" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Line Of Sight Location View Controller-->
<scene sceneID="uVV-jY-ewq">
<objects>
<viewController id="beF-yn-MU6" customClass="LineOfSightLocationViewController" customModule="arcgis_ios_sdk_samples" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="7gX-cs-H6x">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" placeholderIntrinsicWidth="infinite" placeholderIntrinsicHeight="34" translatesAutoresizingMaskIntoConstraints="NO" id="yMh-oN-h6N" userLabel="Instructions Container">
<rect key="frame" x="0.0" y="44" width="375" height="34"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="DOk-3h-gKt">
<rect key="frame" x="0.0" y="8" width="375" height="18"/>
<subviews>
<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">
<rect key="frame" x="0.0" y="0.0" width="375" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.0" green="0.36862745099999999" blue="0.58431372550000005" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="0.0" y="-52" width="375" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.0" green="0.36862745099999999" blue="0.58431372550000005" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="DOk-3h-gKt" secondAttribute="bottom" constant="8" id="48f-E0-Fb3"/>
<constraint firstItem="DOk-3h-gKt" firstAttribute="top" secondItem="yMh-oN-h6N" secondAttribute="top" constant="8" id="ZTX-Hc-u47"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YLS-ms-81h" customClass="AGSSceneView">
<rect key="frame" x="0.0" y="78" width="375" height="734"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="YLS-ms-81h" secondAttribute="trailing" id="4JD-Hc-i8w"/>
<constraint firstItem="YLS-ms-81h" firstAttribute="bottom" secondItem="7gX-cs-H6x" secondAttribute="bottom" id="6p8-oz-atx"/>
<constraint firstItem="YLS-ms-81h" firstAttribute="leading" secondItem="7gX-cs-H6x" secondAttribute="leading" id="72h-w0-ibb"/>
<constraint firstItem="YLS-ms-81h" firstAttribute="top" secondItem="yMh-oN-h6N" secondAttribute="bottom" id="H0c-YF-ggi"/>
<constraint firstItem="bDJ-YQ-Fba" firstAttribute="trailing" secondItem="yMh-oN-h6N" secondAttribute="trailing" id="LlD-gz-Qxg"/>
<constraint firstItem="bDJ-YQ-Fba" firstAttribute="top" secondItem="yMh-oN-h6N" secondAttribute="top" symbolic="YES" id="Lyf-dh-JpZ"/>
<constraint firstItem="DOk-3h-gKt" firstAttribute="leading" secondItem="bDJ-YQ-Fba" secondAttribute="leading" id="Pot-p2-KQq"/>
<constraint firstItem="DOk-3h-gKt" firstAttribute="trailing" secondItem="bDJ-YQ-Fba" secondAttribute="trailing" id="dsL-sF-9B8"/>
<constraint firstItem="yMh-oN-h6N" firstAttribute="leading" secondItem="bDJ-YQ-Fba" secondAttribute="leading" id="uQr-PE-lfP"/>
</constraints>
<viewLayoutGuide key="safeArea" id="bDJ-YQ-Fba"/>
</view>
<connections>
<outlet property="observerInstructionLabel" destination="qgh-ab-wUm" id="FNy-gu-voB"/>
<outlet property="sceneView" destination="YLS-ms-81h" id="siT-TH-Arp"/>
<outlet property="targetInstructionLabel" destination="jHc-7B-FsF" id="wlz-FY-Txb"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="xV7-CA-qW6" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="799" y="10"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright 2018 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import UIKit
import ArcGIS

class LineOfSightLocationViewController: UIViewController, AGSGeoViewTouchDelegate {

@IBOutlet weak var sceneView: AGSSceneView!
@IBOutlet weak var observerInstructionLabel: UILabel!
@IBOutlet weak var targetInstructionLabel: UILabel!

private var lineOfSight: AGSLocationLineOfSight? {
willSet {
sceneView.analysisOverlays.removeAllObjects()
}
didSet {
guard let lineOfSight = lineOfSight else {
targetInstructionLabel.isHidden = true
return
}

targetInstructionLabel.isHidden = false

// create an analysis overlay using a single Line of Sight and add it to the scene view
let analysisOverlay = AGSAnalysisOverlay()
analysisOverlay.analyses.add(lineOfSight)
sceneView.analysisOverlays.add(analysisOverlay)
}
}

private let ELEVATION_SERVICE_URL = URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!

override func viewDidLoad() {
super.viewDidLoad()

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

// initialize the scene with an imagery basemap
let scene = AGSScene(basemap: AGSBasemap.imagery())

// assign the scene to the scene view
sceneView.scene = scene

// initialize the elevation source with the service URL and add it to the base surface of the scene
let elevationSrc = AGSArcGISTiledElevationSource(url: ELEVATION_SERVICE_URL)
scene.baseSurface?.elevationSources.append(elevationSrc)

// set the viewpoint specified by the camera position
let camera = AGSCamera(location: AGSPoint(x: -73.0815, y: -49.3272, z: 4059, spatialReference: AGSSpatialReference.wgs84()), heading: 11, pitch: 62, roll: 0)
sceneView.setViewpointCamera(camera)

// set touch delegate on scene view as self
sceneView.touchDelegate = self

// set the line width (default 1.0). This setting is applied to all line of sight analysis in the view
AGSLineOfSight.setLineWidth(2.0)
}

// MARK: - AGSGeoViewTouchDelegate

func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
// user tapped to place Line of Sight observer. Create Line of Sight analysis if need be
if (lineOfSight == nil) {
// set initial Line of Sight analysis with tapped point
lineOfSight = AGSLocationLineOfSight(observerLocation: mapPoint, targetLocation: mapPoint)
} else {
// update the observer location
lineOfSight?.observerLocation = mapPoint
}
}

func geoView(_ geoView: AGSGeoView, didLongPressAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
// update the target location
lineOfSight?.targetLocation = mapPoint
}

func geoView(_ geoView: AGSGeoView, didMoveLongPressToScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
// update the target location
lineOfSight?.targetLocation = mapPoint
}
}
13 changes: 13 additions & 0 deletions arcgis-ios-sdk-samples/Analysis/Line of sight (location)/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Line of sight (location)

This sample demonstrates how to interactively place a line of sight between two locations.

![](image1.png)

## How it works

`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.

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.

`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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// Copyright 2018 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import UIKit
import ArcGIS

protocol AddStatisticDefinitionsViewControllerDelegate: class {
func addStatisticDefinitions(_ statisticDefinitions: [AGSStatisticDefinition])
}

class AddStatisticDefinitionsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

@IBOutlet private var tableView: UITableView!
@IBOutlet private weak var fieldNamePicker: HorizontalPicker!
@IBOutlet private weak var statisticTypePicker: HorizontalPicker!
@IBOutlet private var tableNavigationItem: UINavigationItem!

public var fieldNames = [String]()
public var statisticDefinitions = [AGSStatisticDefinition]()
private var statisticTypes = ["Average", "Count", "Maximum", "Minimum", "StandardDeviation", "Sum", "Variance"]

// Delegate
weak var delegate: AddStatisticDefinitionsViewControllerDelegate?

override func viewDidLoad() {
super.viewDidLoad()

// Setup UI Controls
setupUI()
}

private func setupUI() {
//
// Add picker options
fieldNamePicker.options = fieldNames
statisticTypePicker.options = statisticTypes

// Set fieldNamePicker's selected field
if fieldNamePicker.options.contains("POP2007"), let index = fieldNamePicker.options.index(of: "POP2007") {
fieldNamePicker.selectedIndex = index
}
}

//MARK: - TableView data source

func numberOfSections(in tableView: UITableView) -> Int {
return 1
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return statisticDefinitions.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "StatisticDefinitionCell", for: indexPath)
if statisticDefinitions.count > 0 {
let statisticDefinition = statisticDefinitions[indexPath.row]
let statisticTypeString = statisticTypes[statisticDefinition.statisticType.rawValue]
let text = "\(statisticDefinition.onFieldName) (\(statisticTypeString))"
cell.textLabel?.text = text
}
return cell
}

// MARK: - Actions

@IBAction func addStatisticDefinitionAction(_ sender: Any) {
//
// Add statistic definition
if let statisticType = AGSStatisticType(rawValue: statisticTypePicker.selectedIndex) {
let fieldName = fieldNamePicker.options[fieldNamePicker.selectedIndex]
let statisticDefinition = AGSStatisticDefinition(onFieldName: fieldName, statisticType: statisticType, outputAlias: nil)
statisticDefinitions.append(statisticDefinition)

// Reload table
tableView.reloadData()
}
else {
print("Unable to determine AGSStatisticType from raw value \(statisticTypePicker.selectedIndex).")
}
}

@IBAction private func doneAction() {
//
// Fire delegate
delegate?.addStatisticDefinitions(statisticDefinitions)

// Dismiss view controller
dismiss(animated: true, completion: nil)
}
}
Loading

0 comments on commit c0d6aad

Please sign in to comment.