Skip to content

Commit

Permalink
Deprecate solr_bbox and parse new WKT syntax. Fixes #297
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Hardy committed Feb 25, 2015
1 parent e89d614 commit efcaf7e
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/generators/geoblacklight/templates/settings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Main Solr geometry field used for spatial search and bounding box. Should be type 'rpt'
GEOMETRY_FIELD: 'solr_bbox'
GEOMETRY_FIELD: 'solr_geom'

# Institution deployed at
INSTITUTION: 'Stanford'
Expand Down
8 changes: 7 additions & 1 deletion lib/geoblacklight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ def itemtype
end

def bounding_box_as_wsen
get(Settings.GEOMETRY_FIELD.to_sym)
s = get(Settings.GEOMETRY_FIELD.to_sym)
if s =~ /^\s*ENVELOPE\(\s*([-\.\d]+)\s*,\s*([-\.\d]+)\s*,\s*([-\.\d]+)\s*,\s*([-\.\d]+)\s*\)\s*$/
w, s, e, n = $1, $4, $2, $3
return "#{w} #{s} #{e} #{n}"
else
return s # as-is, not a WKT
end
end
##
# Provides a convenience method to access a SolrDocument's References
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/actual-papermap1.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"layer_id_s": "MIT:001145244",
"layer_geom_type_s": "Paper Map",
"layer_modified_dt": "2014-12-04T21:32:59Z",
"solr_bbox": "-13.0 49.0 4.0 62.0",
"solr_geom": "ENVELOPE(-13.0, 4.0, 62.0, 49.0)",
"solr_year_i": 1996
}
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/actual-point1.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"layer_id_s": "Columbia:Columbia.landinfo_global_aet",
"layer_geom_type_s": "Point",
"layer_modified_dt": "2014-12-12T19:54:57Z",
"solr_bbox": "-179.5 -56.0 180.0 83.0",
"solr_geom": "ENVELOPE(-179.5, 180.0, 83.0, -56.0)",
"solr_year_i": 1996
}
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/actual-polygon1.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"layer_id_s": "sde:GISPORTAL.GISOWNER01.CAMBRIDGEGRID100_04",
"layer_geom_type_s": "Polygon",
"layer_modified_dt": "2014-12-04T21:33:07Z",
"solr_bbox": "-71.163984 42.34757 -71.052581 42.408316",
"solr_geom": "ENVELOPE(-71.163984, -71.052581, 42.408316, 42.34757)",
"solr_year_i": 2004
}
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/actual-raster1.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@
"georss_box_s": "36.8085911 -121.7948738 36.8606925 -121.7389503",
"georss_polygon_s": "36.8085911 -121.7948738 36.8606925 -121.7948738 36.8606925 -121.7389503 36.8085911 -121.7389503 36.8085911 -121.7948738",
"solr_geom": "ENVELOPE(-121.7948738, -121.7389503, 36.8606925, 36.8085911)",
"solr_bbox": "-121.7948738 36.8085911 -121.7389503 36.8606925",
"solr_year_i": 2005
}
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/harvard_raster.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"layer_id_s": "cite:SDE2.G7064_S2_1834_K3",
"layer_geom_type_s": "Raster",
"layer_modified_dt": "2014-05-27T18:09:36Z",
"solr_bbox": "30.013108 59.669749 30.875309 60.041712",
"solr_geom": "ENVELOPE(30.013108, 30.875309, 60.041712, 59.669749)",
"solr_year_i": 1834,
"solr_issued_dt": "2000-01-01T00:00:00Z"
Expand Down
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/public_iiif_princeton.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"layer_id_s": "02870w62c",
"layer_geom_type_s": "Raster",
"layer_modified_dt": "2014-10-09T18:00:18Z",
"solr_bbox": "-76.3394 38.6693 -72.1916 46.5798",
"solr_geom": "ENVELOPE(-76.3394, -72.1916, 46.5798, 38.6693)",
"solr_year_i": 1778
}
7 changes: 1 addition & 6 deletions spec/fixtures/solr_documents/public_polygon_mit.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@
"layer_id_s": "sde:SDE_DATA.US_MA_E25ZCTA5DCT_2000",
"layer_geom_type_s": "Polygon",
"layer_modified_dt": "2014-05-27T18:09:34Z",
"solr_bbox": "-73.533237 41.230345 -69.898565 42.888068",
"solr_ne_pt": "42.888068,-69.898565",
"solr_sw_pt": "41.230345,-73.533237",
"solr_geom": "ENVELOPE(-73.533237, -69.898565, 42.888068, 41.230345)",
"solr_year_i": 2000,
"solr_issued_dt": "2000-01-01T00:00:00Z",
"solr_wms_url": "http://arrowsmith.mit.edu:8080/geoserver/wms",
"solr_wfs_url": "http://arrowsmith.mit.edu:8080/geoserver/wfs"
"solr_issued_dt": "2000-01-01T00:00:00Z"
}
1 change: 0 additions & 1 deletion spec/fixtures/solr_documents/restricted-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@
"georss_box_s": "38.302994 -123.387366 39.398403 -122.52958",
"georss_polygon_s": "38.302994 -123.387366 39.398403 -123.387366 39.398403 -122.52958 38.302994 -122.52958 38.302994 -123.387366",
"solr_geom": "ENVELOPE(-123.387366, -122.52958, 39.398403, 38.302994)",
"solr_bbox": "-123.387366 38.302994 -122.52958 39.398403",
"solr_year_i": 2002
}
2 changes: 1 addition & 1 deletion spec/lib/geoblacklight/download/geojson_download_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe GeojsonDownload do
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') }
let(:document) { SolrDocument.new(layer_slug_s: 'test', solr_wfs_url: 'http://www.example.com/wfs', layer_id_s: 'stanford-test', solr_geom: 'ENVELOPE(-180, 180, 90, -90)') }
let(:download) { GeojsonDownload.new(document) }
describe '#initialize' do
it 'should initialize as a GeojsonDownload object with specific options' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/geoblacklight/download/geotiff_download_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe GeotiffDownload do
let(:document) { SolrDocument.new(layer_slug_s: 'test', layer_id_s: 'stanford-test', solr_bbox: '-180 -90 180 90') }
let(:document) { SolrDocument.new(layer_slug_s: 'test', layer_id_s: 'stanford-test', solr_geom: 'ENVELOPE(-180, 180, 90, -90)') }
let(:download) { GeotiffDownload.new(document) }
describe '#initialize' do
it 'should initialize as a GeotiffDownload object with specific options' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/geoblacklight/download/kmz_download_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe KmzDownload do
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') }
let(:document) { SolrDocument.new(layer_slug_s: 'test', solr_wfs_url: 'http://www.example.com/wfs', layer_id_s: 'stanford-test', solr_geom: 'ENVELOPE(-180, 180, 90, -90)') }
let(:download) { KmzDownload.new(document) }
describe '#initialize' do
it 'should initialize as a KmzDownload object with specific options' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/geoblacklight/download/shapefile_download_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe ShapefileDownload do
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') }
let(:document) { SolrDocument.new(layer_slug_s: 'test', solr_wfs_url: 'http://www.example.com/wfs', layer_id_s: 'stanford-test', solr_geom: 'ENVELOPE(-180, 180, 90, -90)') }
let(:download) { ShapefileDownload.new(document) }
describe '#initialize' do
it 'should initialize as a ShapefileDownload object with specific options' do
Expand Down

0 comments on commit efcaf7e

Please sign in to comment.