Using ArcGIS Server with Ruby on Rails

5,098 views
4,832 views

Published on

Slides to go with my 2010 ESRI Developer Summit talk on using Ruby on Rails with ArcGIS Server. View the application at http://agsruby.heroku.com and download the source code from http://github.com/dbouwman/agsruby

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,098
On SlideShare
0
From Embeds
0
Number of Embeds
180
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Using ArcGIS Server with Ruby on Rails

  1. 1. Ruby-Fu! http://www.flickr.com/photos/jackbrodus/258077303
  2. 2. Why Ruby On Rails?
  3. 3. http://www.flickr.com/photos/pagedooley/2511369048
  4. 4. Cloud-Friendly Open Source Ruby on Rails Fee, Turner and Mac. http://www.flickr.com/photos/wwarby/2989238425/
  5. 5. (Cheezburger)
  6. 6. (Rails Hipster) (Cheezburger)
  7. 7. Not Ruby 101…
  8. 8. just a quick history…
  9. 9. why’s (poignant) guide to ruby
  10. 10. “matz” (not-“matz”) http://mauthesis.com/me_and_matz1.jpg
  11. 11. The “dhh” http://www.flickr.com/photos/jackbrodus/258077303
  12. 12. convention over configuration
  13. 13. mad unit testing scaffolding db migrations tons of libraries
  14. 14. Rails Apps Now! http://www.flickr.com/photos/thedalogs/3302704209
  15. 15. Research Project Parcel Information App Search for Parcel Parcel Detail with Map Use ArcGIS Online
  16. 16. http://agsruby.heroku.com
  17. 17. Baking the Cake http://www.flickr.com/photos/veganfeast/3845912356
  18. 18. Tooling http://www.flickr.com/photos/denisecarbonell/3923601326
  19. 19. http://www.flickr.com/photos/ckelly/2693315769
  20. 20. TextMate on Mac http://www.flickr.com/photos/m_uhlig/3556705107
  21. 21. RadRails on Windows
  22. 22. Fiddler
  23. 23. SoapUI
  24. 24. Ingredients http://www.flickr.com/photos/vmiramontes/4073518788
  25. 25. ArcServer.rb
  26. 26. ArcServer.rb
  27. 27. gem install httparty gem install handsoap gem install shoulda gem install mocha gem install httpclient gem install json gem install test-unit gem install nokogiri
  28. 28. Implemented Not Implemented SOAP & REST API’s
  29. 29. REST SOAP ExportMap Get Default Map Name Get Legend Info
  30. 30. Cucumber http://www.flickr.com/photos/derekgavey/4245269567
  31. 31. Gherkin
  32. 32. Gherkinz
  33. 33. Enuf! Show meh teh codez nao! http://www.flickr.com/photos/kwl/4116389731
  34. 34. App Post to Search (Ajax request) REST API Query Resutls.rjs
  35. 35. Controllers Views Home Home Request Routing Response Results Parcel Detail lib
  36. 36. require 'arcserver' require 'json class HomeController < ApplicationController #Show the index page def index end #Show the about page def about end def search @searchType = params[:search_type] @searchCriteria = params[:search_criteria].upcase #calls to arcserver.rb to collect data and return to view end end
  37. 37. require 'arcserver' require 'json' class ParcelController < ApplicationController def index @taxid = params[:id] #calls to arcserver.rb to collect data and return to view end end
  38. 38. REST (kitteh) API http://www.flickr.com/photos/pagedooley/4310765089
  39. 39. REST Query def query(layerId, opts = {}) query ={ :f => opts[:f] || :json, :where => opts[:where], :returnGeometry => opts[:returnGeometry], :outFields => opts[:outFields]} HTTParty.get("#{url}/#{layerId}/query", :query => query) end
  40. 40. def search @searchType = params[:search_type] @searchCriteria = params[:search_criteria].upcase service = ArcServer::MapServer.new('http://sampleserver1.arcgisonline @jsonString = service.query(1, {:where=>"#{@searchType} like '%#{@searchCriteria}%'", :outFields=>'TLID, OWNER1,OWNER2,OWNER3,SITEADDR' }) @json = JSON.parse(@jsonString) @results = @json['features'] if @results.nil? || @results.length == 0 flash[:notice] = 'No results found for search ' + @searchCriteria + ' Please try another search.' end respond_to do |format| format.js #  Search.js.rjs  _results.html.erb end Usage end
  41. 41. http://www.flickr.com/photos/soundfromwayout/143822346
  42. 42. Accessing the SOAP API http://www.flickr.com/photos/fdecomite/2867929299
  43. 43. Ruby Hates SOAP. It’s a Fact. http://www.flickr.com/photos/ennuidesign/3023015424
  44. 44. soap4r WSDL savon handsoap ~ XML http://www.flickr.com/photos/fdecomite/2867929299
  45. 45. Documentation Assumes Proxy
  46. 46. SoapUI!
  47. 47. Strip it down…
  48. 48. XML Ruby
  49. 49. Argggh! How Can I debug this!!
  50. 50. Unit Tests C:hacking> ruby map_server_soap_test.rb
  51. 51. Edit Request Compare w/ Good Run test Req Copy View request error to SoapUI
  52. 52. Data
  53. 53. Nested Hashes
  54. 54. Nested Hashes
  55. 55. Deployment
  56. 56. #add changes git add . #commit git commit -m "the message" #push to heroku git push heroku master #crack beer.
  57. 57. src: http://github.com/dbouwman/agsruby demo app: http://agsruby.heroku.com contact: dave@davebouwman.com
  58. 58. Conclusions:
  59. 59. I’s a n00b at teh rubees!!!!
  60. 60. Rails + REST API = ‘OK’
  61. 61. Rails + SOAP API = ‘uggh’ http://www.flickr.com/photos/fdecomite/2867929299
  62. 62. Ruby & Rails vs. .NET?
  63. 63. Waaaaaaaaaay better than webforms
  64. 64. Slightly less work than MVC
  65. 65. Never underestimate the power of a good proxy!
  66. 66. Questions? http://www.flickr.com/photos/seannaber/4044012656

×