simplegeo 0.3.1 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/simple_geo/client.rb +6 -45
 - metadata +3 -4
 
    
        data/lib/simple_geo/client.rb
    CHANGED
    
    | 
         @@ -115,11 +115,6 @@ module SimpleGeo 
     | 
|
| 
       115 
115 
     | 
    
         
             
                    nearby_records
         
     | 
| 
       116 
116 
     | 
    
         
             
                  end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
                  def get_nearby_address(lat, lon)
         
     | 
| 
       119 
     | 
    
         
            -
                    geojson_hash = get Endpoint.nearby_address(lat, lon)
         
     | 
| 
       120 
     | 
    
         
            -
                    HashUtils.symbolize_keys geojson_hash['properties']
         
     | 
| 
       121 
     | 
    
         
            -
                  end
         
     | 
| 
       122 
     | 
    
         
            -
                  
         
     | 
| 
       123 
118 
     | 
    
         
             
                  def get_context(lat, lon)
         
     | 
| 
       124 
119 
     | 
    
         
             
                    geojson_hash = get Endpoint.context(lat, lon)
         
     | 
| 
       125 
120 
     | 
    
         
             
                    HashUtils.recursively_symbolize_keys geojson_hash
         
     | 
| 
         @@ -151,6 +146,9 @@ module SimpleGeo 
     | 
|
| 
       151 
146 
     | 
    
         
             
                  # q is a full-text search of place names and category is an exact match
         
     | 
| 
       152 
147 
     | 
    
         
             
                  # to one or more of the classifiers. 
         
     | 
| 
       153 
148 
     | 
    
         
             
                  def get_places(lat, lon, options={})
         
     | 
| 
      
 149 
     | 
    
         
            +
                    if (options[:category] != nil)
         
     | 
