Building Applications with ArcGIS Runtime SDK for Android—Part II

Report 30 Downloads 409 Views
Building Applications with ArcGIS Runtime SDK for Android—Part II Will Crick Dan O’Neill

Agenda •

Intro



Connected editing summary



Offline capabilities -

Local features

-

Geometry Engine



Platform integration



Accessing content from ArcGIS Online/Portal



Best practice -

Layer performance

-

UI thread

-

Device support

Intro

Who are we all?



Who are you?



Who are we?

ArcGIS 10 — A Complete System Easier More Powerful and Everywhere

Cloud Web

Mobile

• Discover • Create • Manage • Visualize • Analyze • Collaborate

Enterprise

Local Desktop

Runtime SDKs Native ArcGIS Runtime SDKs

iOS

Runtime SDK •

Objective C

Android

Runtime SDK •

Java

Windows Mobile

Windows Phone

Runtime SDK •

Silverlight

Runtime SDK •

.NET

Core Runtime

Windows

Runtime SDK •

WPF, Java

Linux

Runtime SDK •

Java

Runtime Architecture Local Server

Remote Server

Mapping

GP

Editing

Tile Package

GPS

Messaging

Advanced Symbology

OpenGL

DirectX

Server Sync

Offline Routing

Spatial analysis

Offline Geocoding

Geocoding

Mapping

GP

Editing

Native platform capabilities

Runtime Core

Geocoding

WPF

Java

Android

iOS

Windows Mobile

Windows Phone

SDK Release Status



ArcGIS for Android SDK -

1.0 – current (12/11) – 1800 unique installs

-

1.1 to be released next week

-

-

Multiple maps

-

Advanced symbology/message processing

-

ArcGIS Online/Portal & webmap loading

-

Group layer

-

Improved secure service framework

-

Supports ADT r17

1.x/2.0 summer

Connected editing

Editing •

AttributeEditor & GeometryEditor samples in SDK



Uses Feature Service



-

Same model as other webapis

-

applyEdits()

AttributeEditor sample -

check field data types -

Data entry

-

Validation

Geometry Editing Sample •

Uses a “sketch” graphics layer -

Uses MapOnTouchListener -

Implements tap and drag events



Track local edit history yourself



Uses local GeometryEngine -

No server call

FeatureLayer.applyEdits() method



Aynchronous method -

CallbackListener / AsynTask

-

Callback tells success for each feature



applyEdits(adds, deletes, updates, callback)



Attribute updates -

Graphic - only changed attributes & ID

Offline capabilities

What can you do offline today? In memory feature layers

Base maps

Message Processing

Routing

Geocoding

Query attributes offline

Advanced symbology

Geometry operations

Store features in ArcGIS db Sync offline data with server

See the futures section at the end for news on this stuff!

Adding base maps



As seen in part I



Local tiled layers -

compact caches – from 10.0 server

-

NOT 10.1 TPKs [yet] -

Fat32 4GB file size limit

