Permalink
Browse files

added start of floor data

  • Loading branch information...
1 parent 996b1c6 commit bdd30291eed1ca3756ed0453d99c6d6d73dbd6bc @FarMcKon FarMcKon committed Jul 12, 2010
Showing with 41 additions and 136 deletions.
  1. +38 −7 python/FakeFloorData.py
  2. +3 −2 python/TestMatPlotLib.py
  3. +0 −127 ruby/lib/hopeapi.rb
View
45 python/FakeFloorData.py
@@ -1,16 +1,47 @@
+
+
+
+#data in Meters
floor_data = [
{
- "name" : "FarLand",
- "vertices": [[0, 0],[5, 0],[5,5],[2,6],[0,5]],
+ "name" : "Hammock Zone",
+ "vertices": [[0.0, 0.0],[51.58,0.0],[15.58,3.65],[0.0,3.65]],
"floor": 1
- },
- {
- "name" : "cptn_corner",
- "vertices": [[5, 0],[10, 0],[10,15],[5,10]],
+ "acces":"public"
+},
+{
+ "name" : "Low Power Zone",
+ "vertices": [[0.0, 3.65],[15.58,3.65],[15.58,7.27],[0.0,7.24]],
"floor": 1
- }
+ "acces":"public"
+},
+{
+ "name" : "untitled 1",
+ "vertices": [[19.81, 3.65],[22.76,3.65],[22.76,6.24],[19.81,6.24]],
+ "floor": 1
+ "acces":"public"
+},
+{
+ "name" : "Art Space 2",
+ "vertices": [[0.0, 7.24],[15.58,7.24],[15.58,10.74],[0.0,10.74]],
+ "floor": 1
+ "acces":"public"
+},
+{
+ "name" : "Interview Area",
+ "vertices": [[0.0, 10.74],[4.34,10.74],[4.34,13.96],[0.0,=13.96]],
+ "floor": 1
+ "acces":"limited"
+}
+{
+ "name" : "Keynote Bullpen",
+ "vertices": [[0.0, 10.74],[4.34,10.74],[4.34,13.96],[0.0,=13.96]],
+ "floor": 1
+ "acces":"limited"
+}
+
]
View
5 python/TestMatPlotLib.py
@@ -8,7 +8,8 @@
#HACK: since floor data is NOT AVAILABLE, I'm creating floor data
#here as a static string.
-from FakeFloorData import floor_data, FloorTest
+from FakeFloorData import floor_data
+from Floor import TestFloor
hacky_scale_factor = 20.0
@@ -64,7 +65,7 @@ def draw(self, renderer):
fig = plt.figure()
ax = fig.add_subplot(111)
-floor = FloorTest(floor_data)
+floor = TestFloor(floor_data)
floorBoundaries = floor.bounds()
line = TestRoom(floor_data, mfc='red', ms=12, label='line label')
#line.text.set_text('line label')
View
127 ruby/lib/hopeapi.rb
@@ -1,127 +0,0 @@
-require 'rubygems'
-require 'uri'
-require 'cgi'
-require 'curb'
-require 'json'
-
-module HopeAPI
- FEED_URI = "http://api.hope.net"
-
- # various feed structs
- Speaker = Struct.new(:name, :bio)
- Location = Struct.new(:area, :time, :x, :y, :user, :button)
- Talk = Struct.new(:speakers, :title, :abstract, :time, :track, :interests)
- User = Struct.new(:name, :x, :y, :interests)
-
- # TODO worth it to enumerate?
- INTERESTS = [
- "tech",
- "activism",
- "radio",
- "lockpicking",
- "crypto",
- "privacy",
- "ethics",
- "telephones",
- "social engineering",
- "hacker spaces",
- "hardware hacking",
- "nostalgia",
- "communities",
- "science",
- "government",
- "network security",
- "malicious software",
- "pen testing",
- "web",
- "niche hacks",
- "media"
- ]
-
- def self.get_full_uri(type)
- # XXX cheating!
- URI.parse([FEED_URI, 'api', type].join('/') + '/')
- end
-
- #
- # args are the GET parameters. use the force.
- #
- def self.make_request(type, args={})
- # Mocked out map request till it's implemented.
- if (type == 'map')
- return [{
- :name => "FarLand",
- :vertices => [[0, 0],[50, 0],[50,50],[20,60],[0,50]],
- :floor => 1
- },
- {
- :name => "cptn_corner",
- :vertices => [[50, 0],[100, 0],[100,100],[50,100]],
- :floor => 1
- }
- ]
- end
-
- uri = get_full_uri(type)
- # XXX totally broken for dupe keys, but meh. Ruby's HTTP clients blow.
- uri.query = args.keys.map { |key| CGI.escape("#{key}=#{args[key]}") }.join(';')
-
- resp = Curl::Easy.http_get(uri.to_s)
-
- unless resp.response_code == 200
- raise "Response #{resp.response_code} received"
- end
-
- # API improperly yields text/plain, so we run with that case.
- unless resp.content_type == "text/plain" or resp.content_type == "application/json"
- raise "Invalid content type: #{resp.content_type}"
- end
-
- return JSON.load(resp.body_str)
- end
-
- # see above
- def self.to_ruby(type, args={ })
- type = type.to_s
-
- data = make_request(type, args)
-
- # special case for interests
- return data if type == 'interests'
-
- # XXX moar cheating
- const_type = type.gsub(/s$/, '')
- struct_klass = const_get(const_type.capitalize)
-
- raise "not a valid type" unless struct_klass
-
- results = []
-
- if type == "users" or type == "speakers"
- data = data.map { |x| x[1] }
- end
-
- data.each do |item|
- s = struct_klass.new
- item.keys.each do |key|
- s[key] = item[key]
- end
-
- results.push(s)
- end
-
- return results
- end
-end
-
-if __FILE__ == $0
- %w[
- locations
- interests
- users
- speakers
- talks
- ].each do |type|
- p HopeAPI.to_ruby(type)
- end
-end

0 comments on commit bdd3029

Please sign in to comment.