Skip to content

Commit

Permalink
collecting_event.geolocate_ui_params_hash from lat/long.
Browse files Browse the repository at this point in the history
  • Loading branch information
TuckerJD committed Nov 24, 2014
1 parent 5993536 commit cd57599
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 23 deletions.
9 changes: 4 additions & 5 deletions app/models/collecting_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,6 @@ def county_name
=end

def geolocate_ui_params_hash

end

def geolocate_ui_params_string
parameters = {}

parameters[:country] = country_name
Expand All @@ -382,7 +378,7 @@ def geolocate_ui_params_string
unless georeferences.count == 0
unless georeferences.first.error_geographic_item.nil?
# expecting error_geographic_item to be a polygon or multi_polygon
focus = georeferences.first.error_geographic_item.centroid
focus = georeferences.first.error_geographic_item.st_centroid
end
unless georeferences.first.geographic_item.nil?
# the georeferences.first.geographic_item for a verbatim_data instance is a point
Expand All @@ -397,6 +393,9 @@ def geolocate_ui_params_string
Georeference::GeoLocate::RequestUI.new(parameters).request_params
end

def geolocate_ui_params_string
end

# class methods

def self.excluding(collecting_events)
Expand Down
53 changes: 45 additions & 8 deletions spec/models/collecting_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

context 'and that GR has some combination of GIs, and EGIs' do
specify 'that the count of which can be found' do
pending 'fixing the bug in all_geographic_items' # todo: @mjy
pending 'fixing the bug in all_geographic_items' # todo: @mjy
# @ce_p5 has two GRs, each of which has a GI.
expect(@ce_p5.all_geographic_items.count).to eq(2)
# @ce_p8 has two GRs, one of which has only a GI, and the other of which
Expand Down Expand Up @@ -265,7 +265,7 @@

context 'geolocate responses from collecting_event' do
before(:all) {
generate_political_areas
generate_political_areas_with_collecting_events
}
after(:all) {
Georeference.destroy_all
Expand All @@ -278,25 +278,62 @@

specify 'geolocate_ui_params_hash from locality' do
pending 'creation of a method for geolocate_ui_params_hash'
expect(@ce.p1.geolocate_ui_params_hash).to eq({})
expect(@ce_n3.geolocate_ui_params_hash).to eq({:country => "Big Boxia",
:state => "T",
:county => "M1",
:locality => nil,
:Latitude => 27.5,
:Longitude => 33.5,
:Placename => nil,
:Score => "0",
:Uncertainty => "3",
:H20 => "false",
:HwyX => "false",
:Uncert => "true",
:Poly => "true",
:DisplacePoly => "false",
:RestrictAdmin => "false",
:BG => "false",
:LanguageIndex => "0",
:gc => "Tester"
})
end

specify 'geolocate_ui_params_hash from lat/long' do
pending 'creation of a method for geolocate_ui_params_hash'
expect(@ce.p1.geolocate_ui_params_hash).to eq({})
# pending 'creation of a method for geolocate_ui_params_hash'
# @ce_m1.georeference was built from verbatim data
expect(@ce_m1.geolocate_ui_params_hash).to eq({:country => "Big Boxia",
:state => "T",
:county => "M1",
:locality => nil,
:Latitude => 27.5,
:Longitude => 33.5,
:Placename => nil,
:Score => "0",
:Uncertainty => "3",
:H20 => "false",
:HwyX => "false",
:Uncert => "true",
:Poly => "true",
:DisplacePoly => "false",
:RestrictAdmin => "false",
:BG => "false",
:LanguageIndex => "0",
:gc => "Tester"
})
end
end

context 'geolocate_ui_params_string' do

specify 'geolocate_ui_params_string from locality' do
pending 'creation of a method for geolocate_ui_params_string'
expect(@ce.p1.geolocate_ui_params_hash).to eq('')
expect(@ce_m1.geolocate_ui_params_hash).to eq('')
end

specify 'geolocate_ui_params_string from lat/long' do
pending 'creation of a method for geolocate_ui_params_string'
expect(@ce.p1.geolocate_ui_params_hash).to eq('')
expect(@ce_m1.geolocate_ui_params_hash).to eq('')
end
end
end
Expand Down Expand Up @@ -343,7 +380,7 @@
context 'geopolitical labels' do
before(:all) {
# create some bogus countries, states, provinces, counties, and a parish
generate_political_areas
generate_political_areas_with_collecting_events
#
# The idea:
# - geopolitical names all come from GeographicArea, as classified by GeographicAreaType
Expand Down
30 changes: 20 additions & 10 deletions spec/support/geo/geo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def gen_wkt_files()
f_poly.close
end

def generate_political_areas
def generate_political_areas_with_collecting_events
#
# 4 by 4 matrix of squares:
=begin
Expand Down Expand Up @@ -1029,43 +1029,49 @@ def generate_political_areas
:name => 'Great Northern Land Mass',
:geographic_area_type => gat_land_mass,
:iso_3166_a3 => nil,
:iso_3166_a2 => nil)
:iso_3166_a2 => nil,
:parent => @earth)
@area_land_mass.geographic_items << @item_w
@area_land_mass.save

