geocore 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/lib/geocore.rb +104 -2
- data/lib/geocore/version.rb +1 -1
- metadata +2 -3
- data/lib/geocore/builder.rb +0 -106
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1b421fe22eb83584280bf3897c6b1fbd82b4b50e
         | 
| 4 | 
            +
              data.tar.gz: d4218e9559c3d9d50b6e55e6b40dcd6fa76af2b4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1a18bafc72033f68645a2687b0309fa56d0a73bf899ee9f7fe9f172655db7be2ff7cff535c4f5914f890eb5aefbe647262a9eae2473938b257e8efa10da57246
         | 
| 7 | 
            +
              data.tar.gz: dc45ef72acd2efd99825714a2fb996f1acb4e95069e1cadd3fc392b05718d4f3dd4d9abdfffb6acdba22cd428cc5996dfb389606d5bbd194227745ab86359acd
         | 
    
        data/lib/geocore.rb
    CHANGED
    
    | @@ -1,6 +1,108 @@ | |
| 1 1 | 
             
            require "geocore/version"
         | 
| 2 | 
            -
            require " | 
| 3 | 
            -
             | 
| 2 | 
            +
            require "httparty"
         | 
| 3 | 
            +
            require "json"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Geocore
         | 
| 6 | 
            +
                include HTTParty
         | 
| 7 | 
            +
                base_uri 'http://dev1.geocore.jp:80/api'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def initialize(user)
         | 
| 10 | 
            +
                  @url = "http://dev1.geocore.jp/api/auth"
         | 
| 11 | 
            +
                  response = HTTParty.post(@url, body: {'id' => user.api_login, 'password' => user.api_key, 'project_id' => user.project_id})
         | 
| 12 | 
            +
                  if response['status'] == "success"
         | 
| 13 | 
            +
                    @feed_status = 'healthy'
         | 
| 14 | 
            +
                    @token = response["result"]["token"]
         | 
| 15 | 
            +
                    @header = {'Geocore-Access-Token': @token}
         | 
| 16 | 
            +
                  else
         | 
| 17 | 
            +
                    @feed_status = 'Error'
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def feed_status
         | 
| 22 | 
            +
                  return @feed_status
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def places
         | 
| 26 | 
            +
                  self.class.get("/places", headers: @header)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def level0
         | 
| 30 | 
            +
                  self.class.get("/public/ref/gadm")
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def level1(level0Id)
         | 
| 34 | 
            +
                  self.class.get("/public/ref/gadm" + level0Id.to_s)
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def level2(level0Id, level1Id)
         | 
| 38 | 
            +
                  self.class.get("/public/ref/gadm" + level0Id.to_s + '/' + level1Id.to_s)
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def level3(level0Id, level1Id, level2Id)
         | 
| 42 | 
            +
                  self.class.get("/public/ref/gadm" + level0Id.to_s + '/' + level1Id.to_s + '/' + level2Id.to_s)
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def regions(code_prefix)
         | 
| 46 | 
            +
                  self.class.get('/public/ref/jp/regions/' + code_prefix.to_s)
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                def region_prefectures(region_code)
         | 
| 50 | 
            +
                  self.class.get('/public/ref/jp/regions/' + region_code.to_s + '/prefectures')
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                def prefecture_cities(prefecture_code)
         | 
| 54 | 
            +
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/cities')
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                def prefecture_bounds(prefecture_code)
         | 
| 58 | 
            +
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/bounds')
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                def cities_bounds(city_codes_array)
         | 
