building interactive web apps using the arcgis api for javascript … · 2018-04-02 · geometry...

33
Building Interactive Web Apps Using the JavaScript API's Geometry Engine Kristian Ekenes, David Bayer

Upload: others

Post on 03-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Building Interactive Web

Apps Using the JavaScript

API's Geometry EngineKristian Ekenes, David Bayer

Page 2: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Session Goals

• Overview of the Geometry Engine- Available operations

• Coding with the Geometry Engine- How to use the Geometry Engine

• Geometry Engine Internals- Sync/Async Architecture

• When to use the Geometry Engine- When does it make a difference?

Page 3: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Points, lines, polygons, multipoints…

Geometry

Page 4: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Operations: Geometry Operations

Overlaps

Crosses

Intersects

EqualsWithin

Touches

Page 5: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Union

Intersection

Symmetric Difference

Clip

Operations: Overlay

Page 6: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Operations: Topological correctness

Simplify isSimple

Page 7: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Operations: Nearest vertices/coordinates

Page 8: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

• geodesicLength

• planarLength

• geodesicArea

• planarArea

Operations: Measurement

Page 9: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Operations: Buffering

Planar and Geodesic Buffering

Page 10: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

• Generalize

• Densify

• ConvexHull

• Rotate

• Flip

Other Operations

geodesicDensify

Page 11: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

It’s called the Geometry Service!

I can do this already…

Page 12: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

User Experience: Interactivity

Geometry Service REST Call

Encoding Geometry as JSON

5ms

Sending Request over Network

200+ ms

Running Geometry Operation

100+ ms

Sending Response back over Network

200+ ms

DecodingResponse

5ms

Page 13: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

User Experience: Interactivity

Geometry Engine API Call

Running Geometry Operation

200+ ms

Page 14: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

How many REST calls can I save?

Demo

Page 15: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Writing Apps with Geometry Engine

Page 16: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Geometry Engine : Writing Code

Calling the methods

require( [ “esri/geometry/geometryEngine” ],

function( geometryEngine ) {

var buffer = geometryEngine.buffer(mapPoint, 10, “miles”);

});

Page 17: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Geometry Service : Code Comparison

require( [ “esri/tasks/GeometryService”, “esri/tasks/BufferParameters” ],

function( GeometryService, BufferParameters ) {

var geomService = new GeometryService("//.../GeometryServer");

var bufferParams = new BufferParameters();

bufferParams.geometries = [mapPoint]

bufferParams.distances = [10]

bufferParams.unit = GeometryService.UNIT_MILE;

bufferParams.outSpatialReference = map.spatialReference;

geomService.buffer( bufferParams, function(buffer) {

});

});

Page 18: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Building Editing Apps

Page 19: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Building Analysis Apps

Page 20: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

You can use Geometry Engine Async

Synchronous versus Asynchronous

Page 21: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Geometry Engine Async

• Asynchronous Geometry Engine

- Uses Web Workers to perform Geometry Engine

- Operations return Promises.

• Benefits

- Browser is not blocked whilst operations run

- Greater throughput. Operations can run in parallel

- Easier substitution of existing GeometryService code

• Drawbacks

- Older Browsers do not support WebWorkers

Page 22: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Asynchronous Patterns• Uses Deferred Pattern

require( [ “esri/geometry/geometryEngineAsync” ],

function( geometryEngineAsync ) {

geometryEngineAsync.buffer(mapPoint, 10, “miles”).then( function(buffer) {

},

function(err) {

});

});

Page 23: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

What is the Geometry Engine doing for me!

Geometry Engine internals

Page 24: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Spatial Tolerance

XY Tolerance = 0.001

Spatial References have different Tolerances.

GeometryEngine uses X/Y Tolerance

in its calculations

Page 25: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Spatial ToleranceInside the Geometry Methods

require( [ “esri/geometry/geometryEngine” ],

function( geometryEngine ) {

var mapPointA = new esriPoint(1.22, 2.0, map.spatialReference)

var mapPointB = new esriPoint(1.22000000001, 2.0, map.spatialReference)

var areequal = geometryEngine.equals(mapPointA, mapPointB);

// Returns True

});

Page 26: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Geometry Engine AsyncArchitecture and Throughput

Web

Worker

Web

Worker

Web

Worker

Web

Worker

Web

Worker

Queued Geometry Operations

FreeBusyBusyBusyBusy

WebWorker

SendMessage

geometryEngine

Async

buffer

Deferred

Resovled

Page 27: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Coordinate Systems

• No Project Operation

• Certain methods will only work in WebMercator or

Geographic Coordinate Systems

- GeodesicArea

- GeodesicLength

- GeodesicBuffer

• Projected and Geographic

Page 28: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

When will it make a difference in my app

When to use the Geometry Engine

Page 29: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Geometry Engine: Trade-offs

• Trade-off between Geometry Service and Geometry Engine

- Large AMD download for Geometry Engine

versus

- Network latency and round trip cost of Geometry Service

• Other Considerations: Apps Requirements

- Unsupported operations : projections

- Frequency of calls : user interactivity

- Offline or poor network connection

- Ease of coding

Page 30: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Documentation, Blogs, Samples

GeometryEngineResources

Page 31: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Resources

• Documentation

- https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-

geometryEngine.html

- https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-

geometryEngineAsync.html

• Blogs

- Testing spatial relationships and editing

- Measurement

- Overlay analysis

• Demos/samples

- https://github.com/ekenes/conferences/tree/master/ds-2017/geometry-engine

- https://github.com/ekenes/esri-js-samples

Page 32: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry

Please Take Our Survey!

Download the Esri Events app

and go to DevSummit

Select the session you attended

Scroll down to the

“Feedback” section

Complete Answers,

add a Comment,

and Select “Submit”

Page 33: Building Interactive Web Apps Using the ArcGIS API for JavaScript … · 2018-04-02 · Geometry Engine Async •Asynchronous Geometry Engine-Uses Web Workers to perform Geometry