ArcGIS Runtime- Editing Your Data Online and...
Transcript of ArcGIS Runtime- Editing Your Data Online and...
ArcGIS Runtime- Editing Your Data
Online and OfflineWill Crick
Justin Colville
Euan Cameron
ArcGIS Runtime Session Tracks at DevSummit 2017
• ArcGIS Runtime SDKs share a common core, architecture and design
• Functional sessions promote common capabilities and workflows
- An Introduction to the API and Architecture
- Working with Your Portal
- Building Great User Experiences
- Styling Maps
- Working with Maps Online and Offline
- Editing Your Data Online and Offline
- Maximizing Performance of Your Apps
- Analysis
- Building 3D Applications
• Product sessions promote specific development experiences
• Demo theaters highlight examples of specific technical capabilities
Shared workflows, any platform, any device
.NET iOS macOS Android Java Qt
ArcGIS Runtime core
Agenda
• Editing workflows
• API overview
- Works for both online & offline editing
- CRUD operation, attachments, templates, permissions
• Online editing
• Offline editing
• Static feature collection editing
• Map package editing
Editing Workflows
1. Online feature service editing
- Feature services
2. Offline feature service editing and sync
- Sync-able mobile geodatabases
- Created with the the GeodatabaseSyncTask (see the online and offline maps session)
3. Static feature collection editing
- Feature collections (map and item based)
4. Offline map package editing
- Map packages created in ArcMap
- Use map packages in Local Server as a feature service
- Editing code workflow same as 1.
• Mobile map packages from Pro are NOT EDITABLE
- Right now anyway…
Feature Service Based Editing (Online and Offline)
• Data accessed via Feature Services
- Good for data that changes over time
- Good for large data sets
- Scalable (to a certain point)
• Simple features only
- Attachments are supported
• Clients modify features then push these changes back to the service
- Apply edits or sync
• Last in wins conflict detection
Static Feature Collection Editing
• Data accessed via feature collections
- In the map
- As their own portal items
• Good for data that does not change very often
- Will not update unless map/item is reloaded
• Slow initial load
- Loads ALL features
• Scalable for viral applications
- No backend server resources required
- Data retrieval from storage only
ArcGIS FeatureTable API
ServiceFeatureTable
ArcGISFeatureTable
FeatureLayer
FeatureTable
getRenderer()
setDefintionExpression()
addF…(), updateF…(), deleteF…()
queryFeatures()
getLayerInfo()
getTypes/Templates()
applyEdits()
ArcGISFeature
Feature
geometry()
attributes() GeoElement
FeatureTable()
Attachments()
Loadable()
GeodatabaseFeatureTable getGeodatabase()
Editing API Overview
• Features are by-value objects with respect to their table
• Step 1. perform CRUD operations on the table
- Create/get a feature
- update it
- then call a method to update the feature in the table
• Generic pattern for both online and offline – up next…
• Step 2. Apply/sync the edits to the source service
- Online workflow – apply edits
- Offline workflow – sync
- Static feature collection workflow – save map, or save item
• Specific sections on each later on…
Creating New Features
• Check you can add new features
- FeatureTable.canAdd()
• Create a new feature from the table
- FeatureTable.createNewFeature() -> Feature
- ArcGISFeatureTable.createNewFeature(FeatureType/FeatureTemplate) -> ArcGISFeature
• Update attributes
- Some incorrect data types will error client side as you change them (if we can)
• FeatureTable.addFeature(feature)
- Async method
- Returns error if validation fails
- e.g. feature from different table or non-nullable fields still null
Updating Existing Features
• Get feature (query, select or identify)
• Check feature can be updated
- FeatureTable.canUpdate(feature) – checks table ownership, attribute types and more...
• Update attributes
- Some incorrect data types will error client side as you change them (if we can)
• FeatureTable.updateFeature(feature)
- Async method
- Returns error if validation fails
- e.g. feature from different table or non-nullable fields still null
Deleting Features
• Get feature (query, select or identify)
• Check FeatureTable.canDelete()
• FeatureTable.deleteFeature(feature)
- Async method
- Returns error if validation fails
- e.g. feature from different table or non-nullable fields still null
Attachments
• Get an ArcGISFeature (query, selection, identify)
• Check ArcGISFeatureTable.hasAttachments()
• Get its Attachments
- ArcGISFeature.fetchAttachments()
• Attachment class
- Not loadable – don’t want to hold data in memory, should write to disk
- Retrieve attachment data via async Attachment.fetchData() method
- Only get the data when you need it (e.g. when a list item is actually displayed)
Editing Attachments
• Check features attachments can be updated
- ArcGISFeature.canEditAttachments()
• Change attachments on the ArcGISFeature
- ArcGISFeature.addAttachment(byte[], type, name) -> Attachment
- ArcGISFeature.updateAttachment(Attachment, byte[], type, name)
- ArcGISFeature.deleteAttachment(Attachment)
• Call canUpdate(feature) – checks attachment edits are ok
• Call ArcGISFeatureTable.updateFeature(arcgisfeature)
Using Editing Feature Templates
• Leverage the types/templates configured in the service
• Check if there are FeatureTypes first
- If there are types, get templates from the types
- if (ArcGISFeatureTable.getTypeIdField() != "") {…
• Otherwise use FeatureTypes from the table
- ArcGISFeatureTable.getFeatureTypes()
- Iterate over types
Build a Template Picker for New Features
• Coming in toolkit....
• To generate a swatch
- Create a new feature based on the template ( ArcGISFeatureTable.createNewFeature(template) )
- Create a symbol from the renderer ( Renderer.createSymbol(feature) )
- Create a swatch from the symbol ( Symbol.createSwatch() )
• Allow users to choose from a template
• ArcGISFeatureTable.createNewFeature(template)
Justin
Feature Types and
Templates demo
Feature Service Permissions and Editor Tracking
• Editor permissions
- Control if users can add, delete or modify features
- Query the capabilities on the FeatureTable (base class) to determine what tools to show
- canAdd() – new features can be added
- canDelete() – features can be deleted
- canUpdate(feature) – checks editor permissions
- canEditGeometry() – if false, only attributes can be modified
• Editor tracking
- Managed by the API for you (your welcome )
- Layer properties found on ArcGISFeatureLayerInfo (get from ArcGISFeatureTable)
- Configured at Feature service level, properties available on ArcGISFeatureServiceInfo
- getEditableAttributeFields() – will NOT return editor tracking fields API manages
Ownership Based Access Control (OBAC)
• Requires editor tracking
• Restricts edits to features users own
• Creator populated for you by Editor Tracking
• Update restrictions handled for you
- Using canUpdate(feature) – checks OBAC rules
Editing Versioned Data
• All edits are applied to the services configured version
• ArcGISFeatureLayerInfo or ArcGISFeatureServiceInfo
- isDataVersioned() property
• Back-end reconcile and post procedure required
Online Editing
ArcGIS Online – Editing Online
Author
Features sent to client
as needed
Edits pushed back to service
Edit
Author
Optional
ArcGIS
Desktop
Online Editing
• Uses ServiceFeatureTable
• ServiceFeatureTableModes
- On_Interaction_Cache – default mode
- Caches features as you pan/zoom/query when possible
- Good for most data sets
- Queries mostly go to the server
- On_Interaction_NoCache – you have to set this BEFORE table is loaded
- Never caches – every pan/zoom/query clears table and gets new data
- Good for data that changes frequently
- Queries ALWAYS go to the server
- Manual_Cache – you have to define what you get
- Call ServiceFeatureTable.populateFromService(query)
- Up to you how this changes over time (clear, add features with additional populate calls etc…)
- Queries and edits ALWAYS work locally
Online Pattern
• Edit features (as in previous slides)
• Call ServiceFeatureTable.applyEdits()
- Applies all feature and attachment edits
- Try to call this immediately
- Edits are cached in case on network error
Loadable Features
• Features don’t always have all of their attributes
- Load the feature to get all the data
- Load the feature to edit
• Why?
• Allows us to optimize feature queries for map rendering
- Including generalized geometries in certain modes
• Reduces complexity of OutFields
• Removes parameters on QueryParameters
- ReturnZ, ReturnM etc..
Loadable Feature Patterns
• Identify
- Identify on the MapView returns a feature
- Load the feature
- Show in popup/callout
• Show a table view
- Query the table, set QueryOptions to return loaded features
- Show the features in a table view
• Edit features
- Load the feature BEFORE editing
Justin
Editing Features
Online Demo
Online Editing Challenges
• Performance considerations with Large complex features
• Only works when connected
• ServiceFeatureTable provides access to features already downloaded in the event of
intermittent connection
- Connection still required to push edits back to service
- Table held in memory only, not persisted across app sessions
Offline Editing
ArcGIS Online – Editing Offline
Author
Edit
Synchronize
Download
Author
Optional
ArcGIS
Desktop
Offline Feature Access
• OnDemand workflow
- Users takes features offline on an as needed basis
• Preplanned workflow
- Geodatabase is generated up front and downloaded/provisioned to the client
- Register geodatabas before editing
- Scales to very large user numbers with less burden on the server
• Synchronization framework provides robust support for these workflows
Offline Pattern
• Determine if you have edits
- High level to provide simple indicator
- Geodatabase.hasLocalEdits()
- More detail to show a count (does not include attachments)
- ArcGISFeatureTable.getAdded/Updated/Deleted Features
- Time based
- GeodatabaseFeatureTable.hasLocalEditsSince(time)
• Call Sync!
Offline Editing Synchronization Framework
• Per layer sync
• Per geodatabase sync
• Control over sync direction
- Download changes and upload edits - bidirectional
- Upload edits only
- Download changes only
• GeoDatabaseSyncTask encapsulates this
How Does Sync Work?The flow of data
Generate
geodatabase
enabled for sync
Feature service
with sync enabled
Adds, edits, deletes Generate delta
geodatabase
Upload delta
Retrieve response
Apply response to
geodatabase
Call Sync
Justin
Offline Editing with
ArcGIS Online
Demo
Static Feature Collection
Editing
Static Feature Collection Editing
Author
Download collection
Save map / item
Edit
Import data
Static Feature Collection Pattern
• Open a map containing a FeatureCollectionLayer
• Create a FeatureCollectionLayer from a portal item
• Create a new FeatureCollectionLayer
• Edit the features in the FeatureCollectionTables
• Save the FeatureCollection
- In the map – call Map.save()
- As a portal item – use the portal API
FeatureCollectionLayer
FeatureCollectionLayer
FeatureCollection
getItem()
getFeatureCollection()
getFeatureLayers()
getTables()
FeatureCollectionTable
*
add(), update(),delete()FeatureLayer
*
FeatureTable
Offline Map Package Editing
Offline Map Package Editing
Create Map
Package
Edit
Provision
to Local Server
Author
Map
ArcGIS
Desktop
Import Changes from
File GeoDatabase
ArcGIS Desktop Workflows
• Publish to a local server feature service and use the workflows previously described
• Local Server can support more complex workflows
- Available on Windows Desktop and Linux
- .Net, Java and Qt APIs
• Local Server provides access via a feature service
- Features can be stored in a file geodatabase, or an RDBMS and accesed via direct connect
Justin
Local Server Demo
ArcGIS Runtime SDK v100.x License Model
Standard
• License Key
• All capabilities of Basic
• Access to additional data
• Raster layers
• Raster elevation sources
• Local Server
• Map services
• Feature services
• Edit file geodatabases
• GP services
• Subset of ArcGIS Desktop
basic tools
Advanced
• License Key
• All capabilities of Standard
• Local Server
• Feature services
• Edit enterprise geodatabases
• GP services
• Subset of ArcGIS Desktop
standard and advanced
tools
Basic
• Named User – Level 2
• License Key
• All capabilities of Lite
• Simple feature editing
• Add, update, delete content on
portals
• Use of ArcGIS Online analysis
services
Lite
• Named User – Level 1
• License Key
• View maps, scenes, layers, packages
from the ArcGIS Platform
• Routing
• Place finding
Analysis Extension
• License Key
• Local Server GP tools
• 3D Analyst
• Spatial Analyst
• Network Analyst
Licensing Your Editing App
• Editing online
- ArcGIS Runtime Basic
• Editing offline
- ArcGIS Runtime Basic
• Editing using Local Server
- ArcGIS Runtime Standard
Aspect Ratio Test
Esri Corporate Template-Dark v3.3
16:9 version – January 21, 2016
If this shape does not appear as
a perfect circle, adjust the aspect
ratio of your display until it does.
Try the resolution 1920x1080 for
16:9 displays.