Further corrections in resource allocation code
This commit is contained in:
parent
4ab426308b
commit
f460964722
10
layergen.py
10
layergen.py
@ -293,6 +293,16 @@ class mstr_layergen:
|
|||||||
srcstr = srcstr + str(src[s])
|
srcstr = srcstr + str(src[s])
|
||||||
if s < len(src)-1:
|
if s < len(src)-1:
|
||||||
srcstr = srcstr + ","
|
srcstr = srcstr + ","
|
||||||
|
|
||||||
|
# Failsafe
|
||||||
|
if srcstr == "0":
|
||||||
|
srcstr = ""
|
||||||
|
numbers = list(range(1, 16))
|
||||||
|
src = random.sample(numbers, 5)
|
||||||
|
for s in range(len(src)):
|
||||||
|
srcstr = srcstr + str(src[s])
|
||||||
|
if s < len(src)-1:
|
||||||
|
srcstr = srcstr + ","
|
||||||
|
|
||||||
# Patch and border sources. There can only be one for each.
|
# Patch and border sources. There can only be one for each.
|
||||||
brd_src = None
|
brd_src = None
|
||||||
|
@ -37,6 +37,7 @@ class mstr_orthographic:
|
|||||||
self._vstep = self._findVerticalStepping()
|
self._vstep = self._findVerticalStepping()
|
||||||
self._latlngfld = self.latlng_folder([lat,lng])
|
self._latlngfld = self.latlng_folder([lat,lng])
|
||||||
self._prep = prep
|
self._prep = prep
|
||||||
|
self._tiles_visited = []
|
||||||
mstr_msg("orthographic", "Initiated with LAT: " + str(lat) + ", LNG: " + str(lng))
|
mstr_msg("orthographic", "Initiated with LAT: " + str(lat) + ", LNG: " + str(lng))
|
||||||
|
|
||||||
|
|
||||||
@ -440,6 +441,11 @@ class mstr_orthographic:
|
|||||||
|
|
||||||
# We now need to "raytrace" the resources for correct placement
|
# We now need to "raytrace" the resources for correct placement
|
||||||
mstr_msg("orthographic", "Performing resource plamement tracing for tile")
|
mstr_msg("orthographic", "Performing resource plamement tracing for tile")
|
||||||
|
|
||||||
|
# Let's set up an array which keeps track of all used tiles, per resource
|
||||||
|
|
||||||
|
for l in mstr_ortho_layers:
|
||||||
|
self._tiles_visited.append([(l[0], l[1])]) # Store tag and value as tuple for each possible resource
|
||||||
|
|
||||||
for lat_grid in range(1, maxlatlng[0]+1):
|
for lat_grid in range(1, maxlatlng[0]+1):
|
||||||
for lng_grid in range(1, maxlatlng[1]+1):
|
for lng_grid in range(1, maxlatlng[1]+1):
|
||||||
@ -451,11 +457,37 @@ class mstr_orthographic:
|
|||||||
|
|
||||||
for l in range(0, len(fnlines)):
|
for l in range(0, len(fnlines)):
|
||||||
lyr = fnlines[l].split(" ")
|
lyr = fnlines[l].split(" ")
|
||||||
|
|
||||||
|
vstidx = -1
|
||||||
|
for vst in range(0, len(self._tiles_visited)):
|
||||||
|
if self._tiles_visited[vst][0][0] == lyr[0] and self._tiles_visited[vst][0][1] == lyr[1]:
|
||||||
|
vstidx = vst
|
||||||
|
break
|
||||||
|
|
||||||
tp = mstr_tileprep(self._lat, self._long, lat_grid, lng_grid, lyr[0], lyr[1], None, False)
|
tp = mstr_tileprep(self._lat, self._long, lat_grid, lng_grid, lyr[0], lyr[1], None, False)
|
||||||
tp._setLatLngFold(self._latlngfld)
|
tp._setLatLngFold(self._latlngfld)
|
||||||
|
tp._setAlreadyVisitedTiles(self._tiles_visited[vstidx])
|
||||||
tp._placeTileSources(mlat, mlng)
|
tp._placeTileSources(mlat, mlng)
|
||||||
|
self.adjust_tiles_visited(lyr[0], lyr[1], tp._all_visited)
|
||||||
|
|
||||||
|
|
||||||
|
# Adjust the tiles visited for one resource
|
||||||
|
def adjust_tiles_visited(self, tag, value, tiles):
|
||||||
|
lyridx = -1
|
||||||
|
for v in range(0, len(self._tiles_visited)):
|
||||||
|
if self._tiles_visited[v][0][0] == tag and self._tiles_visited[v][0][1] == value:
|
||||||
|
lyridx = v
|
||||||
|
break
|
||||||
|
|
||||||
|
for t in range(1, len(tiles)):
|
||||||
|
fnd = False
|
||||||
|
for v in range(1, len(self._tiles_visited[lyridx])):
|
||||||
|
if self._tiles_visited[lyridx][v][0] == tiles[t][0] and self._tiles_visited[lyridx][v][1] == tiles[t][1]:
|
||||||
|
fnd = True
|
||||||
|
break
|
||||||
|
if fnd == False:
|
||||||
|
self._tiles_visited[lyridx].append((tiles[t][0], tiles[t][1]))
|
||||||
|
|
||||||
# Generates X-Plane 11/12 scenery with
|
# Generates X-Plane 11/12 scenery with
|
||||||
# - the finished orthos
|
# - the finished orthos
|
||||||
# - a current LIDAR scan of the terrain
|
# - a current LIDAR scan of the terrain
|
||||||
|
12
tileprep.py
12
tileprep.py
@ -39,6 +39,8 @@ class mstr_tileprep:
|
|||||||
self._mask = mask
|
self._mask = mask
|
||||||
latlngfld = xplane_latlng_folder([lat, lng])
|
latlngfld = xplane_latlng_folder([lat, lng])
|
||||||
self._tileinfo = mstr_tileinfo(lat, lng, v, h, latlngfld)
|
self._tileinfo = mstr_tileinfo(lat, lng, v, h, latlngfld)
|
||||||
|
self._already_visited = [] # To be filled later
|
||||||
|
self._all_visited = []
|
||||||
|
|
||||||
# Special case for the final step of an ortho
|
# Special case for the final step of an ortho
|
||||||
self._is_completion = is_completion
|
self._is_completion = is_completion
|
||||||
@ -303,6 +305,11 @@ class mstr_tileprep:
|
|||||||
return visited
|
return visited
|
||||||
|
|
||||||
|
|
||||||
|
# Let the orthographic class pass all visited tiles for this resource
|
||||||
|
def _setAlreadyVisitedTiles(self, tiles):
|
||||||
|
self._already_visited = tiles
|
||||||
|
|
||||||
|
|
||||||
# Walk through the now existing data files and make sure we always pick the correct
|
# Walk through the now existing data files and make sure we always pick the correct
|
||||||
# sources for every tile, thus evading previous edge detection errors
|
# sources for every tile, thus evading previous edge detection errors
|
||||||
def _placeTileSources(self, mlat, mlng):
|
def _placeTileSources(self, mlat, mlng):
|
||||||
@ -315,14 +322,15 @@ class mstr_tileprep:
|
|||||||
vst = self._scanConnections((visited[v][0], visited[v][1]))
|
vst = self._scanConnections((visited[v][0], visited[v][1]))
|
||||||
for l in range(len(vst)):
|
for l in range(len(vst)):
|
||||||
if self._checkVisited(visited, (vst[l][0], vst[l][1])) == False: visited.append((vst[l][0], vst[l][1]))
|
if self._checkVisited(visited, (vst[l][0], vst[l][1])) == False: visited.append((vst[l][0], vst[l][1]))
|
||||||
|
|
||||||
|
self._all_visited = visited
|
||||||
|
|
||||||
# We will take the resource of the original tile we have started
|
# We will take the resource of the original tile we have started
|
||||||
# our scan from. If there is nothing, we can choose.
|
# our scan from. If there is nothing, we can choose.
|
||||||
# This is then used for all visited tiles.
|
# This is then used for all visited tiles.
|
||||||
tv = self._tile_v
|
tv = self._tile_v
|
||||||
th = self._tile_h
|
th = self._tile_h
|
||||||
resstring = self._getResourceInfo(tv, th)
|
resstring = self._selectResources()
|
||||||
if resstring == "0" or resstring == "": resstring = self._selectResources()
|
|
||||||
for v in range(0, len(visited)):
|
for v in range(0, len(visited)):
|
||||||
self._storeResourceInfo(visited[v][0], visited[v][1], resstring)
|
self._storeResourceInfo(visited[v][0], visited[v][1], resstring)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user