mapknitter-exporter 0.0.5 → 1.0.0
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/mapknitterExporter.rb +55 -29
- 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: 4746d00b0cdb35d3052ea1e29ebdea992ed259a1
|
|
4
|
+
data.tar.gz: 2615e67a59a4005470390718c5dab06563c81364
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1abc46a8e1990f43a3868b8a3fc1c7e50d16da4dfc575971251103bf1c3b2d1dbd13b04c17af83e40d5512e22e9e5c6d3fe7a310c977e21d768609451cf42db
|
|
7
|
+
data.tar.gz: 8457537423064abca2f24ad5621f58b3f142c3f0a5821eabbe6e7dc67cf505e238758b3fb36f21015116a0b5c8c6c177a03fc9299a19a85f5fd0653cf1e493dd
|
data/lib/mapknitterExporter.rb
CHANGED
|
@@ -27,28 +27,28 @@ class MapKnitterExporter
|
|
|
27
27
|
## Run on each image:
|
|
28
28
|
|
|
29
29
|
# pixels per meter = pxperm
|
|
30
|
-
def self.generate_perspectival_distort(pxperm, id, nodes_array, image_file_name, img_url, height, width
|
|
30
|
+
def self.generate_perspectival_distort(pxperm, id, nodes_array, image_file_name, img_url, height, width)
|
|
31
31
|
require 'net/http'
|
|
32
32
|
|
|
33
33
|
# everything in -working/ can be deleted;
|
|
34
34
|
# this is just so we can use the files locally outside of s3
|
|
35
35
|
working_directory = get_working_directory(id)
|
|
36
36
|
Dir.mkdir(working_directory) unless (File.exists?(working_directory) && File.directory?(working_directory))
|
|
37
|
-
local_location = "#{working_directory}#{id}-#{image_file_name}"
|
|
37
|
+
local_location = "#{working_directory}w#{id}-#{image_file_name}"
|
|
38
38
|
|
|
39
39
|
directory = warps_directory(id)
|
|
40
40
|
Dir.mkdir(directory) unless (File.exists?(directory) && File.directory?(directory))
|
|
41
|
-
completed_local_location = directory+id.to_s+'.png'
|
|
41
|
+
completed_local_location = directory + 'w' + id.to_s+'.png'
|
|
42
42
|
|
|
43
43
|
# everything -masked.png can be deleted
|
|
44
|
-
masked_local_location = directory+id.to_s+'-masked.png'
|
|
44
|
+
masked_local_location = directory + 'w' + id.to_s + '-masked.png'
|
|
45
45
|
# everything -mask.png can be deleted
|
|
46
|
-
mask_location = directory+id.to_s+'-mask.png'
|
|
46
|
+
mask_location = directory + 'w' + id.to_s + '-mask.png'
|
|
47
47
|
#completed_local_location = directory+id.to_s+'.tif'
|
|
48
48
|
# know everything -unwarped can be deleted
|
|
49
|
-
geotiff_location = directory+id.to_s+'-geo-unwarped.tif'
|
|
49
|
+
geotiff_location = directory + 'w' + id.to_s + '-geo-unwarped.tif'
|
|
50
50
|
# everything -geo WITH AN ID could be deleted, but there is a feature request to preserve these
|
|
51
|
-
warped_geotiff_location = directory+id.to_s+'-geo.tif'
|
|
51
|
+
warped_geotiff_location = directory + 'w' + id.to_s + '-geo.tif'
|
|
52
52
|
|
|
53
53
|
northmost = nodes_array.first['lat'].to_f
|
|
54
54
|
southmost = nodes_array.first['lat'].to_f
|
|
@@ -268,7 +268,7 @@ class MapKnitterExporter
|
|
|
268
268
|
warpables = warpables.sort{ |a,b| b['poly_area'] <=> a['poly_area'] }
|
|
269
269
|
end
|
|
270
270
|
warpables.each do |warpable|
|
|
271
|
-
wid = warpable['id'].to_s
|
|
271
|
+
wid = "w" + warpable['id'].to_s
|
|
272
272
|
geotiffs += ' '+directory+wid+'-geo.tif'
|
|
273
273
|
if first
|
|
274
274
|
gdalwarp = "gdalwarp -s_srs EPSG:3857 -te #{minlon} #{minlat} #{maxlon} #{maxlat} #{directory}#{wid}-geo.tif #{directory}#{id}-geo.tif"
|
|
@@ -282,14 +282,17 @@ class MapKnitterExporter
|
|
|
282
282
|
composite_location
|
|
283
283
|
end
|
|
284
284
|
|
|
285
|
-
# generates a tileset at
|
|
286
|
-
|
|
287
|
-
def self.generate_tiles(key, id, root)
|
|
285
|
+
# generates a tileset at public/tms/<id>/
|
|
286
|
+
def self.generate_tiles(key, id)
|
|
288
287
|
key = "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ" if key == "" # ugh, let's clean this up!
|
|
289
288
|
key = key || "AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ"
|
|
290
289
|
gdal2tiles = "gdal2tiles.py -k --s_srs EPSG:3857 -t #{id} -g #{key} public/warps/#{id}/#{id}-geo.tif public/tms/#{id}/"
|
|
291
290
|
puts gdal2tiles
|
|
292
|
-
system(self.ulimit+gdal2tiles)
|
|
291
|
+
if system(self.ulimit+gdal2tiles)
|
|
292
|
+
"public/tms/#{id}/"
|
|
293
|
+
else
|
|
294
|
+
false
|
|
295
|
+
end
|
|
293
296
|
end
|
|
294
297
|
|
|
295
298
|
# zips up tiles at public/tms/<id>.zip;
|
|
@@ -297,20 +300,29 @@ class MapKnitterExporter
|
|
|
297
300
|
rmzip = "cd public/tms/ && rm #{id}.zip && cd ../../"
|
|
298
301
|
system(rmzip)
|
|
299
302
|
zip = "cd public/tms/ && #{self.ulimit} zip -rq #{id}.zip #{id}/ && cd ../../"
|
|
300
|
-
system(zip)
|
|
303
|
+
if system(zip)
|
|
304
|
+
"public/tms/#{id}.zip"
|
|
305
|
+
else
|
|
306
|
+
false
|
|
307
|
+
end
|
|
301
308
|
end
|
|
302
309
|
|
|
303
310
|
# generates a tileset at public/tms/<id>/
|
|
304
|
-
def self.generate_jpg(id
|
|
305
|
-
imageMagick = "convert -background white -flatten public/warps/#{id}/#{id}-geo.tif
|
|
306
|
-
system(self.ulimit+imageMagick)
|
|
311
|
+
def self.generate_jpg(id)
|
|
312
|
+
imageMagick = "convert -background white -flatten public/warps/#{id}/#{id}-geo.tif public/warps/#{id}/#{id}.jpg"
|
|
313
|
+
if system(self.ulimit+imageMagick)
|
|
314
|
+
"public/warps/#{id}/#{id}.jpg"
|
|
315
|
+
else
|
|
316
|
+
false
|
|
317
|
+
end
|
|
307
318
|
end
|
|
308
319
|
|
|
309
320
|
# runs the above map functions while maintaining a record of state in an Export model;
|
|
310
321
|
# we'll be replacing the export model state with a flat status file
|
|
311
|
-
def self.run_export(user_id, resolution, export, id,
|
|
322
|
+
def self.run_export(user_id, resolution, export, id, warpables, key, ordered = false)
|
|
312
323
|
export.user_id = user_id if user_id
|
|
313
324
|
export.status = 'starting'
|
|
325
|
+
# we set these false again later...
|
|
314
326
|
export.tms = false
|
|
315
327
|
export.geotiff = false
|
|
316
328
|
export.zip = false
|
|
@@ -322,11 +334,11 @@ class MapKnitterExporter
|
|
|
322
334
|
w['nodes'] && w['nodes'].length > 0
|
|
323
335
|
end
|
|
324
336
|
|
|
325
|
-
directory = "
|
|
337
|
+
directory = "public/warps/#{id}/"
|
|
326
338
|
stdin, stdout, stderr = Open3.popen3('rm -r '+directory.to_s)
|
|
327
339
|
puts stdout.readlines
|
|
328
340
|
puts stderr.readlines
|
|
329
|
-
stdin, stdout, stderr = Open3.popen3("rm -r
|
|
341
|
+
stdin, stdout, stderr = Open3.popen3("rm -r public/tms/#{id}")
|
|
330
342
|
puts stdout.readlines
|
|
331
343
|
puts stderr.readlines
|
|
332
344
|
|
|
@@ -351,33 +363,47 @@ class MapKnitterExporter
|
|
|
351
363
|
ordered
|
|
352
364
|
)
|
|
353
365
|
|
|
354
|
-
|
|
366
|
+
identify = "identify -quiet -format '%b,%w,%h' #{composite_location}"
|
|
367
|
+
puts identify
|
|
368
|
+
info = (`#{identify}`).split(',')
|
|
355
369
|
puts info
|
|
356
370
|
|
|
357
371
|
if info[0] != ''
|
|
358
|
-
export.geotiff =
|
|
372
|
+
export.geotiff = composite_location
|
|
359
373
|
export.size = info[0]
|
|
360
374
|
export.width = info[1]
|
|
361
375
|
export.height = info[2]
|
|
362
|
-
export.cm_per_pixel = 100.0000/pxperm
|
|
363
|
-
export.status = 'tiling'
|
|
376
|
+
export.cm_per_pixel = 100.0000 / pxperm
|
|
364
377
|
export.save
|
|
365
378
|
end
|
|
366
379
|
|
|
380
|
+
# this could be forked
|
|
367
381
|
puts '> generating tiles'
|
|
368
|
-
export.tms =
|
|
369
|
-
export.status = '
|
|
382
|
+
export.tms = false
|
|
383
|
+
export.status = 'tiling'
|
|
370
384
|
export.save
|
|
385
|
+
export.tms = self.generate_tiles(key, id)
|
|
386
|
+
export.save unless export.tms == false
|
|
371
387
|
|
|
372
388
|
puts '> zipping tiles'
|
|
373
|
-
export.zip =
|
|
374
|
-
export.status = '
|
|
389
|
+
export.zip = false
|
|
390
|
+
export.status = 'zipping tiles'
|
|
375
391
|
export.save
|
|
392
|
+
export.zip = self.zip_tiles(id)
|
|
393
|
+
export.save unless export.zip == false
|
|
394
|
+
# end fork
|
|
376
395
|
|
|
396
|
+
# this could be forked
|
|
377
397
|
puts '> generating jpg'
|
|
378
|
-
export.jpg =
|
|
379
|
-
export.status = '
|
|
398
|
+
export.jpg = false
|
|
399
|
+
export.status = 'creating jpg'
|
|
380
400
|
export.save
|
|
401
|
+
export.jpg = self.generate_jpg(id)
|
|
402
|
+
unless export.jpg == false
|
|
403
|
+
export.status = 'complete'
|
|
404
|
+
export.save
|
|
405
|
+
end
|
|
406
|
+
# end fork
|
|
381
407
|
|
|
382
408
|
export.status
|
|
383
409
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mapknitter-exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeffrey Warren
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: The GDAL/ImageMagick-based exporter system from MapKnitter
|
|
14
14
|
email: jeff@unterbahn.com
|