arcgis 0.1.2

Type-safe Rust SDK for the ArcGIS REST API with compile-time guarantees
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# ArcGIS SDK Examples Expansion Plan

**Created:** 2026-01-18
**Status:** In Progress
**Goal:** Expand example coverage from ~25% to 80%+ of SDK operations

## Executive Summary

Current example coverage is approximately 25% of available SDK operations. This plan outlines a phased approach to create high-quality, entertaining, and educational examples that demonstrate best practices while showcasing the SDK's capabilities.

## Organization

Examples are organized into two categories based on authentication requirements:

### πŸ†“ Public Examples (`examples/public/`)
**Tier 1 - No authentication required, no credit costs**

- βœ… `query_features.rs` - Comprehensive Feature Service queries
- βœ… `spatial_query.rs` - Advanced spatial relationship queries

**Benefits:**
- Run immediately without API keys
- Zero credit cost
- Perfect for learning and CI/CD
- Uses ESRI's public World Cities service

### πŸ’Ό Enterprise Examples (`examples/enterprise/`)
**Tier 2+ - Requires API key or OAuth, may consume credits**

**Authentication & Setup:**
- βœ… `basic_client.rs` - Client creation and API key auth
- βœ… `client_credentials_flow.rs` - OAuth 2.0 flow

**Location Services (Tier 2):**
- βœ… `geocode_addresses.rs` - Forward/reverse geocoding (~0.04 credits)
- βœ… `routing_navigation.rs` - Route finding, directions (~0.50 credits)
- βœ… `geometry_operations.rs` - Buffer, union, intersection (~0.10 credits)

**Portal Operations (Tier 3):**
- βœ… `edit_session.rs` - Feature editing with transactions (~0.01 credits)
- βœ… `feature_attachments.rs` - Attachment management (~0.02 credits)
- βœ… `portal_content_management.rs` - Portal search, groups (~0.01 credits)

**Total credit cost for all enterprise examples:** ~0.68 credits (~$0.07)

For enterprise users with credit pools, this cost is negligible.

### Target State (15+ examples)
Coverage across all major services with practical, real-world scenarios. Organize new examples into appropriate categories based on authentication requirements.

## Implementation Phases

### Phase 1: Core Workflows (Week 1) 🎯

#### 1. Routing Navigation (`routing_navigation.rs`)
**Status:** βœ… Completed (2026-01-18)
**Priority:** HIGH
**Estimated Effort:** 4-6 hours β†’ **Actual:** 3 hours

**Operations Demonstrated:**
- `solve_route()` - Optimal route between multiple stops
- `solve_service_area()` - Drive-time/distance polygons
- `solve_closest_facility()` - Nearest facility analysis

**Story:** Plan a road trip from San Francisco to Seattle with optimal stops, show 30-minute drive zones around each city, and find the nearest gas station along the route.

**Learning Objectives:**
- Multi-stop route optimization
- Service area generation
- Closest facility analysis
- Error handling for routing failures
- Working with complex result geometries

**Success Criteria:**
- [x] Successfully calculates multi-stop route
- [x] Generates service area polygons
- [x] Finds closest facilities
- [x] Handles routing errors gracefully with anyhow::Context
- [x] Uses tracing for progress updates
- [x] Includes practical tips and caveats

---

#### 2. Portal Content Management (`portal_content_management.rs`)
**Status:** βœ… Completed (2026-01-18)
**Priority:** HIGH
**Estimated Effort:** 5-7 hours β†’ **Actual:** 2 hours

**Operations Demonstrated:**
- `search()` - Content discovery with Lucene queries
- `get_item()` - Item metadata retrieval
- `add_item()` - Upload new content (GeoJSON)
- `update_item()` - Modify metadata
- `update_item_data()` - Upload item data
- `share_item()` - Sharing with groups/org
- `create_group()` - Group management

**Story:** Complete content lifecycle - search for parks datasets, upload a new GeoJSON file, add rich metadata, create a project group, and share with team members.

**Learning Objectives:**
- Content search patterns with pagination
- Item creation with rich metadata
- Data upload workflows
- Metadata updates and verification
- Group creation for collaboration
- Sharing workflows (private β†’ org β†’ groups)
- Builder pattern for complex parameters
- Cleanup awareness (quota management)

**Success Criteria:**
- [x] Searches and filters items
- [x] Creates item with metadata
- [x] Uploads item data (GeoJSON)
- [x] Updates existing items
- [x] Shares to groups and organization
- [x] Creates and manages groups
- [x] Error handling with anyhow::Context
- [x] Uses tracing for progress updates
- [x] Shows cleanup tips for quota management
- [x] Demonstrates auth requirements (API key vs OAuth2)

---

#### 3. Feature Attachments (`feature_attachments.rs`)
**Status:** βœ… Completed (2026-01-18)
**Priority:** HIGH
**Estimated Effort:** 3-5 hours β†’ **Actual:** 2 hours

