nswtopo 3.1 → 3.1.1
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/bin/nswtopo +1 -0
- data/lib/nswtopo/formats/svg.rb +1 -9
- data/lib/nswtopo/formats.rb +2 -2
- data/lib/nswtopo/gis/geojson/collection.rb +1 -1
- data/lib/nswtopo/layer/arcgis_raster.rb +3 -5
- data/lib/nswtopo/map.rb +18 -4
- data/lib/nswtopo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be473c574c562b474c1d4ef9b3a1dfc2c697993b1034990375f1405ebfabf1cb
|
4
|
+
data.tar.gz: 7b230fbd3f2e5164bb6452c10a15cd38424dbeea29c42947f6e36150a5784570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a925a874ddb9802d539712371e6dd06e28cb4a3fbdcd22d6b96a274131ae3a89244180d926d9f10a785db14ca98e0fdac4842a9766dad24475f3ff9c878e3c68
|
7
|
+
data.tar.gz: 145391125d1035c7bc5dc3b127389acc846277435624e971dcc82033089d784f5f84c0617ff7cc2af35884d750858b13d433185c73acb0fdd0eb363af9077393
|
data/bin/nswtopo
CHANGED
@@ -220,6 +220,7 @@ begin
|
|
220
220
|
parser.on "-b", "--bounds <bounds.kml>", Pathname, "bounds for map as KML or GPX file"
|
221
221
|
parser.on "-c", "--coords <x1,y1,...>", CoordList, "bounds for map as one or more WGS84",
|
222
222
|
"longitude/latitude pairs"
|
223
|
+
parser.on "-n", "--neatline <neatline.kml>", Pathname, "neatline for map as KML file"
|
223
224
|
parser.on "-d", "--dimensions <width,height>", Dimensions, "map dimensions in mm"
|
224
225
|
parser.on "-r", "--rotation <rotation>", Rotation, "map rotation angle in clockwise",
|
225
226
|
"degrees, 'auto' or 'magnetic'"
|
data/lib/nswtopo/formats/svg.rb
CHANGED
@@ -17,14 +17,6 @@ module NSWTopo
|
|
17
17
|
end
|
18
18
|
|
19
19
|
module Formats
|
20
|
-
def neatline_path_data
|
21
|
-
@neatline.coordinates.map do |ring|
|
22
|
-
ring.map do |point|
|
23
|
-
point.join(" ")
|
24
|
-
end.join(" L ").prepend("M ").concat(" Z")
|
25
|
-
end.join(" ")
|
26
|
-
end
|
27
|
-
|
28
20
|
def render_svg(svg_path, background:, **options)
|
29
21
|
if uptodate?("map.svg", "map.yml")
|
30
22
|
log_update "nswtopo: reading existing map SVG"
|
@@ -63,7 +55,7 @@ module NSWTopo
|
|
63
55
|
# add defs for map filters and masks
|
64
56
|
defs = svg.add_element("defs", "id" => "map.defs")
|
65
57
|
defs.add_element("rect", "id" => "map.rect", "width" => width, "height" => height)
|
66
|
-
defs.add_element("path", "id" => "map.neatline", "d" =>
|
58
|
+
defs.add_element("path", "id" => "map.neatline", "d" => @neatline.svg_path_data)
|
67
59
|
defs.add_element("clipPath", "id" => "map.clip").add_element("use", "href" => "#map.neatline")
|
68
60
|
|
69
61
|
# add a filter converting alpha channel to cutout mask
|
data/lib/nswtopo/formats.rb
CHANGED
@@ -78,8 +78,8 @@ module NSWTopo
|
|
78
78
|
raster_info = "%i×%i (%.1fMpx) map raster at %s" % [*raster_size, megapixels, ppi_info]
|
79
79
|
log_update "chrome: creating #{raster_info}"
|
80
80
|
|
81
|
-
|
82
|
-
(0...
|
81
|
+
raster_size.map do |px|
|
82
|
+
(0...px).step(TILE).map do |px|
|
83
83
|
[px, px * mm_per_px]
|
84
84
|
end
|
85
85
|
end.inject(&:product).map(&:transpose).map do |raster_offset, viewport_offset|
|
@@ -26,17 +26,15 @@ module NSWTopo
|
|
26
26
|
end || lods.last
|
27
27
|
tile_level, tile_resolution = lod.values_at "level", "resolution"
|
28
28
|
|
29
|
-
target_bbox.
|
30
|
-
|
31
|
-
end.transpose.map(&:minmax).zip(tile_sizes).map do |bound, tile_size|
|
32
|
-
bound / tile_resolution / tile_size
|
29
|
+
target_bbox.bounds.zip(origin, tile_sizes).map do |(min, max), origin, tile_size|
|
30
|
+
[(min - origin) / tile_resolution / tile_size, (max - origin) / tile_resolution / tile_size]
|
33
31
|
end.map do |min, max|
|
34
32
|
(min.floor..max.ceil).each_cons(2).to_a
|
35
33
|
end.inject(&:product).inject(GeoJSON::Collection.new(projection: service.projection)) do |tiles, (cols, rows)|
|
36
34
|
[cols, rows].zip(tile_sizes).map do |indices, tile_size|
|
37
35
|
indices.map { |index| index * tile_size * tile_resolution }
|
38
36
|
end.transpose.map do |corner|
|
39
|
-
corner
|
37
|
+
corner.zip(origin).map(&:sum)
|
40
38
|
end.transpose.then do |bounds|
|
41
39
|
ring = bounds.inject(&:product).values_at(0,2,3,1,0)
|
42
40
|
ullr = bounds.inject(&:product).values_at(1,2).flatten
|
data/lib/nswtopo/map.rb
CHANGED
@@ -16,12 +16,18 @@ module NSWTopo
|
|
16
16
|
extend Forwardable
|
17
17
|
delegate %i[write mtime read uptodate?] => :@archive
|
18
18
|
|
19
|
-
def self.init(archive, scale: 25000, rotation: 0.0, bounds: nil, coords: nil, dimensions: nil, margins: nil, **neatline_options)
|
19
|
+
def self.init(archive, scale: 25000, rotation: 0.0, bounds: nil, coords: nil, neatline: nil, dimensions: nil, margins: nil, **neatline_options)
|
20
20
|
points = case
|
21
21
|
when dimensions && margins
|
22
22
|
raise "can't specify both margins and map dimensions"
|
23
|
+
when dimensions && neatline
|
24
|
+
raise "can't specify both neatline and map dimensions"
|
25
|
+
when bounds && neatline
|
26
|
+
raise "can't specify both bounds and neatline"
|
27
|
+
when coords && neatline
|
28
|
+
raise "can't specify both neatline and map coordinates"
|
23
29
|
when coords && bounds
|
24
|
-
raise "can't specify both bounds
|
30
|
+
raise "can't specify both bounds and map coordinates"
|
25
31
|
when coords
|
26
32
|
GeoJSON.multipoint(coords)
|
27
33
|
when bounds
|
@@ -29,6 +35,10 @@ module NSWTopo
|
|
29
35
|
margins ||= [15, 15] unless dimensions || gps.polygons.any?
|
30
36
|
raise "no features found in %s" % bounds if gps.none?
|
31
37
|
end
|
38
|
+
when neatline
|
39
|
+
neatline = GPS.load(neatline)
|
40
|
+
raise "neatline must be a single polygon" unless neatline.polygon?
|
41
|
+
neatline
|
32
42
|
else
|
33
43
|
raise "no bounds file or map coordinates specified"
|
34
44
|
end.dissolve_points
|
@@ -73,8 +83,12 @@ module NSWTopo
|
|
73
83
|
raise "not enough information to calculate map size – check bounds file, or specify map dimensions or margins"
|
74
84
|
end
|
75
85
|
|
76
|
-
|
77
|
-
|
86
|
+
if neatline
|
87
|
+
neatline = neatline.reproject_to projection
|
88
|
+
else
|
89
|
+
ring = [0, 0].zip(dimensions).inject(&:product).values_at(0,2,3,1,0)
|
90
|
+
neatline = GeoJSON.polygon [ring], projection: projection, name: "neatline"
|
91
|
+
end
|
78
92
|
|
79
93
|
neatline_options.each do |key, value|
|
80
94
|
case key
|
data/lib/nswtopo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nswtopo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hollingworth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|