geo_combine 0.9.2 → 0.11.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.
@@ -10,12 +10,19 @@ module GeoCombine
10
10
  class Indexer
11
11
  attr_reader :solr
12
12
 
13
- def initialize(solr: nil, logger: GeoCombine::Logger.logger)
13
+ # Initialize a new indexer
14
+ # @param solr [RSolr::Client] an existing RSolr client
15
+ # @param solr_url [String] the URL of the Solr instance to connect to
16
+ # @param logger [Logger] a logger instance for logging messages
17
+ def initialize(
18
+ solr: nil,
19
+ solr_url: ENV.fetch('SOLR_URL', nil),
20
+ logger: GeoCombine::Logger.logger
21
+ )
14
22
  @logger = logger
15
23
  @batch_size = ENV.fetch('SOLR_BATCH_SIZE', 100).to_i
16
24
 
17
25
  # If SOLR_URL is set, use it; if in a Geoblacklight app, use its solr core
18
- solr_url = ENV.fetch('SOLR_URL', nil)
19
26
  solr_url ||= Blacklight.default_index.connection.base_uri.to_s if defined? Blacklight
20
27
 
21
28
  # If neither, warn and try to use local Blacklight default solr core
@@ -24,6 +31,7 @@ module GeoCombine
24
31
  solr_url = 'http://localhost:8983/solr/blacklight-core'
25
32
  end
26
33
 
34
+ # If solr connection was provided directly, use it; otherwise connect now
27
35
  @solr = solr || RSolr.connect(client, url: solr_url)
28
36
  end
29
37
 
@@ -8,6 +8,7 @@ module GeoCombine
8
8
  class OGP
9
9
  class InvalidMetadata < RuntimeError; end
10
10
  include GeoCombine::Formatting
11
+
11
12
  attr_reader :metadata
12
13
 
13
14
  ##
@@ -123,7 +124,7 @@ module GeoCombine
123
124
  # Builds a Solr Envelope using CQL syntax
124
125
  # @return [String]
125
126
  def envelope
126
- raise ArgumentError unless west >= -180 && west <= 180 &&
127
+ raise ArgumentError unless west.between?(-180, 180) &&
127
128
  east >= -180 && east <= 180 &&
128
129
  north >= -90 && north <= 90 &&
129
130
  south >= -90 && south <= 90 &&
@@ -144,6 +145,15 @@ module GeoCombine
144
145
  GeoCombine::Fgdc.new(metadata['FgdcText']) if metadata['FgdcText']
145
146
  end
146
147
 
148
+ SLUG_STRIP_VALUES = %w[
149
+ SDE_DATA.
150
+ SDE.
151
+ SDE2.
152
+ GISPORTAL.GISOWNER01.
153
+ GISDATA.
154
+ MORIS.
155
+ ].freeze
156
+
147
157
  private
148
158
 
149
159
  ##
@@ -207,15 +217,6 @@ module GeoCombine
207
217
  sluggify(filter_name(name))
208
218
  end
209
219
 
210
- SLUG_STRIP_VALUES = %w[
211
- SDE_DATA.
212
- SDE.
213
- SDE2.
214
- GISPORTAL.GISOWNER01.
215
- GISDATA.
216
- MORIS.
217
- ].freeze
218
-
219
220
  def filter_name(name)
220
221
  # strip out schema and usernames
221
222
  SLUG_STRIP_VALUES.each do |strip_val|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GeoCombine
4
- VERSION = '0.9.2'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -11,20 +11,26 @@ require 'geo_combine/geo_blacklight_harvester'
11
11
  namespace :geocombine do
12
12
  desc 'Clone OpenGeoMetadata repositories'
13
13
  task :clone, [:repo] do |_t, args|
14
- harvester = GeoCombine::Harvester.new
14
+ ogm_path = ENV.fetch('OGM_PATH', 'tmp/opengeometadata')
15
+
16
+ harvester = GeoCombine::Harvester.new(ogm_path: ogm_path)
15
17
  args[:repo] ? harvester.clone(args.repo) : harvester.clone_all
16
18
  end
17
19
 
18
20
  desc '"git pull" OpenGeoMetadata repositories'
19
21
  task :pull, [:repo] do |_t, args|
20
- harvester = GeoCombine::Harvester.new
22
+ ogm_path = ENV.fetch('OGM_PATH', 'tmp/opengeometadata')
23
+
24
+ harvester = GeoCombine::Harvester.new(ogm_path: ogm_path)
21
25
  args[:repo] ? harvester.pull(args.repo) : harvester.pull_all
22
26
  end
23
27
 
24
28
  desc 'Index all JSON documents except Layers.json'
25
- task :index do
26
- harvester = GeoCombine::Harvester.new
29
+ task :index, [:ogm_path] => [:environment] do |_t, args|
30
+ ogm_path = args.ogm_path || ENV.fetch('OGM_PATH', 'tmp/opengeometadata')
31
+
27
32
  indexer = GeoCombine::Indexer.new
33
+ harvester = GeoCombine::Harvester.new(ogm_path: ogm_path)
28
34
  indexer.index(harvester.docs_to_index)
29
35
  end
30
36