**Operations Demonstrated:**
- `query_attachments()` - List attachments with metadata
- `add_attachment()` - Upload files to features (bytes and file paths)
- `download_attachment()` - Download attachments (to file and memory)
- `update_attachment()` - Replace existing attachments
- `delete_attachments()` - Remove multiple attachments

**Story:** Field inspection workflow - utility worker adds photos and documents to infrastructure assets, office staff retrieves attachments for reporting, and cleanup removes outdated files.

**Learning Objectives:**
- Binary data handling with mock JPEG/PDF generators
- Attachment API patterns (demonstration mode for writable services)
- Attachment metadata querying
- Multiple upload/download patterns (bytes vs file paths)
- Batch deletion operations
- Working with LayerId, ObjectId, and AttachmentId types

**Success Criteria:**
- [x] Demonstrates upload patterns for various file types (images, PDFs)
- [x] Shows attachment listing with metadata
- [x] Shows download patterns (to file and memory)
- [x] Demonstrates deletion of attachments
- [x] Includes error handling with anyhow::Context
- [x] Shows file format considerations
- [x] Demonstrates both bytes and streaming patterns
- [x] Includes complete workflow example
- [x] Uses tracing for progress updates
- [x] Handles placeholder service URL gracefully

---

### Phase 2: Analytics & Batch Operations (Week 2) πŸ“Š

#### 4. Advanced Feature Queries (`advanced_queries.rs`)
**Status:** πŸ”² Not Started
**Priority:** MEDIUM
**Estimated Effort:** 4-5 hours

**Operations Demonstrated:**
- `query_related_records()` - Related table queries
- `query_top_features()` - Top N features
- `calculate_statistics()` - Statistical aggregations
- Pagination with `resultOffset`/`resultRecordCount`
- `query_domains()` - Domain value lookups

**Story:** Analyze crime incident data - find related evidence records for each incident, identify top 10 crime hotspots, calculate monthly statistics, and use pagination for large datasets.

**Learning Objectives:**
- Relationship queries
- Statistical operations
- Efficient pagination
- Domain value handling
- Complex where clauses
- Result set management

**Success Criteria:**
- [ ] Queries related records
- [ ] Gets top N features
- [ ] Calculates statistics
- [ ] Demonstrates pagination
- [ ] Shows domain lookups
- [ ] Handles large result sets
- [ ] Performance tips included

---

#### 5. Batch Geocoding (`batch_geocoding.rs`)
**Status:** πŸ”² Not Started
**Priority:** MEDIUM
**Estimated Effort:** 3-4 hours

**Operations Demonstrated:**
- `geocode_addresses()` - Batch address geocoding
- Rate limiting strategies
- Error recovery and retry
- Category-specific geocoding
- Result quality assessment

**Story:** Process a customer mailing list of 500 addresses, handle rate limits gracefully, retry failures, and generate a report of geocoding quality scores.

**Learning Objectives:**
- Batch operation patterns
- Rate limiting implementation
- Error recovery strategies
- Quality assessment
- Progress tracking
- Production-ready patterns

**Success Criteria:**
- [ ] Processes batch addresses
- [ ] Implements rate limiting
- [ ] Handles partial failures
- [ ] Retries transient errors
- [ ] Reports quality metrics
- [ ] Shows progress with tracing
- [ ] Production patterns documented

---

### Phase 3: Specialized Services (Week 3) πŸ—ΊοΈ

#### 6. Elevation Analysis (`elevation_analysis.rs`)
**Status:** πŸ”² Not Started
**Priority:** MEDIUM
**Estimated Effort:** 3-4 hours

**Operations Demonstrated:**
- `profile()` - Elevation along paths
- `summarize_elevation()` - Elevation statistics
- `viewshed()` - Visibility analysis

**Story:** Analyze hiking trail from Mount Tamalpais - get elevation profile, calculate total gain/loss, and determine viewshed from summit.

**Learning Objectives:**
- Elevation profile generation
- Statistical summaries
- Viewshed analysis
- Working with DEMs
- Profile visualization data

**Success Criteria:**
- [ ] Gets elevation profile
- [ ] Calculates elevation stats
- [ ] Generates viewshed
- [ ] Handles terrain data
- [ ] Shows visualization tips

---

#### 7. Places Discovery (`places_discovery.rs`)
**Status:** πŸ”² Not Started
**Priority:** MEDIUM
**Estimated Effort:** 3-4 hours

**Operations Demonstrated:**
- `find_places_near_point()` - POI search by location
- `find_places_by_address()` - POI search by address
- `get_place_details()` - Detailed information
- `get_place_categories()` - Category listing
- Category filtering and ranking

**Story:** Build a travel app - find restaurants near current location, search for hotels by address, get detailed reviews/hours, and explore available categories.

