Skip to content

Commit

Permalink
Reverts some geo stuff. Adds some gems.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjy committed Mar 6, 2014
1 parent 5a5cc9d commit 2b80895
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 17 deletions.
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ gem 'pg', '~> 0.17.0'

# Postgis
gem 'activerecord-postgis-adapter'
# gem 'rgeo-activerecord'
# gem 'activerecord-spatial'
gem 'squeel'

# rgeo support
gem 'ffi-geos'
gem 'rgeo-shapefile'
gem 'rgeo-geojson'
gem 'rgeo-activerecord'
# gem 'activerecord-spatial'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0'
Expand Down Expand Up @@ -69,6 +70,7 @@ gem 'rabl'

group :test, :development do
gem 'rspec-rails'
gem 'byebug'
gem 'debugger', {}.merge(ENV['RM_INFO'] ? {require: false} : {})
gem 'awesome_print'
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/biocuration_classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class BiocurationClassification < ActiveRecord::Base
include Housekeeping

belongs_to :biocuration_class
belongs_to :biological_collection_object
belongs_to :biological_collection_object, class_name: 'CollectionObject::BiologicalCollectionObject'

validates_presence_of :biocuration_class, :biological_collection_object

Expand Down
24 changes: 17 additions & 7 deletions app/models/geographic_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class GeographicItem < ActiveRecord::Base
# RGeo::Geos.preferred_native_interface = :ffi
# RGeo::ActiveRecord::GeometryMixin.set_json_generator(:geojson)

include RGeo::ActiveRecord

include Housekeeping::Users
# include ActiveRecordSpatial::SpatialColumns
# include ActiveRecordSpatial::SpatialScopes
Expand All @@ -17,13 +19,11 @@ class GeographicItem < ActiveRecord::Base
:multi_polygon,
:geometry_collection]


column_factory = RGeo::Geos.factory(
native_interface: :ffi,
srid: 4326,
has_z_coordinate: true,
has_m_coordinate: false)

# column_factory = RGeo::Geos.factory(
# native_interface: :ffi,
# srid: 4326,
# has_z_coordinate: true,
# has_m_coordinate: false)

column_factory = Georeference::FACTORY

Expand All @@ -38,6 +38,16 @@ class GeographicItem < ActiveRecord::Base

validate :proper_data_is_provided


# FactoryGirl.create(:valid_geographic_item)
# FactoryGirl.create(:valid_geographic_item)
# FactoryGirl.create(:valid_geographic_item)
# p = GeographicItem.first.geo_object
#
# GeographicItem.where{st_intersects(point, p)}.count

# The last {} bit comes from Squeel and see bottom of https://github.com/neighborland/activerecord-postgis-adapter/blob/master/Documentation.rdoc

scope :intersecting_boxes, -> (geographic_item) {
select("ST_Contains(geographic_items.polygon, #{geographic_item.geo_object})",
) }
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20140303225547_drop_biocuration_class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DropBiocurationClass < ActiveRecord::Migration
def change
drop_table :biocuration_classes
end
end
6 changes: 1 addition & 5 deletions lib/material.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ def self.create_quick_verbatim(options = {})
object = stub_object.clone
object.total = opts[:collection_objects][o][:total]

foo = 2

if opts[:collection_objects][o][:biocuration_classes]

object.biocuration_classes << BiocurationClass.find(opts[:collection_objects][o][:biocuration_classes])
end

i += 1

# byebug
object.notes << note.clone if note
object.container = container if container
response.collection_objects.push object
Expand Down
1 change: 1 addition & 0 deletions lib/taxonworks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module TaxonWorks
Dir[Rails.root.to_s + '/app/models/container/**/*.rb'].sort.each {|file| require file }
require 'soft_validation'
require 'activerecord_utilities'
require 'squeel'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :collection_object_biological_collection_object, class: 'CollectionObject::BiologicalCollectionObject', traits: [:housekeeping] do
factory :valid_collection_object_biological_collection_object do
type 'Specimen'
total 1
end
end
end
4 changes: 2 additions & 2 deletions spec/lib/material_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
@two_objects_stub[:collection_objects][:object2][:biocuration_classes] = [attribute1.id, attribute4.id]

response = Material.create_quick_verbatim(@two_objects_stub)
expect(response.collection_objects.first.biocuration_classifications).to have(4).things
expect(response.collection_objects.last.biocuration_classifications).to have(2).things
expect(response.collection_objects.first.biocuration_classes).to have(4).things
expect(response.collection_objects.last.biocuration_classes).to have(2).things
end

end
Expand Down

0 comments on commit 2b80895

Please sign in to comment.