blacklight-maps 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec8bdbdd2134f3c1f7f3762f61a91c387fcb39b
|
4
|
+
data.tar.gz: 02828cec807ece0e8564c74f6d424d3f787b9534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c3cb7694eb528ca1ff0d6f45454bb196591ee9c22bed67a8b74d385ac01ec072b1dd35f48cfa01a8b1fa410338ed8579694ea01aa20f9554d4b1d72343f092c
|
7
|
+
data.tar.gz: 75f2982504e7cf96e7d369e365dc7ad371342f388b274e3ea486752be3cd2138ec225a629d161fd0a2c67955cc6cbe118e0e1668a70aaad6d9f2ead52c35008e
|
@@ -85,9 +85,8 @@ module BlacklightMaps
|
|
85
85
|
# turn bboxes into points for index view so we don't get weird mix of boxes and markers
|
86
86
|
def build_feature_from_geojson(loc, hits = nil)
|
87
87
|
geojson_hash = JSON.parse(loc).deep_symbolize_keys
|
88
|
-
|
89
88
|
if @action != "show" && geojson_hash[:bbox]
|
90
|
-
geojson_hash[:geometry][:coordinates] = Geometry::BoundingBox.new(geojson_hash[:bbox]).find_center
|
89
|
+
geojson_hash[:geometry][:coordinates] = Geometry::Point.new(Geometry::BoundingBox.new(geojson_hash[:bbox]).find_center).normalize_for_search
|
91
90
|
geojson_hash[:geometry][:type] = "Point"
|
92
91
|
geojson_hash.delete(:bbox)
|
93
92
|
end
|
@@ -104,7 +103,7 @@ module BlacklightMaps
|
|
104
103
|
if coords.scan(/[\s]/).length == 3 # bbox
|
105
104
|
if @action != "show"
|
106
105
|
geojson_hash[:geometry][:type] = "Point"
|
107
|
-
geojson_hash[:geometry][:coordinates] = Geometry::BoundingBox.from_lon_lat_string(coords).find_center
|
106
|
+
geojson_hash[:geometry][:coordinates] = Geometry::Point.new(Geometry::BoundingBox.from_lon_lat_string(coords).find_center).normalize_for_search
|
108
107
|
else
|
109
108
|
coords_array = coords.split(' ').map { |v| v.to_f }
|
110
109
|
geojson_hash[:bbox] = coords_array
|
@@ -35,5 +35,36 @@ module BlacklightMaps
|
|
35
35
|
new(points.split(' '))
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
# This class contains Point objects and methods for working with them
|
40
|
+
class Point
|
41
|
+
|
42
|
+
# points is an array corresponding to the longitude and latitude values
|
43
|
+
# [long, lat]
|
44
|
+
def initialize(points)
|
45
|
+
@long = points[0].to_f
|
46
|
+
@lat = points[1].to_f
|
47
|
+
end
|
48
|
+
|
49
|
+
# returns a string that can be used as the value of solr_parameters[:pt]
|
50
|
+
# normalizes any long values >180 or <-180
|
51
|
+
def normalize_for_search
|
52
|
+
case
|
53
|
+
when @long > 180
|
54
|
+
@long -= 360
|
55
|
+
when @long < -180
|
56
|
+
@long += 360
|
57
|
+
end
|
58
|
+
[@long,@lat]
|
59
|
+
end
|
60
|
+
|
61
|
+
# Creates a new point from from a coordinate string
|
62
|
+
# "-50,100" (lat,long)
|
63
|
+
def self.from_lat_lon_string(points)
|
64
|
+
new(points.split(',').reverse)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
38
69
|
end
|
39
70
|
end
|
@@ -131,6 +131,18 @@ describe "BlacklightMaps::GeojsonExport" do
|
|
131
131
|
expect(@output[:geometry][:coordinates]).to eq([82.7789705, 21.12899555])
|
132
132
|
end
|
133
133
|
|
134
|
+
describe "bounding box that crosses the dateline" do
|
135
|
+
|
136
|
+
before do
|
137
|
+
@output = subject.send(:build_feature_from_coords, '1.162386 6.7535159 -179.395555 35.5044752', 1)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should set a center point with a long value between -180 and 180" do
|
141
|
+
expect(@output[:geometry][:coordinates]).to eq([90.88341550000001,21.12899555])
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
134
146
|
end
|
135
147
|
|
136
148
|
describe "catalog#show view" do
|
@@ -1,24 +1,43 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe BlacklightMaps::Geometry do
|
4
4
|
|
5
|
-
|
6
|
-
let(:bbox_california) { BlacklightMaps::Geometry::BoundingBox.from_lon_lat_string('-124.4096196 32.5342321 -114.131211 42.0095169') }
|
7
|
-
let(:bbox_dateline) {BlacklightMaps::Geometry::BoundingBox.from_lon_lat_string('165 30 -172 -20') }
|
5
|
+
describe "BlacklightMaps::Geometry::BoundingBox" do
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
let(:bbox) { BlacklightMaps::Geometry::BoundingBox.from_lon_lat_string('-100 -50 100 50') }
|
8
|
+
let(:bbox_california) { BlacklightMaps::Geometry::BoundingBox.from_lon_lat_string('-124.4096196 32.5342321 -114.131211 42.0095169') }
|
9
|
+
let(:bbox_dateline) {BlacklightMaps::Geometry::BoundingBox.from_lon_lat_string('165 30 -172 -20') }
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
it "should instantiate Geometry::BoundingBox" do
|
12
|
+
expect(bbox.class).to eq(::BlacklightMaps::Geometry::BoundingBox)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return center of simple bounding box" do
|
16
|
+
expect(bbox.find_center).to eq([0.0, 0.0])
|
17
|
+
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
it "should return center of California bounding box" do
|
20
|
+
expect(bbox_california.find_center).to eq([-119.2704153, 37.271874499999996])
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return correct dateline bounding box" do
|
24
|
+
expect(bbox_dateline.find_center).to eq([-183.5, 5])
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
describe "BlacklightMaps::Geometry::Point" do
|
29
|
+
|
30
|
+
let(:point) { BlacklightMaps::Geometry::Point.from_lat_lon_string('20,120') }
|
31
|
+
let(:unparseable_point) { BlacklightMaps::Geometry::Point.from_lat_lon_string('35.86166,-184.195397') }
|
32
|
+
|
33
|
+
it "should instantiate Geometry::Point" do
|
34
|
+
expect(point.class).to eq(::BlacklightMaps::Geometry::Point)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return a Solr-parseable coordinate if @long is > 180 or < -180" do
|
38
|
+
expect(unparseable_point.normalize_for_search).to eq([175.804603,35.86166])
|
39
|
+
end
|
40
|
+
|
23
41
|
end
|
42
|
+
|
24
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-maps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|