ArcGIS and Ruby: Making Web Development Fun and Easy





Jason Wieringa

Goals




  • Try Ruby
  • Show some libraries that DC team uses

Where is IT Used?



  • Github
  • Esri Portland
  • Open Street Maps
  • Esri DC
  • Living Social

Community



  • User Groups
  • Online Chat (IRC)
  • So many Books!
  • So many tutorials!


Everything is Class


Including Numbers!


irb(main):001:0> 5.class
=> Fixnum

Flexibility

(example from ruby-lang.org)


class Fixnum
  def plus(x)
    self.+(x)
  end
end

Blocks


# Traditional
array = [1,2,3,4]
array.reverse!
array

# With a Block
[1,2,3,4].tap do |array|
  array.reverse!
end

More Blocks




[1, 2, 3, 4, 5, 6].select {|num| num % 2 == 0 }.map {|num| num * 2 }
=> [4, 8, 12]

And More blocks!


class Person
  attr_accessor :first_name

  def initialize(name)
    @first_name = name
  end
end

people = []
people << Person.new("jason")
people << Person.new("catherine")
people << Person.new("don")

people.each do |person|
  puts person.first_name
end



Libraries

RubyGEMS.org



Gems are packages of  Ruby that are easily distributable. The Ruby community shares these packages on Rubygems.org.

How Esri DC R&D Uses Ruby


How DC uses Ruby


  • Talking with ArcGIS Online (Chain)
  • Web applications (Rails)
  • Data processing (ffi-ogr)

Talking to The Web

class Agol
  attr_accessor :online

  def initialize(url)
    @online = Chain::Url.new(url)
  end

end

agol = Agol.new("https://www.arcgis.com")


# Search Arcgis Online for groups with the term epa
agol.online.sharing.rest.community.groups[f: 'json', q:'epa']

agol.online.sharing.rest.community.users['jwieringa_dcdev'][f: 'json']

# Search Arcgis Online for my groups (requires a token for full results)
# agol.online.sharing.rest.community.users[jwieringa_dcdev][f: 'json', token: token].groups

More Chain


(Not real!!)
def search_groups(params)
  arcgis_online.sharing.rest.community.groups(q:'epa', f: 'json', num: 100)).results
end

def my_groups
  arcgis_online.sharing.rest.community.users[username][f: 'json', token: token].groups
end

def org_and_my_groups(params)
  search_groups(params).concat(my_groups).uniq(&:id)
end

Links



Resources



Thank YOu



jwieringa@esri.com
@jwieringa








Esri DC R&D
Made with Slides.com