open_places 0.0.1 → 0.0.2
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: 8ebc05f7e2896ab593680b3ed93bb6e5263de0d7
|
4
|
+
data.tar.gz: ac3dc9718e63adac690b42bd285f221f51a6e1ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ee5557cef56c3f3692810ac0d3ae22bb9b35f7ab97134874093f7be06c04186fe176409cabf812cf365ba42b52fc8480a90b666dac805248bd6161398517ecb
|
7
|
+
data.tar.gz: 7a14007363c7e6e1535fe2a6e6800867e094b53277a5b35019453c9391657b20c9d0868dd66e23441ef9ba391827f07481cade5275e7a18aa402a5b5e257caa8
|
@@ -9,9 +9,9 @@ module OpenPlaces
|
|
9
9
|
op = (params.keys & ['q', 'like', 'contains', 'starts', 'ends']).flatten.shift
|
10
10
|
@results = OpenPlaces::Geo
|
11
11
|
@results = @results.where(geotype: params[:type].split(",").map{|t| "OpenPlaces::#{t}" }) if params[:type].present?
|
12
|
-
@results = @results.near(params[:near]) if params[:near].present?
|
13
|
-
@results = @results.autocomplete(query_string, op) if query_string.present?
|
14
12
|
@results = @results.order('scalerank ASC')
|
13
|
+
@results = @results.autocomplete(query_string, op) if query_string.present?
|
14
|
+
@results = @results.near(params[:near]) if params[:near].present?
|
15
15
|
@results = @results.limit(params[:limit])
|
16
16
|
|
17
17
|
respond_to do |format|
|
@@ -37,13 +37,14 @@ module OpenPlaces
|
|
37
37
|
end
|
38
38
|
}
|
39
39
|
|
40
|
-
scope :near, -> (here=false,
|
40
|
+
scope :near, -> (here=false, query=self.all){
|
41
41
|
return query unless here
|
42
42
|
select("*,round(cast((ST_Distance_Sphere(latlng, ST_SetSRID(ST_MakePoint(#{here.toLngLat}), 4326))*0.000621371) AS NUMERIC),2) AS distance").order("latlng <-> st_setsrid(st_makepoint(#{here.toLngLat}),4326) ASC")
|
43
43
|
}
|
44
44
|
|
45
|
-
scope :
|
46
|
-
|
45
|
+
scope :within, -> (here=false, within='5', query=self.all){
|
46
|
+
return query unless here
|
47
|
+
where("ST_DWithin(latlng, ST_SetSRID(ST_MakePoint(#{here.toLngLat}), 4326), #{within})")
|
47
48
|
}
|
48
49
|
|
49
50
|
scope :to_geojson, -> (field="geom", query=self.all) {
|
data/lib/open_places/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_places
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ty Rauber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|