nswtopo 3.1.1 → 3.1.3
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 +3 -3
- data/lib/nswtopo/commands/scrape.rb +1 -1
- data/lib/nswtopo/formats.rb +11 -1
- data/lib/nswtopo/gis/dem.rb +2 -2
- data/lib/nswtopo/gis/geojson/collection.rb +3 -3
- data/lib/nswtopo/layer/contour.rb +2 -2
- data/lib/nswtopo/layer/raster.rb +3 -3
- data/lib/nswtopo/layer/relief.rb +2 -2
- data/lib/nswtopo/layer/vegetation.rb +1 -1
- data/lib/nswtopo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95688c5f09f158d8a3f31f800d05dbf68eb11b01f387c66d22a51d4cfdfd43df
|
4
|
+
data.tar.gz: e545a460b94c4836da02ebcec3af19f97bb2f8e3f9eae0ec811458716ec16249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b59a5be38b039fd42f105fb4d855805f070629ad665238db73f294cbfdb9c0cc19df5ae87bf3275f733db3974009598e9af1945eb0be8e92b54ad8c87cc7cf5e
|
7
|
+
data.tar.gz: f32a3ed4e30ee4e488a8953300dc84ab6bae3be7ab2d07b45625fe969b65ad12c87f9f96f277e627470424989d710f7fa0d6a1b793186494df1323a7ed3c9578
|
data/bin/nswtopo
CHANGED
@@ -41,8 +41,8 @@ begin
|
|
41
41
|
log_abort "ruby 3.1.4 or greater required"
|
42
42
|
when !Zlib.const_defined?(:GzipFile)
|
43
43
|
log_abort "ruby with GZIP_SUPPORT required"
|
44
|
-
when (GDAL_VERSION.split(/\D+/).take(3).map(&:to_i) <=> [3,
|
45
|
-
log_abort "GDAL 3.
|
44
|
+
when (GDAL_VERSION.split(/\D+/).take(3).map(&:to_i) <=> [3,8]) < 0
|
45
|
+
log_abort "GDAL 3.8 or greater required"
|
46
46
|
end
|
47
47
|
|
48
48
|
digits = '\d+(?:_\d+)*'
|
@@ -436,7 +436,7 @@ begin
|
|
436
436
|
when "inspect"
|
437
437
|
parser.banner = <<~EOF
|
438
438
|
*nswtopo* *inspect* - inspect data from an ArcGIS REST endpoint or local data source
|
439
|
-
usage: _nswtopo_
|
439
|
+
usage: _nswtopo_ _inspect_ [~options~] <url-or-path>
|
440
440
|
EOF
|
441
441
|
parser.on "-l", "--layer <layer>", String, "name of layer"
|
442
442
|
parser.on "-i", "--id <id>", Integer, "id number of layer"
|
@@ -29,7 +29,7 @@ module NSWTopo
|
|
29
29
|
queue = Queue.new
|
30
30
|
thread = Thread.new do
|
31
31
|
while page = queue.pop
|
32
|
-
*, status = Open3.capture3 *%W[ogr2ogr #{path} /vsistdin
|
32
|
+
*, status = Open3.capture3 *%W[ogr2ogr #{path} /vsistdin?buffer_limit=-1], *flags, *format_flags, stdin_data: page.to_json
|
33
33
|
format_flags = %w[-update -append]
|
34
34
|
queue.close unless status.success?
|
35
35
|
end
|
data/lib/nswtopo/formats.rb
CHANGED
@@ -98,12 +98,22 @@ module NSWTopo
|
|
98
98
|
vrt.elements.each("VRTDataset/VRTRasterBand/SimpleSource/DstRect") do |dst_rect|
|
99
99
|
dst_rect.add_attributes "xOff" => raster_offset[0], "yOff" => raster_offset[1]
|
100
100
|
end
|
101
|
+
vrt.elements["VRTDataset/VRTRasterBand[@band='1']"].deep_clone.then do |band|
|
102
|
+
vrt.elements["VRTDataset"].add_element(band)
|
103
|
+
band.add_attribute("band", 4)
|
104
|
+
band.elements["ColorInterp"].text = "Alpha"
|
105
|
+
band.elements["SimpleSource"]
|
106
|
+
end.then do |source|
|
107
|
+
source.name = "ComplexSource"
|
108
|
+
source.add_element("ScaleRatio").add_text("0")
|
109
|
+
source.add_element("ScaleOffset").add_text("255")
|
110
|
+
end unless vrt.elements["VRTDataset/VRTRasterBand[@band='4']"]
|
101
111
|
end
|
102
112
|
end.inject do |vrt, tile_vrt|
|
103
113
|
vrt.elements["VRTDataset/VRTRasterBand[@band='1']"].add_element tile_vrt.elements["VRTDataset/VRTRasterBand[@band='1']/SimpleSource"]
|
104
114
|
vrt.elements["VRTDataset/VRTRasterBand[@band='2']"].add_element tile_vrt.elements["VRTDataset/VRTRasterBand[@band='2']/SimpleSource"]
|
105
115
|
vrt.elements["VRTDataset/VRTRasterBand[@band='3']"].add_element tile_vrt.elements["VRTDataset/VRTRasterBand[@band='3']/SimpleSource"]
|
106
|
-
vrt.elements["VRTDataset/VRTRasterBand[@band='4']"].add_element tile_vrt.elements["VRTDataset/VRTRasterBand[@band='4']
|
116
|
+
vrt.elements["VRTDataset/VRTRasterBand[@band='4']"].add_element tile_vrt.elements["VRTDataset/VRTRasterBand[@band='4']/*[self::SimpleSource|self::ComplexSource]"]
|
107
117
|
vrt
|
108
118
|
end.tap do |vrt|
|
109
119
|
vrt.elements.each("VRTDataset/VRTRasterBand/@blockYSize", &:remove)
|
data/lib/nswtopo/gis/dem.rb
CHANGED
@@ -30,7 +30,7 @@ module NSWTopo
|
|
30
30
|
|
31
31
|
indexed_dem_path = temp_dir / "dem.#{index}.tif"
|
32
32
|
OS.gdalbuildvrt "-overwrite", "-allow_projection_difference", "-a_srs", projection, "-input_file_list", txt_path, vrt_path
|
33
|
-
OS.gdalwarp "-t_srs", @map.projection, "-tr", @mm_per_px, @mm_per_px, "-r", "bilinear", "-cutline", "GeoJSON:/vsistdin
|
33
|
+
OS.gdalwarp "-t_srs", @map.projection, "-tr", @mm_per_px, @mm_per_px, "-r", "bilinear", "-cutline", "GeoJSON:/vsistdin?buffer_limit=-1", "-crop_to_cutline", vrt_path, indexed_dem_path do |stdin|
|
34
34
|
stdin.puts cutline.to_json
|
35
35
|
end
|
36
36
|
indexed_dem_path
|
@@ -64,7 +64,7 @@ module NSWTopo
|
|
64
64
|
end
|
65
65
|
|
66
66
|
log_update "%s: smoothing DEM raster" % @name
|
67
|
-
OS.gdal_translate "/vsistdin
|
67
|
+
OS.gdal_translate "/vsistdin?buffer_limit=-1", blur_path do |stdin|
|
68
68
|
stdin.write xml
|
69
69
|
end
|
70
70
|
end
|
@@ -47,7 +47,7 @@ module NSWTopo
|
|
47
47
|
|
48
48
|
def reproject_to(projection)
|
49
49
|
return self if self.projection == projection
|
50
|
-
json = OS.ogr2ogr "-t_srs", projection, "-f", "GeoJSON", "-lco", "RFC7946=NO", "/vsistdout/", "GeoJSON:/vsistdin
|
50
|
+
json = OS.ogr2ogr "-t_srs", projection, "-f", "GeoJSON", "-lco", "RFC7946=NO", "/vsistdout/", "GeoJSON:/vsistdin?buffer_limit=-1" do |stdin|
|
51
51
|
stdin.puts to_json
|
52
52
|
end
|
53
53
|
Collection.load json, projection: projection
|
@@ -83,7 +83,7 @@ module NSWTopo
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def with_sql(sql, name: @name)
|
86
|
-
json = OS.ogr2ogr *%w[-f GeoJSON -lco RFC7946=NO /vsistdout/ GeoJSON:/vsistdin
|
86
|
+
json = OS.ogr2ogr *%w[-f GeoJSON -lco RFC7946=NO /vsistdout/ GeoJSON:/vsistdin?buffer_limit=-1 -dialect SQLite -sql], sql do |stdin|
|
87
87
|
stdin.puts to_json
|
88
88
|
end
|
89
89
|
Collection.load(json, projection: @projection).with_name(name)
|
@@ -123,7 +123,7 @@ module NSWTopo
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def clip(polygon)
|
126
|
-
OS.ogr2ogr "-f", "GeoJSON", "-lco", "RFC7946=NO", "-clipsrc", polygon.wkt, "/vsistdout/", "GeoJSON:/vsistdin
|
126
|
+
OS.ogr2ogr "-f", "GeoJSON", "-lco", "RFC7946=NO", "-clipsrc", polygon.wkt, "/vsistdout/", "GeoJSON:/vsistdin?buffer_limit=-1" do |stdin|
|
127
127
|
stdin.puts to_json
|
128
128
|
end.then do |json|
|
129
129
|
Collection.load json, projection: @projection
|
@@ -42,7 +42,7 @@ module NSWTopo
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def check_geos!
|
45
|
-
json = OS.ogr2ogr "-dialect", "SQLite", "-sql", "SELECT geos_version() AS version", "-f", "GeoJSON", "-lco", "RFC7946=NO", "/vsistdout/", "
|
45
|
+
json = OS.ogr2ogr "-dialect", "SQLite", "-sql", "SELECT geos_version() AS version", "-f", "GeoJSON", "-lco", "RFC7946=NO", "/vsistdout/", "GeoJSON:/vsistdin?buffer_limit=-1" do |stdin|
|
46
46
|
stdin.write GeoJSON::Collection.new.to_json
|
47
47
|
end
|
48
48
|
raise unless version = JSON.parse(json).dig("features", 0, "properties", "version")
|
@@ -107,7 +107,7 @@ module NSWTopo
|
|
107
107
|
end
|
108
108
|
|
109
109
|
contours.each_slice(100).inject(nil) do |update, features|
|
110
|
-
OS.ogr2ogr "-a_srs", @map.projection, "-nln", "contour", *update, "-simplify", @simplify, *db_flags, db_path, "GeoJSON:/vsistdin
|
110
|
+
OS.ogr2ogr "-a_srs", @map.projection, "-nln", "contour", *update, "-simplify", @simplify, *db_flags, db_path, "GeoJSON:/vsistdin?buffer_limit=-1" do |stdin|
|
111
111
|
stdin.write contours.with_features(features).to_json
|
112
112
|
end
|
113
113
|
%w[-update -append]
|
data/lib/nswtopo/layer/raster.rb
CHANGED
@@ -3,7 +3,7 @@ module NSWTopo
|
|
3
3
|
using Helpers
|
4
4
|
def create
|
5
5
|
Dir.mktmppath do |temp_dir|
|
6
|
-
args = ["-t_srs", @map.projection, "-r", "bilinear", "-cutline", "GeoJSON:/vsistdin
|
6
|
+
args = ["-t_srs", @map.projection, "-r", "bilinear", "-cutline", "GeoJSON:/vsistdin?buffer_limit=-1", "-te", *@map.te, "-of", "GTiff", "-co", "TILED=YES"]
|
7
7
|
args += ["-tr", @mm_per_px, @mm_per_px] if Numeric === @mm_per_px
|
8
8
|
OS.gdalwarp *args, get_raster(temp_dir), "/vsistdout/" do |stdin|
|
9
9
|
stdin.puts @map.cutline.to_json
|
@@ -31,7 +31,7 @@ module NSWTopo
|
|
31
31
|
end.then do |(width, height), (_, mm_per_px, *)|
|
32
32
|
image.add_attributes "width" => width, "height" => height, "transform" => "scale(#{mm_per_px})"
|
33
33
|
end
|
34
|
-
OS.gdal_translate "-of", "PNG", "-co", "ZLEVEL=9", "/vsistdin
|
34
|
+
OS.gdal_translate "-of", "PNG", "-co", "ZLEVEL=9", "/vsistdin?buffer_limit=-1", "/vsistdout/" do |stdin|
|
35
35
|
stdin.binmode.write tif
|
36
36
|
end.then do |png|
|
37
37
|
image.add_attributes "href" => "data:image/png;base64,#{Base64.encode64 png}", "image-rendering" => "optimizeQuality"
|
@@ -40,7 +40,7 @@ module NSWTopo
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def to_s
|
43
|
-
OS.gdalinfo "-json", "/vsistdin
|
43
|
+
OS.gdalinfo "-json", "/vsistdin?buffer_limit=-1" do |stdin|
|
44
44
|
stdin.binmode.write @map.read(filename)
|
45
45
|
end.then do |json|
|
46
46
|
JSON.parse(json).values_at "size", "geoTransform"
|
data/lib/nswtopo/layer/relief.rb
CHANGED
@@ -50,7 +50,7 @@ module NSWTopo
|
|
50
50
|
end.inject(&:merge)
|
51
51
|
|
52
52
|
log_update "%s: calculating DEM" % @name
|
53
|
-
OS.gdal_grid "-a", "linear:radius=0:nodata=-9999", "-zfield", "elevation", "-ot", "Float32", "-txe", *bounds[0], "-tye", *bounds[1], "-outsize", *outsize, "
|
53
|
+
OS.gdal_grid "-a", "linear:radius=0:nodata=-9999", "-zfield", "elevation", "-ot", "Float32", "-txe", *bounds[0], "-tye", *bounds[1], "-outsize", *outsize, "GeoJSON:/vsistdin?buffer_limit=-1", dem_path do |stdin|
|
54
54
|
stdin.puts collection.to_json
|
55
55
|
end
|
56
56
|
|
@@ -64,7 +64,7 @@ module NSWTopo
|
|
64
64
|
begin
|
65
65
|
log_update "%s: generating shaded relief" % @name
|
66
66
|
OS.gdaldem *%W[hillshade -q -compute_edges -s #{@map.scale / 1000.0} -z #{@factor} -az #{@azimuth} -#{@method}], dem_path, raw_path
|
67
|
-
OS.gdalwarp "-t_srs", @map.projection, "-cutline", "GeoJSON:/vsistdin
|
67
|
+
OS.gdalwarp "-t_srs", @map.projection, "-cutline", "GeoJSON:/vsistdin?buffer_limit=-1", "-crop_to_cutline", raw_path, tif_path do |stdin|
|
68
68
|
stdin.puts cutline.to_json
|
69
69
|
end
|
70
70
|
rescue OS::Error
|
@@ -64,7 +64,7 @@ module NSWTopo
|
|
64
64
|
tif_path = temp_dir / "source.tif"
|
65
65
|
vrt_path = temp_dir / "source.vrt"
|
66
66
|
|
67
|
-
args = ["-t_srs", @map.projection, "-r", "nearest", "-cutline", "GeoJSON:/vsistdin
|
67
|
+
args = ["-t_srs", @map.projection, "-r", "nearest", "-cutline", "GeoJSON:/vsistdin?buffer_limit=-1", "-crop_to_cutline"]
|
68
68
|
args += ["-tr", @mm_per_px, @mm_per_px] if @mm_per_px
|
69
69
|
OS.gdalwarp *args, *vrt_paths, tif_path do |stdin|
|
70
70
|
stdin.puts @map.cutline.to_json
|
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: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hollingworth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements:
|
153
|
-
- GDAL >= v3.
|
153
|
+
- GDAL >= v3.8
|
154
154
|
- Google Chrome >= v112
|
155
155
|
rubygems_version: 3.3.26
|
156
156
|
signing_key:
|