mapsnatcher 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/VERSION +1 -1
- data/bin/mapsnatcher +25 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 565027095fb4c152f3ecb41a1f21b3eefaeff40674fb1fef5c9c0338b367874b
|
4
|
+
data.tar.gz: fe2dabf2468133590feb71f27e1f53fa16b7e33a82398ca22d03ae1de50a73be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3708d7ba9dcda65acfcdc0163e5389ea5e2d72bda7b81878b4f8f2e0db5204a14af5407cd342e82fc6e56ee52dabab3db3e4bd63231ebe7a82a899cf79bcd1c9
|
7
|
+
data.tar.gz: 9cdaa0b8e52029e65dc4603410cdd3be473ffb94e6e32c2edefe2e76cfd47bd2f9f72179776f8a900b9b8cec7c9c4bf3075e918a6514b21ec0b4c5a5ad397e31
|
data/README.md
CHANGED
@@ -9,6 +9,20 @@ You can use a tool such as
|
|
9
9
|
[ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html) to find
|
10
10
|
these URLs easily.
|
11
11
|
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
You will need ImageMagick and its development headers installed in order to
|
15
|
+
build the dependencies. For Ubuntu these are:
|
16
|
+
|
17
|
+
```sudo apt-get install imagemagick libmagickwand-dev```
|
18
|
+
|
19
|
+
Once set up, install through RubyGems:
|
20
|
+
|
21
|
+
```gem install mapsnatcher```
|
22
|
+
|
23
|
+
To process larger maps, you may need to comment out or modify the resource
|
24
|
+
policies in `/etc/ImageMagick-6/policy.xml`.
|
25
|
+
|
12
26
|
## Usage
|
13
27
|
|
14
28
|
Usage is as follows:
|
@@ -24,3 +38,5 @@ boundaries that you would like to capture.
|
|
24
38
|
If you are unsure of the boundaries and would like to capture the entire map,
|
25
39
|
add the `-b` argument and you will only need to enter one valid coordinate;
|
26
40
|
`mapsnatcher` will do the rest.
|
41
|
+
|
42
|
+
If you would like to save the tiles, add the `-s` argument.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1
|
1
|
+
0.1.1
|
data/bin/mapsnatcher
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "fileutils"
|
4
|
-
require "yaml"
|
5
4
|
require "open-uri"
|
6
5
|
require "net/http"
|
7
6
|
require "rmagick"
|
8
7
|
include Magick
|
9
8
|
|
10
9
|
TEMP_DIR = "./.ms.tmp"
|
10
|
+
TILES_DIR = "./tiles"
|
11
11
|
|
12
12
|
# False if URL returns a 200
|
13
13
|
#
|
@@ -34,6 +34,7 @@ if ARGV.empty? or %w[-h --help].include? ARGV.first
|
|
34
34
|
puts " in the URL. The first number is typically the zoom level, which is constant."
|
35
35
|
puts
|
36
36
|
puts " [-b] find outer bounds of map automatically"
|
37
|
+
puts " [-s] save tiles to a directory ./tiles/"
|
37
38
|
exit 0
|
38
39
|
end
|
39
40
|
|
@@ -51,10 +52,16 @@ elsif !Dir.empty? TEMP_DIR
|
|
51
52
|
puts
|
52
53
|
end
|
53
54
|
|
54
|
-
|
55
|
+
save_tiles = false
|
56
|
+
if (args = ARGV).include? "-s"
|
57
|
+
args -= ["-s"]
|
58
|
+
save_tiles = true
|
59
|
+
end
|
60
|
+
|
61
|
+
if args.include? "-b"
|
55
62
|
# Automatic boundary mode
|
56
63
|
|
57
|
-
url = (
|
64
|
+
url = (args - ["-b"]).first
|
58
65
|
|
59
66
|
# CLI input function
|
60
67
|
#
|
@@ -104,7 +111,7 @@ if ARGV.include? "-b"
|
|
104
111
|
else
|
105
112
|
# User input coordinate mode
|
106
113
|
|
107
|
-
url =
|
114
|
+
url = args.first
|
108
115
|
|
109
116
|
# CLI input function
|
110
117
|
#
|
@@ -141,7 +148,8 @@ end
|
|
141
148
|
# Use the tile at 0, 0 to calculate final image size
|
142
149
|
sample = Image.from_blob(URI.open(build_url url, x_range.first, y_range.first).read).first
|
143
150
|
final_size = {x: sample.columns * x_range.size, y: sample.rows * y_range.size}
|
144
|
-
|
151
|
+
format = sample.format
|
152
|
+
puts "Image found, #{format} size #{final_size[:x]}x#{final_size[:y]}"
|
145
153
|
puts
|
146
154
|
|
147
155
|
dl_counter = 0
|
@@ -153,16 +161,17 @@ y_range.each do |y|
|
|
153
161
|
x_range.each do |x|
|
154
162
|
print "Downloading... [#{dl_counter += 1}/#{dl_total}]\r"
|
155
163
|
|
156
|
-
temp = "#{TEMP_DIR}/#{x}_#{y}.
|
164
|
+
temp = "#{TEMP_DIR}/#{x}_#{y}.#{format.downcase}"
|
157
165
|
if File.exists? temp
|
158
166
|
# Load the backup file
|
159
|
-
|
167
|
+
img = Image.read(temp).first
|
160
168
|
else
|
161
169
|
blob = URI.open(build_url url, x, y).read
|
162
|
-
File.open(temp, "w") { |f| f.write
|
170
|
+
File.open(temp, "w") { |f| f.write blob }
|
171
|
+
img = Image.from_blob(blob).first
|
163
172
|
end
|
164
173
|
|
165
|
-
row.push
|
174
|
+
row.push img
|
166
175
|
end
|
167
176
|
|
168
177
|
stitch.push row.append(false)
|
@@ -188,5 +197,11 @@ print "Enter file name for map: "
|
|
188
197
|
filename = STDIN.gets.chomp
|
189
198
|
print "Saving, this may take a minute..."
|
190
199
|
stitch.append(true).write filename
|
191
|
-
FileUtils.rm_rf TEMP_DIR
|
192
200
|
puts "\nImage written to: #{filename}"
|
201
|
+
|
202
|
+
if save_tiles
|
203
|
+
File.rename TEMP_DIR, TILES_DIR
|
204
|
+
puts "Tiles saved to: #{TILES_DIR.match /\w+/}/"
|
205
|
+
else
|
206
|
+
FileUtils.rm_rf TEMP_DIR
|
207
|
+
end
|