Permalink
Browse files

levels

  • Loading branch information...
1 parent 75c8462 commit 4f3785cd477a172cc3931a1ffeacbae3fde3379e @pghodgman committed Sep 23, 2013
View
@@ -47,6 +47,9 @@
<orderEntry type="library" scope="PROVIDED" name="rack-protection (v1.5.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.2, RVM: ruby-2.0.0-p247) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v4.0.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rails_12factor (v0.0.2, RVM: ruby-2.0.0-p247) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rails_serve_static_assets (v0.0.1, RVM: ruby-2.0.0-p247) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rails_stdout_logging (v0.0.2, RVM: ruby-2.0.0-p247) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v4.0.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v10.1.0, RVM: ruby-2.0.0-p247) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="redis (v3.0.4, RVM: ruby-2.0.0-p247) [gem]" level="application" />
View
Oops, something went wrong.
@@ -11,6 +11,9 @@ def bodies
def location
render json: Model.find(params[:id]).location, :except=> [:image]
end
+ def levels
+ render json: Model.find(params[:id]).levels, :except=> [:uuid]
+ end
def preview
model = Model.find(params[:id])
send_data model.preview, :type => 'image/png',:disposition => 'inline'
View
@@ -20,6 +20,7 @@ def self.process(model_filename)
get_location(model, model_file, directory['IMAG'])
get_preview(model, model_file, directory['PRVW'])
get_meta(model, model_file, directory['META'])
+ get_levels(model, model_file, directory['LEVS'])
end
@@ -202,5 +203,39 @@ def self.get_meta(model, model_file, offset)
model.save
end
+ def self.get_levels(model, model_file, offset)
+ model_file.seek(offset, IO::SEEK_SET)
+
+ block_id = model_file.read(4).unpack("L").first
+ version = model_file.read(4).unpack("L").first
+ size = model_file.read(4).unpack("L").first
+ cksum = model_file.read(4).unpack("L").first
+
+ num_levels = model_file.read(4).unpack("L").first
+
+ num_levels.times do |n|
+ # skip header
+ model_file.read(16)
+
+ # level
+ uuid = model_file.read(16)
+ elevation = model_file.read(8).unpack("D").first
+ namesize = model_file.read(4).unpack("L").first
+ name = model_file.read(namesize)
+
+ level = Level.new
+ level.uuid = uuid
+ level.elevation = elevation
+ level.name = name
+ level.model = model
+ level.save
+
+
+ end
+
+
+ end
+
+
end
View
@@ -0,0 +1,3 @@
+class BodyLevel < ActiveRecord::Base
+ belongs_to :body
+end
View
@@ -0,0 +1,3 @@
+class Level < ActiveRecord::Base
+ belongs_to :model
+end
View
@@ -1,4 +1,5 @@
class Model < ActiveRecord::Base
has_many :bodies
has_one :location
+ has_many :levels
end
View
@@ -8,6 +8,7 @@
get 'models/:id/bodies' => 'models#bodies'
get 'models/:id/location' => 'models#location'
get 'models/:id/preview' => 'models#preview'
+ get 'models/:id/levels' => 'models#levels'
get 'bodies' => 'bodies#all'
@@ -0,0 +1,11 @@
+class CreateLevels < ActiveRecord::Migration
+ def change
+ create_table :levels do |t|
+ t.string :uuid
+ t.float :elevation
+ t.string :name
+
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,5 @@
+class AddModelIdToLevel < ActiveRecord::Migration
+ def change
+ add_column :levels, "model_id", :integer
+ end
+end
@@ -0,0 +1,7 @@
+class RemoveStringUuid < ActiveRecord::Migration
+ def change
+ def change
+ remove_column :levels, "uuid", :string
+ end
+ end
+end
@@ -0,0 +1,5 @@
+class RemoveUuid < ActiveRecord::Migration
+ def change
+ remove_column :levels, :uuid
+ end
+end
@@ -0,0 +1,5 @@
+class AddUuidBinary < ActiveRecord::Migration
+ def change
+ add_column :levels, :uuid, :binary
+ end
+end
@@ -0,0 +1,10 @@
+class CreateBLevels < ActiveRecord::Migration
+ def change
+ create_table :b_levels do |t|
+ t.string :name
+ t.binary :uuid
+
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,10 @@
+class CreateBodyLevels < ActiveRecord::Migration
+ def change
+ create_table :body_levels do |t|
+ t.string :name
+ t.binary :uuid
+
+ t.timestamps
+ end
+ end
+end
View
@@ -11,7 +11,14 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20130915143011) do
+ActiveRecord::Schema.define(version: 20130923010804) do
+
+ create_table "b_levels", force: true do |t|
+ t.string "name"
+ t.binary "uuid"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "bodies", force: true do |t|
t.binary "data"
@@ -22,6 +29,22 @@
t.integer "model_id"
end
+ create_table "body_levels", force: true do |t|
+ t.string "name"
+ t.binary "uuid"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "levels", force: true do |t|
+ t.float "elevation"
+ t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "model_id"
+ t.binary "uuid"
+ end
+
create_table "locations", force: true do |t|
t.binary "image"
t.float "latitude"
View
Binary file not shown.
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ uuid:
+
+two:
+ name: MyString
+ uuid:
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ uuid:
+
+two:
+ name: MyString
+ uuid:
View
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ uuid: MyString
+ elevation: 1.5
+ name: MyString
+
+two:
+ uuid: MyString
+ elevation: 1.5
+ name: MyString
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class BLevelTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class BodyLevelTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LevelTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end

0 comments on commit 4f3785c

Please sign in to comment.