Another attempt to correct resource placement discoloration
This commit is contained in:
parent
59cae087a4
commit
c2d4915114
86
tileprep.py
86
tileprep.py
@ -229,6 +229,11 @@ class mstr_tileprep:
|
|||||||
textfile.write(newline)
|
textfile.write(newline)
|
||||||
|
|
||||||
|
|
||||||
|
# Find neighborinf tiles
|
||||||
|
def _findNeighbors(self, tv, th):
|
||||||
|
return [ (tv+1, th), (tv, th+1), (tv-1, th), (tv, th-1) ]
|
||||||
|
|
||||||
|
|
||||||
# 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):
|
||||||
@ -237,7 +242,7 @@ class mstr_tileprep:
|
|||||||
edge_end = [0,0,0,0] # top, right, bottom, left
|
edge_end = [0,0,0,0] # top, right, bottom, left
|
||||||
|
|
||||||
# Array with info we need
|
# Array with info we need
|
||||||
resinfo = ["", ""] # Touch, Resource numbers, contrast
|
resinfo = ["", ""] # Touch, Resource numbers
|
||||||
|
|
||||||
# Go through everything until the end is reached (no more options left)
|
# Go through everything until the end is reached (no more options left)
|
||||||
end_reached = False
|
end_reached = False
|
||||||
@ -251,17 +256,29 @@ class mstr_tileprep:
|
|||||||
resinfo[0] = self._getResourceTouch(tv, th)
|
resinfo[0] = self._getResourceTouch(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
resinfo[1] = self._getResourceInfo(tv, th)
|
||||||
|
|
||||||
|
# Only do the following steps if we have nothing stored
|
||||||
if resinfo[1] == "0":
|
if resinfo[1] == "0":
|
||||||
self._storeResourceInfo(tv, th, self._selectResources())
|
neighbors = self._findNeighbors(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
neighborinfo = ["",""]
|
||||||
|
for n in range(0, len(neighbors)):
|
||||||
|
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
|
||||||
|
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
|
||||||
|
if "b" in neighborinfo[0] and neighborinfo[1] != "0":
|
||||||
|
resinfo[1] = neighborinfo[1]
|
||||||
|
break
|
||||||
|
|
||||||
|
# Store info. At this point we either have neighboring data, or
|
||||||
|
# we need to select something
|
||||||
|
if resinfo[1] == "0": resinfo[1] = self._selectResources()
|
||||||
|
self._storeResourceInfo(tv, th, resinfo[1])
|
||||||
|
|
||||||
|
# Move forward
|
||||||
if "t" in resinfo[0]:
|
if "t" in resinfo[0]:
|
||||||
tv=tv+1
|
tv=tv+1
|
||||||
rinfo = self._getResourceInfo(tv, th)
|
|
||||||
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
|
|
||||||
else:
|
else:
|
||||||
edge_end[0] = 1
|
edge_end[0] = 1
|
||||||
|
|
||||||
|
|
||||||
# Go east
|
# Go east
|
||||||
tv = self._tile_v
|
tv = self._tile_v
|
||||||
th = self._tile_h
|
th = self._tile_h
|
||||||
@ -270,17 +287,29 @@ class mstr_tileprep:
|
|||||||
resinfo[0] = self._getResourceTouch(tv, th)
|
resinfo[0] = self._getResourceTouch(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
resinfo[1] = self._getResourceInfo(tv, th)
|
||||||
|
|
||||||
|
# Only do the following steps if we have nothing stored
|
||||||
if resinfo[1] == "0":
|
if resinfo[1] == "0":
|
||||||
self._storeResourceInfo(tv, th, self._selectResources())
|
neighbors = self._findNeighbors(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
neighborinfo = ["",""]
|
||||||
|
for n in range(0, len(neighbors)):
|
||||||
|
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
|
||||||
|
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
|
||||||
|
if "l" in neighborinfo[0] and neighborinfo[1] != "0":
|
||||||
|
resinfo[1] = neighborinfo[1]
|
||||||
|
break
|
||||||
|
|
||||||
|
# Store info. At this point we either have neighboring data, or
|
||||||
|
# we need to select something
|
||||||
|
if resinfo[1] == "0": resinfo[1] = self._selectResources()
|
||||||
|
self._storeResourceInfo(tv, th, resinfo[1])
|
||||||
|
|
||||||
|
# Move forward
|
||||||
if "r" in resinfo[0]:
|
if "r" in resinfo[0]:
|
||||||
th=th+1
|
th=th+1
|
||||||
rinfo = self._getResourceInfo(tv, th)
|
|
||||||
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
|
|
||||||
else:
|
else:
|
||||||
edge_end[1] = 1
|
edge_end[1] = 1
|
||||||
|
|
||||||
|
|
||||||
# Go south
|
# Go south
|
||||||
tv = self._tile_v
|
tv = self._tile_v
|
||||||
th = self._tile_h
|
th = self._tile_h
|
||||||
@ -289,17 +318,29 @@ class mstr_tileprep:
|
|||||||
resinfo[0] = self._getResourceTouch(tv, th)
|
resinfo[0] = self._getResourceTouch(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
resinfo[1] = self._getResourceInfo(tv, th)
|
||||||
|
|
||||||
|
# Only do the following steps if we have nothing stored
|
||||||
if resinfo[1] == "0":
|
if resinfo[1] == "0":
|
||||||
self._storeResourceInfo(tv, th, self._selectResources())
|
neighbors = self._findNeighbors(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
neighborinfo = ["",""]
|
||||||
|
for n in range(0, len(neighbors)):
|
||||||
|
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
|
||||||
|
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
|
||||||
|
if "t" in neighborinfo[0] and neighborinfo[1] != "0":
|
||||||
|
resinfo[1] = neighborinfo[1]
|
||||||
|
break
|
||||||
|
|
||||||
|
# Store info. At this point we either have neighboring data, or
|
||||||
|
# we need to select something
|
||||||
|
if resinfo[1] == "0": resinfo[1] = self._selectResources()
|
||||||
|
self._storeResourceInfo(tv, th, resinfo[1])
|
||||||
|
|
||||||
|
# Move forward
|
||||||
if "b" in resinfo[0]:
|
if "b" in resinfo[0]:
|
||||||
tv=tv-1
|
tv=tv-1
|
||||||
rinfo = self._getResourceInfo(tv, th)
|
|
||||||
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
|
|
||||||
else:
|
else:
|
||||||
edge_end[2] = 1
|
edge_end[2] = 1
|
||||||
|
|
||||||
|
|
||||||
# Go west
|
# Go west
|
||||||
tv = self._tile_v
|
tv = self._tile_v
|
||||||
th = self._tile_h
|
th = self._tile_h
|
||||||
@ -308,14 +349,25 @@ class mstr_tileprep:
|
|||||||
resinfo[0] = self._getResourceTouch(tv, th)
|
resinfo[0] = self._getResourceTouch(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
resinfo[1] = self._getResourceInfo(tv, th)
|
||||||
|
|
||||||
|
# Only do the following steps if we have nothing stored
|
||||||
if resinfo[1] == "0":
|
if resinfo[1] == "0":
|
||||||
self._storeResourceInfo(tv, th, self._selectResources())
|
neighbors = self._findNeighbors(tv, th)
|
||||||
resinfo[1] = self._getResourceInfo(tv, th)
|
neighborinfo = ["",""]
|
||||||
|
for n in range(0, len(neighbors)):
|
||||||
|
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
|
||||||
|
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
|
||||||
|
if "r" in neighborinfo[0] and neighborinfo[1] != "0":
|
||||||
|
resinfo[1] = neighborinfo[1]
|
||||||
|
break
|
||||||
|
|
||||||
|
# Store info. At this point we either have neighboring data, or
|
||||||
|
# we need to select something
|
||||||
|
if resinfo[1] == "0": resinfo[1] = self._selectResources()
|
||||||
|
self._storeResourceInfo(tv, th, resinfo[1])
|
||||||
|
|
||||||
|
# Move forward
|
||||||
if "l" in resinfo[0]:
|
if "l" in resinfo[0]:
|
||||||
th=th-1
|
th=th-1
|
||||||
rinfo = self._getResourceInfo(tv, th)
|
|
||||||
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
|
|
||||||
else:
|
else:
|
||||||
edge_end[3] = 1
|
edge_end[3] = 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user