| 62 | 
            +
                  self.class.get('/public/ref/jp/cities/bounds?city_codes=' + URI.escape(city_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                def train_line_bounds(line_code)
         | 
| 66 | 
            +
                  self.class.get('/public/ref/jp/lines/' + line_code.to_s + '/bounds')
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                def train_lines_bounds(line_codes_array)
         | 
| 70 | 
            +
                  self.class.get('/public/ref/jp/cities/bounds?city_codes=' + URI.escape(line_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                def prefecture_train_lines(prefecture_code)
         | 
| 74 | 
            +
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/lines')
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                def prefecture_train_line_stations(prefecture_code, line_code)
         | 
| 78 | 
            +
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/lines/' + line_code.to_s + '/stations')
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                def stations_bounds(station_codes_array)
         | 
| 82 | 
            +
                  self.class.get('/public/ref/jp/stations/bounds?station_codes=' + URI.escape(station_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                def prefecture(prefecture_code)
         | 
| 86 | 
            +
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s)
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                def city(city_code)
         | 
| 90 | 
            +
                  self.class.get('/public/ref/jp/cities/' + city_code.to_s)  # Code examples: Shinjuku = 13104, Saiwai(Kawasaki) = 14132, Nishi(Yokohama) = 14103, city_codes_array = [13104, 14132, 14103]
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                def nearest_city(lat, lon)
         | 
| 94 | 
            +
                  self.class.get('/public/ref/jp/cities/nearest?lat=' + lat + '&lon=' + lon)
         | 
| 95 | 
            +
                end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                def train_line(line_code)
         | 
| 98 | 
            +
                  self.class.get('/public/ref/jp/lines/' + line_code)
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                def station(station_code)
         | 
| 102 | 
            +
                  self.class.get('/public/ref/jp/stations/' + station_code)
         | 
| 103 | 
            +
                end
         | 
| 6 104 | 
             
            end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
             | 
| 107 | 
            +
             | 
| 108 | 
            +
             | 
    
        data/lib/geocore/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: geocore
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - MapMotion K.K
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-10- | 
| 11 | 
            +
            date: 2018-10-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -81,7 +81,6 @@ files: | |
| 81 81 | 
             
            - bin/setup
         | 
| 82 82 | 
             
            - geocore.gemspec
         | 
| 83 83 | 
             
            - lib/geocore.rb
         | 
| 84 | 
            -
            - lib/geocore/builder.rb
         | 
| 85 84 | 
             
            - lib/geocore/version.rb
         | 
| 86 85 | 
             
            homepage: http://dev1.geocore.jp/apidocs/
         | 
| 87 86 | 
             
            licenses: []
         | 
    
        data/lib/geocore/builder.rb
    DELETED
    
    | @@ -1,106 +0,0 @@ | |
| 1 | 
            -
            require "httparty"
         | 
| 2 | 
            -
            require "json"
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module Geocore
         | 
| 5 | 
            -
              class Builder
         | 
| 6 | 
            -
                include HTTParty
         | 
| 7 | 
            -
                base_uri 'http://dev1.geocore.jp:80/api'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def initialize(user)
         | 
| 10 | 
            -
                  @url = "http://dev1.geocore.jp/api/auth"
         | 
| 11 | 
            -
                  response = HTTParty.post(@url, body: {'id' => user.api_login, 'password' => user.api_key, 'project_id' => user.project_id})
         | 
| 12 | 
            -
                  if response['status'] == "success"
         | 
| 13 | 
            -
                    @feed_status = 'healthy'
         | 
| 14 | 
            -
                    @token = response["result"]["token"]
         | 
| 15 | 
            -
                    @header = {'Geocore-Access-Token': @token}
         | 
| 16 | 
            -
                  else
         | 
| 17 | 
            -
                    @feed_status = 'Error'
         | 
| 18 | 
            -
                  end
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                def feed_status
         | 
| 22 | 
            -
                  return @feed_status
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                def places
         | 
| 26 | 
            -
                  self.class.get("/places", headers: @header)
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                def level0
         | 
| 30 | 
            -
                  self.class.get("/public/ref/gadm")
         | 
| 31 | 
            -
                end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                def level1(level0Id)
         | 
| 34 | 
            -
                  self.class.get("/public/ref/gadm" + level0Id.to_s)
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                def level2(level0Id, level1Id)
         | 
| 38 | 
            -
                  self.class.get("/public/ref/gadm" + level0Id.to_s + '/' + level1Id.to_s)
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                def level3(level0Id, level1Id, level2Id)
         | 
| 42 | 
            -
                  self.class.get("/public/ref/gadm" + level0Id.to_s + '/' + level1Id.to_s + '/' + level2Id.to_s)
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                def regions(code_prefix)
         | 
| 46 | 
            -
                  self.class.get('/public/ref/jp/regions/' + code_prefix.to_s)
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                def region_prefectures(region_code)
         | 
| 50 | 
            -
                  self.class.get('/public/ref/jp/regions/' + region_code.to_s + '/prefectures')
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                def prefecture_cities(prefecture_code)
         | 
| 54 | 
            -
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/cities')
         | 
| 55 | 
            -
                end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                def prefecture_bounds(prefecture_code)
         | 
| 58 | 
            -
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/bounds')
         | 
| 59 | 
            -
                end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                def cities_bounds(city_codes_array)
         | 
| 62 | 
            -
                  self.class.get('/public/ref/jp/cities/bounds?city_codes=' + URI.escape(city_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                def train_line_bounds(line_code)
         | 
| 66 | 
            -
                  self.class.get('/public/ref/jp/lines/' + line_code.to_s + '/bounds')
         | 
| 67 | 
            -
                end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                def train_lines_bounds(line_codes_array)
         | 
| 70 | 
            -
                  self.class.get('/public/ref/jp/cities/bounds?city_codes=' + URI.escape(line_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
         | 
| 71 | 
            -
                end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                def prefecture_train_lines(prefecture_code)
         | 
| 74 | 
            -
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/lines')
         | 
| 75 | 
            -
                end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                def prefecture_train_line_stations(prefecture_code, line_code)
         | 
| 78 | 
            -
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s + '/lines/' + line_code.to_s + '/stations')
         | 
| 79 | 
            -
                end
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                def stations_bounds(station_codes_array)
         | 
| 82 | 
            -
                  self.class.get('/public/ref/jp/stations/bounds?station_codes=' + URI.escape(station_codes_array.join(','), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")))
         | 
| 83 | 
            -
                end
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                def prefecture(prefecture_code)
         | 
| 86 | 
            -
                  self.class.get('/public/ref/jp/prefectures/' + prefecture_code.to_s)
         | 
| 87 | 
            -
                end
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                def city(city_code)
         | 
| 90 | 
            -
                  self.class.get('/public/ref/jp/cities/' + city_code.to_s)  # Code examples: Shinjuku = 13104, Saiwai(Kawasaki) = 14132, Nishi(Yokohama) = 14103, city_codes_array = [13104, 14132, 14103]
         | 
| 91 | 
            -
                end
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                def nearest_city(lat, lon)
         | 
| 94 | 
            -
                  self.class.get('/public/ref/jp/cities/nearest?lat=' + lat + '&lon=' + lon)
         | 
| 95 | 
            -
                end
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                def train_line(line_code)
         | 
| 98 | 
            -
                  self.class.get('/public/ref/jp/lines/' + line_code)
         | 
| 99 | 
            -
                end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                def station(station_code)
         | 
| 102 | 
            -
                  self.class.get('/public/ref/jp/stations/' + station_code)
         | 
| 103 | 
            -
                end
         | 
| 104 | 
            -
              end
         | 
| 105 | 
            -
            end
         | 
| 106 | 
            -
             |