snapa 0.0.4 → 0.0.5

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: a443e13cbefe386b96caeec8c81e195de7a37fec
4
- data.tar.gz: 5f0b8d512eaa7b8673fe7063af3d6a59b248ea1d
3
+ metadata.gz: e782328109d352dfaddf33fb93c7896200058afd
4
+ data.tar.gz: f8ece8508d685e8e59782c90bb5a9fa4e0fb98be
5
5
  SHA512:
6
- metadata.gz: 5c383eac3a661731254b0328fa1c51fe1648ef56f71f1ffb8965896f572a190c1afc00ae310031f164e1ce74a0559ec84e846d81d55296184e50a40183f5da6e
7
- data.tar.gz: 5ed9aed27c694ce74da3e59d0b1c8755a13f4b37061cbe2bd98dcb7d4ff6a4f5d36bd378443b33ab44b7c13ba5c76462ed251edd9095e9c812279154c910773d
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
@@ -1,3 +1,3 @@
1
1
  module Snapa
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
- var projection = d3.geo.mercator()
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 (rotation[0] === '') {
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 = [-centroid[0], -centroid[1], 0];
70
- }
73
+ if (rotation[0] === '') {
74
+ rotation = [-centroid[0], 0, 0];
75
+ }
71
76
 
72
- projection
73
- .rotate(rotation);
77
+ projection
78
+ .rotate(rotation);
74
79
 
75
- if (scale === '') {
76
80
  var bounds = path.bounds(highlight);
77
- scale = percent / Math.max((bounds[1][0] - bounds[0][0]) / width, (bounds[1][1] - bounds[0][1]) / height);
78
- scale = Math.min(scale, 1000);
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
- projection
82
- .scale(scale);
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
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-12 00:00:00.000000000 Z
11
+ date: 2013-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack