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

Commit

Permalink
Merge pull request #58 from Esri/v.next
Browse files Browse the repository at this point in the history
100.2 Samples
  • Loading branch information
dg0yal authored Dec 18, 2017
2 parents e33b78f + 503cb89 commit 9f958f0
Show file tree
Hide file tree
Showing 100 changed files with 3,052 additions and 975 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ The samples use ArcGIS Online basemaps and services. Learn more [here](http://w
2. Build and run the project to create a single app containing all of the samples.

## Requirements
[ArcGIS Runtime SDK for macOS](http://developers.arcgis.com/macOS/) (Requires ArcGIS for Developers account; free to sign up)

For Swift :
* XCode 8.0 (or higher)
* macOS SDK 10.12 (or higher)
* [ArcGIS Runtime SDK for macOS](http://developers.arcgis.com/macOS/) 100.2 (or higher)
* XCode 9.0 (or higher)
* macOS SDK 10.13 (or higher)

## Additional Resources

Expand Down
258 changes: 255 additions & 3 deletions arcgis-runtime-samples-macos.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HotspotsViewController: NSViewController {
self.applyButton.isEnabled = false

//cancel previous job request
self.geoprocessingJob?.cancel()
self.geoprocessingJob?.progress.cancel()

//geoprocessing parameters
let params = AGSGeoprocessingParameters(executionType: .asynchronousSubmit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ViewshedViewController: NSViewController, AGSGeoViewTouchDelegate {
self.resultGraphicsOverlay.graphics.removeAllObjects()

//Cancel previous job
self.geoprocessingJob?.cancel()
self.geoprocessingJob?.progress.cancel()

//the service requires input of rest data type GPFeatureRecordSetLayer
//which is AGSGeoprocessingFeatures in runtime
Expand Down
17 changes: 17 additions & 0 deletions arcgis-runtime-samples-macos/Analysis/Statistical query/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Statistical query

This sample demonstrates how to query a feature table to get aggregated statistics back for a specific field.

## How to use the sample

Select the appropriate switch to filter features by attributes and/or within the current extent. Click the button to see basic statistics displayed for world cities.

![](image1.png)

## How it works

An `AGSServiceFeatureTable` is created with a URL to the REST endpoint of a feature service. `AGSStatisticsQueryParameters` are created, and several `AGSStatisticDefinition` objects are created and added to the parameters. These definitions defines the various statistics that we would like to compute, such as average, minimum and maximum of a given field. When the button is clicked, `queryStatistics` is executed on the `AGSServiceFeatureTable`. Depending on the state of two switches, additional paramters are set. This process runs asynchronously, and once completed, returns `AGSStatisticsQueryResult`, which contains key/value pairs as the result.




Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="wP8-H8-3FB">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Statistical Query View Controller-->
<scene sceneID="OvX-k4-GDR">
<objects>
<viewController id="wP8-H8-3FB" customClass="StatisticalQueryViewController" customModule="arcgis_runtime_samples_macos" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="9Lv-6O-Wz6">
<rect key="frame" x="0.0" y="0.0" width="656" height="592"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="v6y-KQ-9tg" customClass="AGSMapView">
<rect key="frame" x="0.0" y="0.0" width="656" height="592"/>
</customView>
<visualEffectView wantsLayer="YES" appearanceType="vibrantLight" blendingMode="withinWindow" material="appearanceBased" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="KSm-rV-tiC">
<rect key="frame" x="411" y="455" width="225" height="115"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="tmk-nm-TUB">
<rect key="frame" x="0.0" y="0.0" width="225" height="115"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="Tfx-M9-Mch">
<rect key="frame" x="18" y="226" width="187" height="18"/>
<buttonCell key="cell" type="check" title="Only cities greater than 5M" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="1Rk-Mz-zLT">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="OBV-gv-rFM">
<rect key="frame" x="18" y="79" width="189" height="18"/>
<buttonCell key="cell" type="check" title="Only cities in current extent" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Aw8-ay-MzU">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sBp-iM-ZBt">
<rect key="frame" x="51" y="13" width="122" height="32"/>
<buttonCell key="cell" type="push" title="Get Statistics" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="DPT-rg-6x9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="getStatisticsAction:" target="wP8-H8-3FB" id="osw-6q-phA"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="gkv-gh-ymH">
<rect key="frame" x="18" y="52" width="187" height="18"/>
<buttonCell key="cell" type="check" title="Only cities greater than 5M" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="JVv-fz-Pen">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</subviews>
<constraints>
<constraint firstItem="gkv-gh-ymH" firstAttribute="centerX" secondItem="sBp-iM-ZBt" secondAttribute="centerX" id="03D-gj-TbG"/>
<constraint firstItem="OBV-gv-rFM" firstAttribute="leading" secondItem="gkv-gh-ymH" secondAttribute="leading" id="333-hU-pUL"/>
<constraint firstItem="gkv-gh-ymH" firstAttribute="top" secondItem="OBV-gv-rFM" secondAttribute="bottom" constant="13" id="3gn-uO-a7A"/>
<constraint firstItem="Tfx-M9-Mch" firstAttribute="leading" secondItem="OBV-gv-rFM" secondAttribute="leading" id="70N-6B-CaA"/>
<constraint firstItem="OBV-gv-rFM" firstAttribute="top" secondItem="tmk-nm-TUB" secondAttribute="top" constant="20" symbolic="YES" id="FA3-9u-B6v"/>
<constraint firstItem="OBV-gv-rFM" firstAttribute="leading" secondItem="tmk-nm-TUB" secondAttribute="leading" constant="20" symbolic="YES" id="HI8-EG-6J9"/>
<constraint firstAttribute="bottom" secondItem="sBp-iM-ZBt" secondAttribute="bottom" constant="20" symbolic="YES" id="c6X-m4-qMt"/>
<constraint firstAttribute="trailing" secondItem="OBV-gv-rFM" secondAttribute="trailing" constant="20" symbolic="YES" id="dkg-dK-VUB"/>
<constraint firstItem="sBp-iM-ZBt" firstAttribute="top" secondItem="gkv-gh-ymH" secondAttribute="bottom" constant="13" id="ePi-GB-CJG"/>
<constraint firstItem="Tfx-M9-Mch" firstAttribute="top" secondItem="tmk-nm-TUB" secondAttribute="top" constant="-127" id="zpu-e4-Kxn"/>
</constraints>
</customView>
</subviews>
<constraints>
<constraint firstItem="tmk-nm-TUB" firstAttribute="leading" secondItem="KSm-rV-tiC" secondAttribute="leading" id="9zW-gR-51g"/>
<constraint firstItem="tmk-nm-TUB" firstAttribute="top" secondItem="KSm-rV-tiC" secondAttribute="top" id="H8T-c2-ypJ"/>
<constraint firstAttribute="trailing" secondItem="tmk-nm-TUB" secondAttribute="trailing" id="aXN-j6-XJv"/>
<constraint firstAttribute="bottom" secondItem="tmk-nm-TUB" secondAttribute="bottom" id="yzT-uC-l80"/>
</constraints>
</visualEffectView>
</subviews>
<constraints>
<constraint firstItem="v6y-KQ-9tg" firstAttribute="leading" secondItem="9Lv-6O-Wz6" secondAttribute="leading" id="7Q0-E9-wJ3"/>
<constraint firstItem="v6y-KQ-9tg" firstAttribute="top" secondItem="9Lv-6O-Wz6" secondAttribute="top" id="Qut-8M-e2R"/>
<constraint firstItem="KSm-rV-tiC" firstAttribute="top" secondItem="9Lv-6O-Wz6" secondAttribute="top" constant="22" id="hUe-SA-INO"/>
<constraint firstAttribute="trailing" secondItem="v6y-KQ-9tg" secondAttribute="trailing" id="uMS-Ym-2qH"/>
<constraint firstAttribute="trailing" secondItem="KSm-rV-tiC" secondAttribute="trailing" constant="20" symbolic="YES" id="veu-bN-ONl"/>
<constraint firstAttribute="bottom" secondItem="v6y-KQ-9tg" secondAttribute="bottom" id="vpF-Fh-B7H"/>
</constraints>
</view>
<connections>
<outlet property="getStatisticsButton" destination="sBp-iM-ZBt" id="8ru-69-7NA"/>
<outlet property="mapView" destination="v6y-KQ-9tg" id="wE0-77-yhC"/>
<outlet property="onlyBigCitiesCheckBox" destination="gkv-gh-ymH" id="XeA-a5-cPg"/>
<outlet property="onlyInCurrentExtentCheckBox" destination="OBV-gv-rFM" id="fSj-rW-9mn"/>
<outlet property="settingsView" destination="KSm-rV-tiC" id="yvo-BX-Wcp"/>
</connections>
</viewController>
<customObject id="LN9-mg-usj" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="27" y="145"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// Copyright 2017 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 Cocoa
import ArcGIS

class StatisticalQueryViewController: NSViewController {

@IBOutlet private weak var mapView: AGSMapView!
@IBOutlet weak var settingsView: NSVisualEffectView!
@IBOutlet private var getStatisticsButton: NSButton!
@IBOutlet private var onlyInCurrentExtentCheckBox: NSButton!
@IBOutlet private var onlyBigCitiesCheckBox: NSButton!
private var map: AGSMap?
private var serviceFeatureTable: AGSServiceFeatureTable?

override func viewDidLoad() {
super.viewDidLoad()

// Corner radius for view
settingsView.wantsLayer = true
settingsView.layer?.cornerRadius = 10

// Initialize map and set it on map view
map = AGSMap(basemap: AGSBasemap.streetsVector())
mapView.map = map

// Initialize feature table, layer and add it to map
serviceFeatureTable = AGSServiceFeatureTable(url: URL(string: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/0")!)
let featureLayer = AGSFeatureLayer(featureTable: serviceFeatureTable!)
map?.operationalLayers.add(featureLayer)
}

// MARK: - Actions

@IBAction private func getStatisticsAction(_ sender: Any) {
//
// Add the statistic definitions
var statisticDefinitions = [AGSStatisticDefinition]()
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .average, outputAlias: nil))
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .minimum, outputAlias: nil))
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .maximum, outputAlias: nil))
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .sum, outputAlias: nil))
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .standardDeviation, outputAlias: nil))
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .variance, outputAlias: nil))
statisticDefinitions.append(AGSStatisticDefinition(onFieldName: "POP", statisticType: .count, outputAlias: nil))