baseMapLayer = new ArcGISLocalTiledLayer(”file:///mnt/sdcard//Layers", false);

Offline features A •





Use in memory “feature collection” Feature Layer -

Feature set [array of features]

-

Layer definition [json from a feature service]

Change features using: -

addGraphic() / removeGraphic() methods

-

applyEdits() method [new in 1.1 for feature collection!]

Write features to/from disk in json [new in 1.1!]

B •

Graphics layers -

Add/remove graphics

C •

Advanced Symbology -

Process messages

Offline features code examples Create the layer… <string name="config.windturbine.layer.definition"> {\"currentVersion\":10.01,\"id\":0,\"name\":\"Wind Turbine\”… //Java class turbinesFeatureLayer = new ArcGISFeatureLayer(R.string. config.windturbine.layer.definition, FeatureSet, null);

(Demo app is different, creates layer then loads json features, then adds features)

Add/edit features… featureLayer.addGraphics(graphics); //or Graphic[] graphics = new Graphic[ g ]; featureLayer.applyEdits( //adds graphics, //updates, //deletes);

to/fromJson



Jackson JsonParser



Serialize to disk



-

FeatureSet.toJson(); - String

-

JsonGenerator.writeRawValue();

Read from disk -

Passed to activity in a bundle

-

FeatureSet.fromJson(jsonParser, hasSpatialRef);

File jsonFile = bladeRunnerApp.getJSONFile(BladeRunnerApplication.teamAreasName); JsonFactory jsonFactory = new JsonFactory(); JsonParser jsonParser = jsonFactory.createJsonParser(jsonFile); FeatureSet featureSet = FeatureSet.fromJson(jsonParser, true);

Blade Runner demo Will Crick

Message Processing





Add features to the map via a message -

Radio/UDP/wifi

-

Different actions, add/update/delete

-

Different message types

-

Requires an initialized group layer

Support for advanced symbology -

Based on symbol packages (dictionary .dat files)

-

2525c Military symbology (new in 1.1)

-

Build your own custom dictionary (future release) -

Needs desktop support

Message Processor Workflow •

MessageProcessor processes a message from an external resource



DictionaryType enum dictates message format



DictionaryType is backed by a resource bundle



-

Dictionary data file

-

Message file types

MessageProcessor bound to a Group Layer -

Used to display, update, and remove MultilayerSymbol

Message Processing Code example Create a MessageProcessor Object MapView map = (MapView)findViewById(R.id.map); final GroupLayer groupLayer = new GroupLayer(); map.addLayer(groupLayer); try { MessageProcessor processor = new MessageProcessor(DictionaryType.Mil2525C, groupLayer); } catch (FileNotFoundException e) { e.printStackTrace(); }

Message Processing Code example Create a Message object Process it! // Message creation Message lmessage = new Message(); UUID luuid = UUID.randomUUID(); lmessage.setID(luuid.toString()); lmessage.setProperty("_Type", "position_report"); lmessage.setProperty("_Action", "update"); String controlpoints = x1 + "," + y1; lmessage.setProperty("_Control_Points", controlpoints); lmessage.setProperty("sic", "SFGPUCRRL--E---"); lmessage.setProperty("_WKID", "3857"); lmessage.setProperty("UniqueDesignation", "2020"); // process message and add point processor.processMessage(lmessage);

Update Graphics •

Get GraphicLayer from GroupLayer



Get Graphic from GraphicsLayer



Get Geometry from Graphic



Set Property with update



Process messsage

Message message = processor.createMessageFrom(gr); String controlPoints = (String)message.getProperty( MessageHelper.MESSAGE_2525C_CONTROL_POINTS_PROPERTY_NAME); if (targetcontrolpt !=null) { message.setProperty( MessageHelper.MESSAGE_2525C_CONTROL_POINTS_PROPERTY_NAME,

targetcontrolpt.getX() + "," + targetcontrolpt.getY());

} message.setProperty("_Action", "update"); processor.processMessage(message);

Message processing demo Dan O’Neill

Platform integration Will Crick

Using the GPS



Wraps Android Location Service



Adds useful functions -

Symbol

-

Accuracy [changed at 1.1]

-

Auto pan

LocationService ls = map.getLocationService(); ls.setSymbol(symbol); ls.setAccuracyCircleOn(true); ls.setBearing(false);

(Demo app uses simulated location to make things easier!)

Compass sensor integration



Use SensorManager to get access to sensors



Create Sensor object ( TYPE_ORIENTATION / getOrientation() )



Register SensorEventListener with SensorManager

public void onSensorChanged(SensorEvent event) {

}

sensorValues = event.values; map.setRotationAngle(sensorValues[0]);

Bluetooth devices •

Laser range finder to add a point using an offset



Get BlueToothDevice from BlueToothAdapter(String address)



Create a custom service (BlueToothSerialService) -

reads bytes from a socket

-

send bytes in a message to MapViewActivity Handler

-

-

Converts to string buffer

-

Reads LSR sentence

Uses local method/ (maths) to create point from offset -

PointFromOffset will be in future version of SDK

Blade Runner app code

ArcGIS Portal (new in 1.1) Dan O’Neill

Portal API basics





Organization -

Part of portal created for specific entity

-

Configurable site

-

Invite and manage users

Groups and Users -

Collaboration with other portal users

-

Exchange content related to activities/projects

Accessing a Portal



Portal Class -

Entry point

-

Instantiate with credential or as guest

-

2 cases -

1. Organization account

-

2. Portal -

If credential provided automatically connects to Organization account

Workflow



Create a Portal



Get the feature group query list with portalinfo



Loop through the list of queries and retrieve each group



For each group get the title and thumbnail



Update the View with the results

Portal connection Create the portal with credentials and Portal URL

//set up portal portalUrl = "https://csf.maps.arcgis.com/"; credentials = new UserCredentials(); credentials.setUserAccount("mobile_org", "dev.team"); //create a new instance of portal Portal.newInstance(portalUrl, credentials, new PortalListener() { @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onCallback(Portal portal) { ... });

Search Portal •



Construct query string -

PortalQueryParams methods return query strings

-

findItemsWithQueryParams queries items and groups

Find list of items in a group

PortalQueryParams queryParams = new PortalQueryParams(); queryParams.setQueryForItemsInGroup(groupId); // You can also create your custom PortalQueryParams object PortalQueryParams queryParamS = new PortalQueryParams(); // Once you have the query parameter string, // you can make the query on the portal. portal.findItems(queryParams, portalListener);

ArcGIS Portal demo Dan O’Neill

Best Practice

ArcGIS for Android Layer performance •







Try to minimize traffic -

Requests are expensive

-

Processing of results cost

ArcGISFeatureLayer - types -

Snapshot / feature collection

-

On Demand

-

Selection

TileLayer (ArcGIS, Bing) -

Static

-

Also have dynamic access

Dynamic map service layer -



Image only

ArcGISLocalTiledLayer -

No network requests!

Combine together

The importance of the UI Thread



Work with Views on the UI Thread



Async methods are common -



Run in other threads

Options -

AsyncTask

-

Handler() – bound to creation thread -

Processed in a queue

-

messages & runnables

-

View.runOnUiThread(new runnable(){…})

-

ExecutorService

-

Threads

OS support



2.2 25%!

Device & OS support



Single app deployment -





Compatibility libraries -

Fragments 1.6+

-

Action Bar 3.0+

Some devices don’t have features -



cameras/gps

Deployment -



UI = fragments/different views

Manifest settings are really important

Localisation means global…

The future

Future releases •







Playing iOS catchup J -

Open Streetmap layer

-

NAServer task

-

Wrap around

-

Navigation modes

10.1 server support -

Editor tracking

-

Replica service -

Also local data storage and a sync api

-

Related tables!!!

Online features -

Wms/wmts/kml

-

Csv by ref

Runtime…………..

Summary info





Where to get more info -

Resource centre android/sdk

http://resources.arcgis.com/content/arcgis-

-

Blog http://blogs.esri.com/esri/arcgis/category/mobile/

-

Forum - http://forums.arcgis.com/forums/139-ArcGIS-Runtime-SDK-forAndroid

-

Last resort [email protected]

Where to get code -

We will post demo app to arcgis online android group shortly

-

http://www.arcgis.com/home/group.html?owner=willcrick&title=Android

Questions??



All yours….