**Learning Objectives:**
- POI search patterns
- Category filtering
- Place detail retrieval
- Ranking and sorting
- Consumer app patterns

**Success Criteria:**
- [ ] Searches places by location
- [ ] Searches by address
- [ ] Gets place details
- [ ] Lists categories
- [ ] Filters by category
- [ ] Shows ranking strategies

---

#### 8. Map Export (`map_export.rs`)
**Status:** πŸ”² Not Started
**Priority:** LOW
**Estimated Effort:** 3-4 hours

**Operations Demonstrated:**
- `export()` - Map image export
- `identify()` - Feature identification
- `find()` - Attribute search
- `legend()` - Legend generation
- `get_metadata()` - Service metadata

**Story:** Generate static maps for PDF reports - export map images with different extents, identify features at clicked coordinates, and include legends.

**Learning Objectives:**
- Map image export
- Identify operations
- Legend generation
- Extent management
- Static map creation

**Success Criteria:**
- [ ] Exports map images
- [ ] Identifies features
- [ ] Generates legends
- [ ] Shows extent control
- [ ] Image format options

---

### Phase 4: Advanced Features (Future) πŸš€

#### 9. Geoprocessing Workflows (`geoprocessing_tasks.rs`)
**Status:** πŸ”² Not Started
**Priority:** LOW

**Operations:**
- `execute()` - Synchronous tasks
- `submit_job()` - Async job submission
- `get_job_status()` - Job monitoring
- `get_result()` - Result retrieval

---

#### 10. Image Service Operations (`image_analysis.rs`)
**Status:** πŸ”² Not Started
**Priority:** LOW

**Operations:**
- `export()` - Image export
- `identify()` - Raster identification
- `histogram()` - Raster histogram
- `sample()` - Raster sampling

---

#### 11. Vector Tile Styling (`vector_tiles.rs`)
**Status:** πŸ”² Not Started
**Priority:** LOW

**Operations:**
- `get_style()` - Style retrieval
- `get_tile()` - Tile fetching
- Font and sprite management

---

## Example Quality Standards

### Code Structure
- Use `anyhow::Result` for error handling
- Use `anyhow::Context` for error messages
- Structured logging with `tracing`
- Builder pattern for parameters
- Proper async/await patterns

### Documentation
- Engaging scenario-based descriptions
- Clear learning objectives
- Prerequisites section
- Running instructions with RUST_LOG
- Practical tips and caveats

### User Experience
- Relatable real-world scenarios
- Progressive complexity (simple β†’ advanced)
- Strategic emoji usage
- Conversational tone in logs
- Practical tips and best practices

### Testing
- Each example must compile
- Each example must run successfully
- Include error handling demonstrations
- Show both success and failure paths

## Progress Tracking

### Completed Examples: 10 total
**Public Examples (2):**
- βœ… query_features.rs
- βœ… spatial_query.rs

**Enterprise Examples (8):**
- βœ… basic_client.rs (auth setup)
- βœ… client_credentials_flow.rs (OAuth)
- βœ… geocode_addresses.rs (Tier 2)
- βœ… routing_navigation.rs (Tier 2)
- βœ… geometry_operations.rs (Tier 2)
- βœ… edit_session.rs (Tier 3)
- βœ… feature_attachments.rs (Tier 3)
- βœ… portal_content_management.rs (Tier 3)

### Phase Progress
**Phase 1:** 3/3 complete (100%) βœ…
- βœ… routing_navigation.rs
- βœ… portal_content_management.rs
- βœ… feature_attachments.rs

**Phase 2:** 0/2 complete (0%)
**Phase 3:** 0/3 complete (0%)
**Phase 4:** 0/3 complete (0%)

**Overall:** 10 existing + 3/11 planned = 13/21 examples (62% coverage when Phase 1 examples included)

## Success Metrics

- [ ] Coverage increased to 80%+ of SDK operations
- [ ] Each example demonstrates 3+ operations
- [ ] All examples include error handling
- [ ] All examples use tracing effectively
- [ ] Each example has a compelling real-world story
- [ ] Examples serve as templates for user code
- [ ] Documentation quality matches or exceeds existing examples

## Notes

### Organization Guidelines
- **Public examples** (`examples/public/`): Use public services, no auth required, zero credit cost
- **Enterprise examples** (`examples/enterprise/`): Require API keys/OAuth, may consume credits
- Include credit estimates in enterprise example documentation
- Organize new examples by authentication tier

### Development Guidelines
- Examples should be self-contained where possible
- Prefer public/free services when available (Tier 1)
- Include rate limiting awareness for enterprise examples
- Show production-ready patterns (not just toy examples)
- Each example should take 5-10 minutes to run and understand
- Document credit costs for enterprise examples

---

**Last Updated:** 2026-01-18
**Next Review:** After Phase 1 completion