| 
      
 150 
     | 
    
         
            +
                        options[:category] = URI.escape(options[:category], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
         
     | 
| 
      
 151 
     | 
    
         
            +
                    end
         
     | 
| 
       154 
152 
     | 
    
         
             
                    geojson_hash = get Endpoint.places(lat, lon, options)
         
     | 
| 
       155 
153 
     | 
    
         
             
                    HashUtils.recursively_symbolize_keys geojson_hash
         
     | 
| 
       156 
154 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -160,55 +158,18 @@ module SimpleGeo 
     | 
|
| 
       160 
158 
     | 
    
         
             
                    if (options[:category] != nil)
         
     | 
| 
       161 
159 
     | 
    
         
             
                        options[:category] = URI.escape(options[:category], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
         
     | 
| 
       162 
160 
     | 
    
         
             
                    end
         
     | 
| 
       163 
     | 
    
         
            -
                    options
         
     | 
| 
       164 
161 
     | 
    
         
             
                    geojson_hash = get Endpoint.places_by_address(address, options)
         
     | 
| 
       165 
162 
     | 
    
         
             
                    HashUtils.recursively_symbolize_keys geojson_hash
         
     | 
| 
       166 
163 
     | 
    
         
             
                  end
         
     | 
| 
       167 
164 
     | 
    
         | 
| 
       168 
165 
     | 
    
         
             
                  def get_places_by_ip(ip='ip', options={})
         
     | 
| 
      
 166 
     | 
    
         
            +
                    if (options[:category] != nil)
         
     | 
| 
      
 167 
     | 
    
         
            +
                        options[:category] = URI.escape(options[:category], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
         
     | 
| 
      
 168 
     | 
    
         
            +
                    end
         
     | 
| 
       169 
169 
     | 
    
         
             
                    geojson_hash = get Endpoint.places_by_ip(ip, options)
         
     | 
| 
       170 
170 
     | 
    
         
             
                    HashUtils.recursively_symbolize_keys geojson_hash
         
     | 
| 
       171 
171 
     | 
    
         
             
                  end
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
     | 
    
         
            -
                  def get_density(lat, lon, day, hour=nil)
         
     | 
| 
       174 
     | 
    
         
            -
                    geojson_hash = get Endpoint.density(lat, lon, day, hour)
         
     | 
| 
       175 
     | 
    
         
            -
                    geojson_hash = HashUtils.recursively_symbolize_keys(geojson_hash)
         
     | 
| 
       176 
     | 
    
         
            -
                    if hour.nil?
         
     | 
| 
       177 
     | 
    
         
            -
                      density_info = []
         
     | 
| 
       178 
     | 
    
         
            -
                      geojson_hash[:features].each do |hour_geojson_hash|
         
     | 
| 
       179 
     | 
    
         
            -
                        density_info << hour_geojson_hash[:properties].merge(
         
     | 
| 
       180 
     | 
    
         
            -
                          {:geometry => hour_geojson_hash[:geometry]})
         
     | 
| 
       181 
     | 
    
         
            -
                      end
         
     | 
| 
       182 
     | 
    
         
            -
                      density_info
         
     | 
| 
       183 
     | 
    
         
            -
                    else
         
     | 
| 
       184 
     | 
    
         
            -
                      geojson_hash[:properties].merge({:geometry => geojson_hash[:geometry]})
         
     | 
| 
       185 
     | 
    
         
            -
                    end
         
     | 
| 
       186 
     | 
    
         
            -
                  end
         
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
                  def get_overlaps(south, west, north, east, options=nil)
         
     | 
| 
       189 
     | 
    
         
            -
                    warn "[DEPRECATION] `SimpleGeo::Client.get_overlaps` is deprecated."
         
     | 
| 
       190 
     | 
    
         
            -
                    info = get Endpoint.overlaps(south, west, north, east), options
         
     | 
| 
       191 
     | 
    
         
            -
                    HashUtils.recursively_symbolize_keys(info)
         
     | 
| 
       192 
     | 
    
         
            -
                  end
         
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
                  # this API call seems to always return a 404
         
     | 
| 
       195 
     | 
    
         
            -
                  def get_boundary(id)
         
     | 
| 
       196 
     | 
    
         
            -
                    warn "[DEPRECATION] `SimpleGeo::Client.get_boundary` is deprecated. Use `SimpleGeo::Client.get_feature` instead."
         
     | 
| 
       197 
     | 
    
         
            -
                    info = get Endpoint.boundary(id)
         
     | 
| 
       198 
     | 
    
         
            -
                    HashUtils.recursively_symbolize_keys(info)
         
     | 
| 
       199 
     | 
    
         
            -
                  end
         
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
                  def get_contains(lat, lon)
         
     | 
| 
       202 
     | 
    
         
            -
                    warn "[DEPRECATION] `SimpleGeo::Client.get_contains` is deprecated. Use `SimpleGeo::Client.get_context` instead."
         
     | 
| 
       203 
     | 
    
         
            -
                    get_context(lat, lon)
         
     | 
| 
       204 
     | 
    
         
            -
                  end
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                  def get_contains_ip_address(ip)
         
     | 
| 
       207 
     | 
    
         
            -
                    warn "[DEPRECATION] `SimpleGeo::Client.get_contains` is deprecated."
         
     | 
| 
       208 
     | 
    
         
            -
                    info = get Endpoint.contains_ip_address(ip)
         
     | 
| 
       209 
     | 
    
         
            -
                    HashUtils.recursively_symbolize_keys(info)
         
     | 
| 
       210 
     | 
    
         
            -
                  end
         
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
173 
     | 
    
         
             
                  def get(endpoint, data=nil)
         
     | 
| 
       213 
174 
     | 
    
         
             
                    raise NoConnectionEstablished  if @@connection.nil?
         
     | 
| 
       214 
175 
     | 
    
         
             
                    @@connection.get endpoint, data
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: simplegeo
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
       10 
     | 
    
         
            -
              version: 0.3.1
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 4
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: "0.4"
         
     | 
| 
       11 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
12 
     | 
    
         
             
            - Andrew Mager
         
     |