// Create the parameters with statistic definitions
let statisticsQueryParameters = AGSStatisticsQueryParameters(statisticDefinitions: statisticDefinitions)

// If only using features in the current extent, set up the spatial filter for the statistics query parameters
if (onlyInCurrentExtentCheckBox.state == 1) {
//
// Set the statistics query parameters geometry with the envelope
statisticsQueryParameters.geometry = mapView.visibleArea?.extent

// Set the spatial relationship to Intersects (which is the default)
statisticsQueryParameters.spatialRelationship = .intersects
}

// If only evaluating the largest cities (over 5 million in population), set up an attribute filter
if (onlyBigCitiesCheckBox.state == 1) {
statisticsQueryParameters.whereClause = "POP_RANK = 1"
}

// Execute the statistical query with parameters
serviceFeatureTable?.queryStatistics(with: statisticsQueryParameters, completion: { [weak self] (statisticsQueryResult, error) in
//
// If there an error, display it
guard error == nil else {
self?.showAlert(messageText: "Error", informativeText: "Error while executing statistics query :: \(String(describing: error?.localizedDescription))")
return
}

// Get the result
if let statisticRecordEnumerator = statisticsQueryResult?.statisticRecordEnumerator() {
//
// Let's build result message
var resultMessage = " \n"
while statisticRecordEnumerator.hasNextObject() {
let statisticRecord = statisticRecordEnumerator.nextObject()
for (key, value) in (statisticRecord?.statistics)! {
resultMessage += "\(key): \(value) \n"
}
}

// Show result
self?.showAlert(messageText: "Statistical Query Results", informativeText: resultMessage)
}
})
}

// MARK: - Helper Methods

private func showAlert(messageText:String, informativeText:String) {
let alert = NSAlert()
alert.messageText = messageText
alert.informativeText = informativeText
alert.beginSheetModal(for: self.view.window!, completionHandler: nil)
}
}

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,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "featureLayerGeoPackage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "featureLayerGeoPackage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "featureLayerGeoPackage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Feature layer (shapefile).png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Feature layer (shapefile)@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Feature layer (shapefile)@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "FeatureLayerExtrusion@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "FeatureLayerExtrusion@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "FeatureLayerExtrusion@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "Raster-function-service.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Raster-function-service@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Raster-function-service@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9f958f0

Please sign in to comment.