Module: Bplgeo
- Defined in:
- lib/bplgeo.rb,
lib/bplgeo/tgn.rb,
lib/bplgeo/parser.rb,
lib/bplgeo/version.rb,
lib/bplgeo/geonames.rb,
lib/bplgeo/constants.rb,
lib/bplgeo/town_lookup.rb,
lib/bplgeo/standardizer.rb
Defined Under Namespace
Classes: Constants, Geonames, Parser, Standardizer, TGN, TownLookup
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
Class Method Details
.parse(term, parse_term = false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bplgeo.rb', line 15 def self.parse(term,parse_term=false) return {} if term.blank? return_hash = Bplgeo::Parser.parse_mapquest_api(term, parse_term) if return_hash.blank? return_hash = Bplgeo::Parser.parse_bing_api(term, parse_term) end if return_hash.blank? return_hash = Bplgeo::Parser.parse_google_api(term, parse_term) end if return_hash[:country_part].present? #FIXME return_hash[:tgn] = Bplgeo::TGN.tgn_id_from_geo_hash(return_hash) if return_hash[:tgn].blank? geo_hash_temp = Bplgeo::Standardizer.try_with_entered_names(return_hash) return_hash[:tgn] = Bplgeo::TGN.tgn_id_from_geo_hash(geo_hash_temp) if geo_hash_temp.present? if return_hash[:tgn].blank? && return_hash[:neighborhood_part].present? geo_hash_temp = return_hash.clone geo_hash_temp[:neighborhood_part] = nil geo_hash_temp[:original_string_differs] = true return_hash[:tgn] = Bplgeo::TGN.tgn_id_from_geo_hash(geo_hash_temp) return_hash[:tgn][:original_string_differs] = true if return_hash[:tgn].present? elsif return_hash[:city_part].present? && return_hash[:tgn].blank? geo_hash_temp = return_hash.clone geo_hash_temp[:city_part] = nil geo_hash_temp[:original_string_differs] = true return_hash[:tgn] = Bplgeo::TGN.tgn_id_from_geo_hash(geo_hash_temp) return_hash[:tgn][:original_string_differs] = true if return_hash[:tgn].present? end end return_hash[:geonames] = Bplgeo::Geonames.geonames_id_from_geo_hash(return_hash) end return return_hash end |