|
@@ -2,7 +2,10 @@ extends Node
|
|
|
|
|
|
var Downloader = preload("res://downloader.gd")
|
|
|
|
|
|
-var datafile = "height/SLDEM2015_512_00N_30N_000_045_FLOAT.IMG"
|
|
|
+var filePrefix = "user://topo"
|
|
|
+var formatString = "%s/sldem2015_%s_%02d%s_%02d%s_%03d_%03d_float.img"
|
|
|
+# example sldem2015_512_00n_30n_000_045_float.img
|
|
|
+var datafile = "user://topo/sldem2015_512_00n_30n_000_045_float.img"
|
|
|
var samplesPerLine = 23040
|
|
|
var lines = 15360
|
|
|
var offset = 1737.4#*1000
|
|
@@ -20,16 +23,16 @@ var file: File
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
func open():
|
|
|
file = File.new()
|
|
|
- if not file.file_exists("user://"+datafile):
|
|
|
- var downloader = Downloader.new()
|
|
|
- add_child(downloader)
|
|
|
- downloader.load(datafile, "height")
|
|
|
- yield(downloader, "request_completed")
|
|
|
- file.open("user://"+datafile, File.READ)
|
|
|
+ print("opening topo: "+getFilename())
|
|
|
+ file.open(getFilename(), File.READ)
|
|
|
|
|
|
func close():
|
|
|
file.close()
|
|
|
- queue_free()
|
|
|
+ #queue_free()
|
|
|
+
|
|
|
+func clear():
|
|
|
+ file.close()
|
|
|
+ cache = {}
|
|
|
|
|
|
func cacheArea(latMinIN, latMaxIN, lonMinIN, lonMaxIN):
|
|
|
if not _validate(latMinIN,lonMinIN) and not _validate(latMaxIN,lonMaxIN) :
|
|
@@ -65,6 +68,17 @@ func _validate(lat,lon):
|
|
|
return true
|
|
|
return false
|
|
|
|
|
|
+func getFilename():
|
|
|
+ # example sldem2015_512_00n_30n_000_045_float.img
|
|
|
+ # "%s/sldem2015_%s_%0*d%s_%0*d%s_%00*d_%00*d_float.img"
|
|
|
+ var orientation: String
|
|
|
+ if latMin >= 0:
|
|
|
+ orientation = "n"
|
|
|
+ else:
|
|
|
+ orientation = "s"
|
|
|
+ var properties = [filePrefix, resolution, latMin, orientation, latMax, orientation, lonMin, lonMax]
|
|
|
+ return formatString % properties
|
|
|
+
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
#func _process(delta):
|
|
|
# pass
|