snapa 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/lib/snapa.rb +2 -1
- data/lib/snapa/version.rb +1 -1
- data/public/map.html +21 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e782328109d352dfaddf33fb93c7896200058afd
|
4
|
+
data.tar.gz: f8ece8508d685e8e59782c90bb5a9fa4e0fb98be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3955e764eb1e524191beac8b5eb1bb89277ec71a3b4cbfa7431bc65b0d154e2bb02861047c4e3f59d217d7a7ce9b7897f1c8d95e83721fa21395923bdb7bfeb
|
7
|
+
data.tar.gz: f3820c4d9e0a72ddd15525b4541c52da8a63dcf1ac47f1f88f0c601e4ff0fd1a9119c0a8599491b11a1245ee29e0e2fc28add8d294c709c60633cd691d38278c
|
data/lib/snapa.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'snapa/version'
|
2
2
|
require 'rack/file'
|
3
|
+
require 'digest'
|
3
4
|
|
4
5
|
module Snapa
|
5
6
|
class File < Rack::File
|
@@ -21,7 +22,7 @@ module Snapa
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def path(request)
|
24
|
-
@path ||= F.join('/tmp/snapa', request.query_string + '.png')
|
25
|
+
@path ||= F.join('/tmp/snapa', ::Digest.hexencode(request.query_string) + '.png')
|
25
26
|
end
|
26
27
|
|
27
28
|
def _call(env)
|
data/lib/snapa/version.rb
CHANGED
data/public/map.html
CHANGED
@@ -44,9 +44,8 @@ var svg = d3.select("body").append("svg")
|
|
44
44
|
.attr("width", width)
|
45
45
|
.attr("height", height);
|
46
46
|
|
47
|
-
|
48
|
-
.scale(1)
|
49
|
-
.translate([width / 2, height / 2]);
|
47
|
+
window.projection = d3.geo.mercator()
|
48
|
+
.scale(1);
|
50
49
|
|
51
50
|
var path = d3.geo.path()
|
52
51
|
.projection(projection);
|
@@ -64,22 +63,30 @@ d3.json("countries.json", function(error, world) {
|
|
64
63
|
}
|
65
64
|
}
|
66
65
|
|
67
|
-
if (
|
66
|
+
if (highlight === undefined) {
|
67
|
+
projection
|
68
|
+
.scale(50)
|
69
|
+
.translate([width / 2], [height / 2]);
|
70
|
+
|
71
|
+
} else {
|
68
72
|
var centroid = d3.geo.centroid(highlight);
|
69
|
-
rotation
|
70
|
-
|
73
|
+
if (rotation[0] === '') {
|
74
|
+
rotation = [-centroid[0], 0, 0];
|
75
|
+
}
|
71
76
|
|
72
|
-
|
73
|
-
|
77
|
+
projection
|
78
|
+
.rotate(rotation);
|
74
79
|
|
75
|
-
if (scale === '') {
|
76
80
|
var bounds = path.bounds(highlight);
|
77
|
-
|
78
|
-
|
79
|
-
|
81
|
+
if (scale === '') {
|
82
|
+
scale = percent / Math.max((bounds[1][0] - bounds[0][0]) / width, (bounds[1][1] - bounds[0][1]) / height);
|
83
|
+
scale = Math.min(scale, 300);
|
84
|
+
}
|
80
85
|
|
81
|
-
|
82
|
-
|
86
|
+
projection
|
87
|
+
.scale(scale)
|
88
|
+
.translate([width / 2, (height / 2) + centroid[1] * 2.77]);
|
89
|
+
}
|
83
90
|
|
84
91
|
svg.selectAll("path")
|
85
92
|
.data(features)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Tillman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|