geoblacklight 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.coveralls.yml +1 -0
- data/.gitmodules +1 -1
- data/.travis.yml +9 -0
- data/Gemfile +18 -0
- data/README.md +36 -38
- data/Rakefile +9 -9
- data/app/assets/fonts/geoblacklight.eot +0 -0
- data/app/assets/fonts/geoblacklight.svg +117 -0
- data/app/assets/fonts/geoblacklight.ttf +0 -0
- data/app/assets/fonts/geoblacklight.woff +0 -0
- data/app/assets/images/blacklight/logo.png +0 -0
- data/app/assets/javascripts/geoblacklight/application.js +1 -0
- data/app/assets/javascripts/geoblacklight/geoblacklight.js +86 -2
- data/app/assets/javascripts/geoblacklight/modules/collapse.js +6 -0
- data/app/assets/javascripts/geoblacklight/modules/download.js +45 -0
- data/app/assets/javascripts/geoblacklight/modules/geosearch.js +77 -0
- data/app/assets/javascripts/geoblacklight/modules/home.js +10 -0
- data/app/assets/javascripts/geoblacklight/modules/item.js +72 -0
- data/app/assets/javascripts/geoblacklight/modules/map-view.js +7 -7
- data/app/assets/javascripts/geoblacklight/modules/results.js +50 -0
- data/app/assets/stylesheets/geoblacklight/_geoblacklight.css.scss +20 -0
- data/app/assets/stylesheets/geoblacklight/_styles.css.scss +44 -0
- data/app/assets/stylesheets/geoblacklight/application.css.scss +3 -0
- data/app/assets/stylesheets/geoblacklight/modules/home.css.scss +3 -0
- data/app/assets/stylesheets/geoblacklight/modules/icon-customization.css.scss +10 -0
- data/app/assets/stylesheets/geoblacklight/modules/icons.css.scss +77 -0
- data/app/assets/stylesheets/geoblacklight/modules/item.css.scss +4 -0
- data/app/assets/stylesheets/geoblacklight/modules/results.css.scss +29 -0
- data/app/controllers/download_controller.rb +22 -94
- data/app/controllers/wms_controller.rb +2 -74
- data/app/helpers/geoblacklight_helper.rb +6 -36
- data/app/views/catalog/_document_split.html.erb +4 -0
- data/app/views/catalog/_home_text.html.erb +2 -39
- data/app/views/catalog/_index_split_default.html.erb +24 -0
- data/app/views/catalog/_show_default.html.erb +4 -57
- data/app/views/catalog/_show_header_default.html.erb +8 -0
- data/app/views/catalog/_show_sidebar.html.erb +17 -57
- data/app/views/catalog/_upper_metadata.html.erb +38 -0
- data/config/initializers/rails_config.rb +3 -0
- data/config/jetty.yml +6 -0
- data/config/locales/geoblacklight.en.yml +5 -0
- data/geoblacklight.gemspec +5 -5
- data/lib/generators/geoblacklight/install_generator.rb +45 -15
- data/lib/generators/geoblacklight/templates/geoblacklight.css.scss +2 -78
- data/lib/generators/geoblacklight/templates/settings.yml +9 -0
- data/lib/geoblacklight.rb +13 -0
- data/lib/geoblacklight/controller_override.rb +18 -0
- data/lib/geoblacklight/download.rb +63 -0
- data/lib/geoblacklight/download/kmz_download.rb +14 -0
- data/lib/geoblacklight/download/shapefile_download.rb +14 -0
- data/lib/geoblacklight/engine.rb +11 -1
- data/lib/geoblacklight/solr_document.rb +30 -0
- data/lib/geoblacklight/version.rb +1 -1
- data/lib/geoblacklight/view_helper_override.rb +17 -0
- data/lib/geoblacklight/wms_layer.rb +38 -0
- data/lib/geoblacklight/wms_layer/feature_info_response.rb +30 -0
- data/lib/tasks/geoblacklight.rake +15 -0
- data/spec/features/download_layer_spec.rb +18 -0
- data/spec/features/home_page_spec.rb +49 -0
- data/spec/features/layer_inspection_spec.rb +9 -0
- data/spec/features/layer_preview_spec.rb +16 -0
- data/spec/features/split_view.html.erb_spec.rb +35 -0
- data/spec/fixtures/test-berkeley-fields.json +44 -0
- data/spec/lib/geoblacklight/controller_override_spec.rb +28 -0
- data/spec/lib/geoblacklight/download/kmz_download_spec.rb +15 -0
- data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +14 -0
- data/spec/lib/geoblacklight/download_spec.rb +76 -0
- data/spec/lib/geoblacklight/solr_document.rb +52 -0
- data/spec/lib/geoblacklight/view_helper_override_spec.rb +23 -0
- data/spec/lib/geoblacklight/wms_layer/feature_info_response_spec.rb +43 -0
- data/spec/lib/geoblacklight/wms_layer_spec.rb +33 -0
- data/spec/spec_helper.rb +3 -6
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -2
- data/spec/views/catalog/_document_split.html.erb_spec.rb +5 -0
- data/spec/views/catalog/_index_split.html.erb_spec.rb +5 -0
- data/template.rb +10 -0
- data/vendor/assets/javascripts/native.history.js +1 -0
- metadata +129 -82
- data/app/assets/images/geoblacklight/src_berkeley.png +0 -0
- data/app/assets/images/geoblacklight/src_cambridge.png +0 -0
- data/app/assets/images/geoblacklight/src_harvard.png +0 -0
- data/app/assets/images/geoblacklight/src_maryland.png +0 -0
- data/app/assets/images/geoblacklight/src_massgis.png +0 -0
- data/app/assets/images/geoblacklight/src_mit.png +0 -0
- data/app/assets/images/geoblacklight/src_princeton.png +0 -0
- data/app/assets/images/geoblacklight/src_stanford.png +0 -0
- data/app/assets/images/geoblacklight/src_tufts.png +0 -0
- data/app/assets/images/geoblacklight/src_un.png +0 -0
- data/app/assets/images/geoblacklight/type_arc.png +0 -0
- data/app/assets/images/geoblacklight/type_dot.png +0 -0
- data/app/assets/images/geoblacklight/type_library.png +0 -0
- data/app/assets/images/geoblacklight/type_map.png +0 -0
- data/app/assets/images/geoblacklight/type_polygon.png +0 -0
- data/app/assets/images/geoblacklight/type_raster.png +0 -0
- data/app/assets/javascripts/geoblacklight/modules/map-home.js +0 -25
- data/app/assets/javascripts/geoblacklight/modules/map-results.js +0 -72
- data/app/views/catalog/_document_list.html.erb +0 -12
- data/app/views/catalog/_index_header_default.html.erb +0 -59
- data/spec/fixtures/geoblacklight_schema/transformed.json +0 -53
@@ -0,0 +1,14 @@
|
|
1
|
+
class KmzDownload < Download
|
2
|
+
KMZ_DOWNLOAD_PARAMS = { service: 'wms', version: '1.1.0', request: 'GetMap', srsName: 'EPSG:900913', format: 'application/vnd.google-earth.kmz', width: 2000, height: 2000 }
|
3
|
+
|
4
|
+
def initialize(document)
|
5
|
+
request_params = KMZ_DOWNLOAD_PARAMS.merge(layers: document[:layer_id_s], bbox: document[:solr_bbox].split(' ').join(', '))
|
6
|
+
super(document, {
|
7
|
+
type: 'kmz',
|
8
|
+
extension: 'kmz',
|
9
|
+
request_params: request_params,
|
10
|
+
content_type: 'application/vnd.google-earth.kmz',
|
11
|
+
service_type: :solr_wms_url
|
12
|
+
})
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class ShapefileDownload < Download
|
2
|
+
SHAPEFILE_DOWNLOAD_PARAMS = { service: 'wfs', version: '2.0.0', request: 'GetFeature', srsName: 'EPSG:4326', outputformat: 'SHAPE-ZIP' }
|
3
|
+
|
4
|
+
def initialize(document)
|
5
|
+
request_params = SHAPEFILE_DOWNLOAD_PARAMS.merge(typeName: document[:layer_id_s])
|
6
|
+
super(document, {
|
7
|
+
type: 'shapefile',
|
8
|
+
extension: 'zip',
|
9
|
+
request_params: request_params,
|
10
|
+
content_type: 'application/zip',
|
11
|
+
service_type: :solr_wfs_url
|
12
|
+
})
|
13
|
+
end
|
14
|
+
end
|
data/lib/geoblacklight/engine.rb
CHANGED
@@ -1,15 +1,25 @@
|
|
1
1
|
require 'blacklight'
|
2
2
|
require 'leaflet-rails'
|
3
|
+
# move towards removing httparty, replaced by faraday
|
3
4
|
require 'httparty'
|
4
5
|
require 'font-awesome-rails'
|
6
|
+
require 'rails_config'
|
7
|
+
require 'faraday'
|
5
8
|
|
6
9
|
module Geoblacklight
|
7
10
|
class Engine < ::Rails::Engine
|
8
11
|
|
12
|
+
Blacklight::Configuration.default_values[:view].split.partials = ['index']
|
13
|
+
Blacklight::Configuration.default_values[:view].delete_field('list')
|
14
|
+
|
9
15
|
# GeoblacklightHelper is needed by all helpers, so we inject it
|
10
|
-
# into action view base here.
|
16
|
+
# into action view base here.
|
11
17
|
initializer 'geoblacklight.helpers' do |app|
|
12
18
|
ActionView::Base.send :include, GeoblacklightHelper
|
13
19
|
end
|
20
|
+
|
21
|
+
config.to_prepare do
|
22
|
+
Geoblacklight.inject!
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Geoblacklight
|
2
|
+
# Extends Blacklight::Solr::Document for GeoBlacklight specific functionalit
|
3
|
+
module SolrDocument
|
4
|
+
extend Blacklight::Solr::Document
|
5
|
+
|
6
|
+
def available?
|
7
|
+
public? || same_institution?
|
8
|
+
end
|
9
|
+
|
10
|
+
def public?
|
11
|
+
get(:dc_rights_s) == 'Public'
|
12
|
+
end
|
13
|
+
|
14
|
+
def downloadable?
|
15
|
+
get(:solr_wfs_url) && get(:solr_wms_url) && available?
|
16
|
+
end
|
17
|
+
|
18
|
+
def download_types
|
19
|
+
[{ label: 'Shapefile', type: 'shapefile' }, { label: 'KMZ', type: 'kmz' }]
|
20
|
+
end
|
21
|
+
|
22
|
+
def same_institution?
|
23
|
+
get(:dct_provenance_s) == Settings.Institution
|
24
|
+
end
|
25
|
+
|
26
|
+
def itemtype
|
27
|
+
"http://schema.org/Dataset"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Geoblacklight
|
2
|
+
module ViewHelperOverride
|
3
|
+
|
4
|
+
def has_spatial_parameters?
|
5
|
+
params[:bbox]
|
6
|
+
end
|
7
|
+
|
8
|
+
# Overrides BL method to enable results for spatial only params
|
9
|
+
def has_search_parameters?
|
10
|
+
super || has_spatial_parameters?
|
11
|
+
end
|
12
|
+
|
13
|
+
def query_has_contraints(params = params)
|
14
|
+
super || has_search_parameters?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'geoblacklight/wms_layer/feature_info_response'
|
3
|
+
class WmsLayer
|
4
|
+
|
5
|
+
def initialize(params)
|
6
|
+
@params = params.merge(Settings.WMS_PARAMS)
|
7
|
+
@response = FeatureInfoResponse.new(request_response)
|
8
|
+
end
|
9
|
+
|
10
|
+
def url
|
11
|
+
@params['URL']
|
12
|
+
end
|
13
|
+
|
14
|
+
def search_params
|
15
|
+
@params.except('URL')
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_feature_info
|
19
|
+
@response.check
|
20
|
+
end
|
21
|
+
|
22
|
+
def request_response
|
23
|
+
begin
|
24
|
+
conn = Faraday.new(url: url)
|
25
|
+
conn.get do |request|
|
26
|
+
request.params = search_params
|
27
|
+
request.options = {
|
28
|
+
timeout: 2,
|
29
|
+
open_timeout: 2
|
30
|
+
}
|
31
|
+
end
|
32
|
+
rescue Faraday::Error::ConnectionFailed => error
|
33
|
+
{ error: error }
|
34
|
+
rescue Faraday::Error::TimeoutError => error
|
35
|
+
{ error: error }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class FeatureInfoResponse
|
2
|
+
def initialize(response)
|
3
|
+
@response = response
|
4
|
+
end
|
5
|
+
|
6
|
+
def check
|
7
|
+
if error?
|
8
|
+
@response
|
9
|
+
else
|
10
|
+
format
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def format
|
15
|
+
page = Nokogiri::HTML(@response.body)
|
16
|
+
table_values = { values: [] }
|
17
|
+
page.css('th').each do |th|
|
18
|
+
table_values[:values].push([th.text])
|
19
|
+
end
|
20
|
+
page.css('td').each_with_index do |td, index|
|
21
|
+
table_values[:values][index].push(td.text)
|
22
|
+
end
|
23
|
+
table_values
|
24
|
+
end
|
25
|
+
|
26
|
+
def error?
|
27
|
+
@response[:error] ||
|
28
|
+
@response.headers['content-type'].slice(0, 9) == 'text/xml'
|
29
|
+
end
|
30
|
+
end
|
@@ -9,5 +9,20 @@ namespace :geoblacklight do
|
|
9
9
|
Blacklight.solr.add docs
|
10
10
|
Blacklight.solr.commit
|
11
11
|
end
|
12
|
+
|
13
|
+
desc "Ingests a GeoHydra transformed.json"
|
14
|
+
task :ingest_all => :environment do
|
15
|
+
docs = JSON::parse(File.read("#{Rails.root}/tmp/transformed.json"))
|
16
|
+
docs.each do |doc|
|
17
|
+
Blacklight.solr.add doc
|
18
|
+
Blacklight.solr.commit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
namespace :downloads do
|
23
|
+
desc 'Delete all cached downloads'
|
24
|
+
task delete: :environment do
|
25
|
+
FileUtils.rm_rf Dir.glob("#{Rails.root}/tmp/downloads/*")
|
26
|
+
end
|
12
27
|
end
|
13
28
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Download layer', js: true do
|
4
|
+
scenario 'clicking shapefile download button should trigger download' do
|
5
|
+
expect_any_instance_of(ShapefileDownload).to receive(:get).and_return('mit-us-ma-e25zcta5dct-2000-shapefile.zip')
|
6
|
+
visit catalog_path('mit-us-ma-e25zcta5dct-2000')
|
7
|
+
find('button', text: 'Download').click
|
8
|
+
find('a', text: 'Shapefile').click
|
9
|
+
expect(page).to have_css('a', text: 'Your file mit-us-ma-e25zcta5dct-2000-shapefile.zip is ready for download')
|
10
|
+
end
|
11
|
+
scenario 'clicking kmz download button should trigger download' do
|
12
|
+
expect_any_instance_of(KmzDownload).to receive(:get).and_return('mit-us-ma-e25zcta5dct-2000-kmz.kmz')
|
13
|
+
visit catalog_path('mit-us-ma-e25zcta5dct-2000')
|
14
|
+
find('button', text: 'Download').click
|
15
|
+
find('a', text: 'KMZ').click
|
16
|
+
expect(page).to have_css('a', text: 'Your file mit-us-ma-e25zcta5dct-2000-kmz.kmz is ready for download')
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Home page', js: true do # use js: true for tests which require js, but it slows things down
|
4
|
+
before do
|
5
|
+
visit root_path
|
6
|
+
end
|
7
|
+
scenario 'should have facets listed correctly' do
|
8
|
+
within '#facet-panel-collapse' do
|
9
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Institution')
|
10
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Publisher')
|
11
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Subject')
|
12
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Place')
|
13
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Year')
|
14
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Access')
|
15
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Data type')
|
16
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Format')
|
17
|
+
expect(page).to have_css('div.panel.facet_limit', text: 'Language')
|
18
|
+
end
|
19
|
+
click_link 'Institution'
|
20
|
+
expect(page).to have_css('a.facet_select', text: 'Harvard', visible: true)
|
21
|
+
expect(page).to have_css('a.facet_select', text: 'Tufts', visible: true)
|
22
|
+
expect(page).to have_css('a.facet_select', text: 'MIT', visible: true)
|
23
|
+
expect(page).to have_css('a.facet_select', text: 'MassGIS', visible: true)
|
24
|
+
expect(page).to have_css('a.facet_select', text: 'Stanford', visible: true)
|
25
|
+
end
|
26
|
+
scenario 'map should be visible' do
|
27
|
+
within '#content' do
|
28
|
+
expect(page).to have_css('#map')
|
29
|
+
expect(page).to have_css('img.leaflet-tile', count: 16)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
scenario 'clicking map search should create a spatial search' do
|
33
|
+
find('#map').double_click
|
34
|
+
within '#map' do
|
35
|
+
find('a.search-control').click
|
36
|
+
expect(page.current_url).to match /bbox=/
|
37
|
+
end
|
38
|
+
expect(page).to have_css '#documents'
|
39
|
+
end
|
40
|
+
|
41
|
+
scenario 'clicking map search should retain current search parameters' do
|
42
|
+
visit '/?f[dc_subject_sm][]=polygon&f[dc_subject_sm][]=boundaries'
|
43
|
+
find('#map').double_click
|
44
|
+
within '#appliedParams' do
|
45
|
+
expect(page).to have_content('Subject polygon')
|
46
|
+
expect(page).to have_content('Subject boundaries')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Layer preview', js: true do
|
4
|
+
scenario 'Restricted layer should show bounding box' do
|
5
|
+
visit catalog_path('mit-us-ma-cambridge-s1consv-2007')
|
6
|
+
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 1
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'Public layer should show wms layer not bounding box' do
|
10
|
+
visit catalog_path('mit-us-ma-e25zcta5dct-2000')
|
11
|
+
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 0
|
12
|
+
within '.leaflet-tile-pane' do
|
13
|
+
expect(page).to have_css('.leaflet-layer', count: 2)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Index view', js: true do
|
4
|
+
before do
|
5
|
+
visit catalog_index_path( f: { dct_provenance_s: ['Stanford']})
|
6
|
+
end
|
7
|
+
|
8
|
+
scenario 'should have documents and map on page' do
|
9
|
+
expect(page).to have_css('#documents')
|
10
|
+
expect(page).to have_css(".document", count: 2)
|
11
|
+
expect(page).to have_css('#map')
|
12
|
+
end
|
13
|
+
|
14
|
+
scenario 'hover on record should produce bounding box on map' do
|
15
|
+
# Needed to find an svg element on the page
|
16
|
+
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 0
|
17
|
+
find('.documentHeader', match: :first).trigger(:mouseover)
|
18
|
+
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 1
|
19
|
+
end
|
20
|
+
|
21
|
+
scenario 'click on a record area to expand collapse' do
|
22
|
+
within('.documentHeader', match: :first) do
|
23
|
+
expect(page).to_not have_css('.collapse')
|
24
|
+
find('.status-icons').click
|
25
|
+
expect(page).to have_css('.collapse', visible: true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
scenario 'spatial search should reset to page one' do
|
30
|
+
visit '/?f%5Bdc_format_s%5D%5B%5D=Shapefile&page=2'
|
31
|
+
find("#map").double_click
|
32
|
+
expect(find('.page_entries')).to have_content('1 - 10')
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"uuid": "http://ark.cdlib.org/ark:/28722/bk0012h5z5n",
|
4
|
+
"dc_description_s": "Field boundaries for Napa County.",
|
5
|
+
"dc_format_s": "Shapefile",
|
6
|
+
"dc_identifier_s": "http://ark.cdlib.org/ark:/28722/bk0012h5z5n",
|
7
|
+
"dc_language_s": "English",
|
8
|
+
"dc_publisher_s": "UC Berkeley Libraries",
|
9
|
+
"dc_rights_s": "Public",
|
10
|
+
"dc_subject_sm": [
|
11
|
+
"boundaries",
|
12
|
+
"farming"
|
13
|
+
],
|
14
|
+
"dc_title_s": "Field Boundaries",
|
15
|
+
"dc_type_s": "Dataset",
|
16
|
+
"dct_references_s": "{\"http://www.opengis.net/def/serviceType/ogc/wfs\":\"http://gis.lib.berkeley.edu:8080/geoserver/wfs\",\"http://www.opengis.net/def/serviceType/ogc/wms\":\"http://gis.lib.berkeley.edu:8080/geoserver/wms\"}",
|
17
|
+
"dct_spatial_sm": [
|
18
|
+
"Napa County",
|
19
|
+
"American Canyon",
|
20
|
+
"Yountville",
|
21
|
+
"St Helena",
|
22
|
+
"Calistoga"
|
23
|
+
],
|
24
|
+
"dct_temporal_sm": [
|
25
|
+
"2007"
|
26
|
+
],
|
27
|
+
"dct_issued_s": "2000",
|
28
|
+
"dct_provenance_s": "Berkeley",
|
29
|
+
"georss_box_s": "38.157173 -122.647473 38.861126 -122.084131",
|
30
|
+
"georss_polygon_s": "38.861126 -122.647473 38.861126 -122.084131 38.157173 -122.084131 38.157173 -122.647473 38.861126 -122.647473",
|
31
|
+
"layer_slug_s": "berkeley-fields",
|
32
|
+
"layer_id_s": "UCB:fields",
|
33
|
+
"layer_geom_type_s": "Polygon",
|
34
|
+
"layer_modified_dt": "2014-05-27T18:09:33Z",
|
35
|
+
"solr_bbox": "-122.647473 38.157173 -122.084131 38.861126",
|
36
|
+
"solr_ne_pt": "38.861126,-122.084131",
|
37
|
+
"solr_sw_pt": "38.157173,-122.647473",
|
38
|
+
"solr_geom": "ENVELOPE(-122.647473, -122.084131, 38.861126, 38.157173)",
|
39
|
+
"solr_year_i": 2007,
|
40
|
+
"solr_issued_dt": "2000-01-01T00:00:00Z",
|
41
|
+
"solr_wms_url": "http://gis.lib.berkeley.edu:8080/geoserver/wms",
|
42
|
+
"solr_wfs_url": "http://gis.lib.berkeley.edu:8080/geoserver/wfs"
|
43
|
+
}
|
44
|
+
]
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Geoblacklight::ControllerOverride do
|
4
|
+
class GeoblacklightControllerTestClass
|
5
|
+
end
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@fake_controller = GeoblacklightControllerTestClass.new
|
9
|
+
@fake_controller.extend(Geoblacklight::ControllerOverride)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:solr_params) { OpenStruct.new }
|
13
|
+
let(:req_params) { OpenStruct.new }
|
14
|
+
|
15
|
+
describe 'add_spatial_params' do
|
16
|
+
it 'should return the solr_params when no bbox is given' do
|
17
|
+
expect(@fake_controller.add_spatial_params(solr_params, req_params)).to eq solr_params
|
18
|
+
end
|
19
|
+
it 'should return a spatial search if bbox is given' do
|
20
|
+
req_params.bbox = '123'
|
21
|
+
expect(has_spatial_query(solr_params, req_params)).to be_truthy
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_spatial_query(solr_params, req_params)
|
27
|
+
/Intersects/ =~ @fake_controller.add_spatial_params(solr_params, req_params).fq.first
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KmzDownload do
|
4
|
+
let(:document) { SolrDocument.new(layer_slug_s: 'test', solr_wfs_url: 'http://www.example.com/wfs', layer_id_s: 'stanford-test', solr_bbox: '-180 -90 180 90') }
|
5
|
+
let(:download) { KmzDownload.new(document) }
|
6
|
+
describe '#initialize' do
|
7
|
+
it 'should initialize as a KmzDownload object with specific options' do
|
8
|
+
expect(download).to be_an KmzDownload
|
9
|
+
options = download.instance_variable_get(:@options)
|
10
|
+
expect(options[:content_type]).to eq 'application/vnd.google-earth.kmz'
|
11
|
+
expect(options[:request_params][:layers]).to eq 'stanford-test'
|
12
|
+
expect(options[:request_params][:bbox]).to eq '-180, -90, 180, 90'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ShapefileDownload do
|
4
|
+
let(:document) { SolrDocument.new(layer_slug_s: 'test', solr_wfs_url: 'http://www.example.com/wfs', layer_id_s: 'stanford-test', solr_bbox: '-180 -90 180 90') }
|
5
|
+
let(:download) { ShapefileDownload.new(document) }
|
6
|
+
describe '#initialize' do
|
7
|
+
it 'should initialize as a ShapefileDownload object with specific options' do
|
8
|
+
expect(download).to be_an ShapefileDownload
|
9
|
+
options = download.instance_variable_get(:@options)
|
10
|
+
expect(options[:content_type]).to eq 'application/zip'
|
11
|
+
expect(options[:request_params][:typeName]).to eq 'stanford-test'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|