@area_old_boxia = FactoryGirl.build(:level0_geographic_area,
:name => 'Old Boxia',
:geographic_area_type => gat_country,
:iso_3166_a3 => nil,
:iso_3166_a2 => nil)
:iso_3166_a2 => nil,
:parent => @area_land_mass)
@area_old_boxia.geographic_items << @item_ob
@area_old_boxia.save
@area_big_boxia = FactoryGirl.build(:level0_geographic_area,
:name => 'Big Boxia',
:geographic_area_type => gat_country,
:iso_3166_a3 => nil,
:iso_3166_a2 => nil)
:iso_3166_a2 => nil,
:parent => @area_land_mass)
@area_big_boxia.geographic_items << @item_bb
@area_big_boxia.save
@area_q = FactoryGirl.build(:level0_geographic_area,
:name => 'Q',
:geographic_area_type => gat_country,
:iso_3166_a3 => 'QQQ',
:iso_3166_a2 => 'QQ')
:iso_3166_a2 => 'QQ',
:parent => @area_land_mass)
@area_q.geographic_items << @item_q
@area_q.save
@area_east_boxia_1 = FactoryGirl.build(:level0_geographic_area,
:name => 'East Boxia',
:geographic_area_type => gat_country,
:iso_3166_a3 => 'EB1',
:iso_3166_a2 => nil)
:iso_3166_a2 => nil,
:parent => @area_land_mass)
@area_east_boxia_1.geographic_items << @item_eb_1
@area_east_boxia_1.save
@area_east_boxia_2 = FactoryGirl.build(:level0_geographic_area,
:name => 'East Boxia',
:geographic_area_type => gat_country,
:iso_3166_a3 => 'EB2',
:iso_3166_a2 => nil)
:iso_3166_a2 => nil,
:parent => @area_land_mass)
@area_east_boxia_2.geographic_items << @item_eb_2
@area_east_boxia_2.save
@area_east_boxia_3 = FactoryGirl.build(:level1_geographic_area,
Expand All @@ -1080,7 +1086,8 @@ def generate_political_areas
:name => 'West Boxia',
:geographic_area_type => gat_country,
:iso_3166_a3 => 'WB1',
:iso_3166_a2 => nil)
:iso_3166_a2 => nil,
:parent => @area_land_mass)
@area_west_boxia_1.geographic_items << @item_wb
@area_west_boxia_1.save
@area_west_boxia_3 = FactoryGirl.build(:level1_geographic_area,
Expand All @@ -1095,14 +1102,16 @@ def generate_political_areas
:name => 'R',
:geographic_area_type => gat_country,
:iso_3166_a3 => 'RRR',
:iso_3166_a2 => 'RR')
:iso_3166_a2 => 'RR',
:parent => @area_land_mass)
@area_r.geographic_items << @item_r
@area_r.save
@area_s = FactoryGirl.build(:level0_geographic_area,
:name => 'S',
:geographic_area_type => gat_country,
:iso_3166_a3 => 'SSS',
:iso_3166_a2 => 'SS')
:iso_3166_a2 => 'SS',
:parent => @area_land_mass)
@area_s.geographic_items << @item_s
@area_s.save

Expand Down Expand Up @@ -1459,6 +1468,7 @@ def generate_political_areas
:error_geographic_item => @item_m3,
:geographic_item => GeographicItem.new(:point => @item_m3.st_centroid))
@ce_n3 = FactoryGirl.create(:collecting_event,
:verbatim_locality => 'Greater Boxia Lake',
:verbatim_label => '@ce_n3',
:geographic_area => @area_n3)
@gr_n3 = FactoryGirl.create(:georeference_verbatim_data,
Expand Down

0 comments on commit cd57599

Please sign in to comment.