12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- extends Node
- var datafile = "user://sldem2015_512_00n_30n_000_045_float.img"
- var samplesPerLine = 23040
- var lines = 15360
- var offset = 1737.4
- var scaleFact = 1
- var resolution = 512
- var latMin = 0
- var latMax = 30
- var lonMin = 0
- var lonMax = 45
- var cache = {}
- var file: File
- # Called when the node enters the scene tree for the first time.
- func open():
- file = File.new()
- file.open(datafile, File.READ)
-
- func close():
- file.close()
- queue_free()
-
- func cacheArea(latMinIN, latMaxIN, lonMinIN, lonMaxIN):
- if not _validate(latMinIN,lonMinIN) and not _validate(latMaxIN,lonMaxIN) :
- print("out of scope!")
- return
-
- var lat = latMinIN
- while lat <= latMaxIN:
- cache[lat]={}
- file.seek(lat*resolution*samplesPerLine*4 + lonMinIN*resolution*4)
- var lon = lonMinIN
- while lon <= lonMaxIN:
- cache[lat][lon] = file.get_float()
- lon += 1.0/float(resolution)
- lat += 1.0/float(resolution)
- return
-
- func read(lat,lon):
- if _validate(lat,lon):
- return cache[lat][lon]
- else:
- print("out of scope!")
- func _validate(lat,lon):
- if lat <= latMax and lat >= latMin and lon <= lonMax and lon >= lonMin:
- return true
- return false
- # Called every frame. 'delta' is the elapsed time since the previous frame.
- #func _process(delta):
- # pass
|