mstr_msg("orthographic", "Beginning construction of tile")\r
\r
# Clear cache\r
- tmp = glob.glob(mstr_datafolder + "_cache/*.*")\r
- for t in range(0, len(tmp)):\r
- os.remove(tmp[t])\r
+ #tmp = glob.glob(mstr_datafolder + "_cache/*.*")\r
+ #for t in range(0, len(tmp)):\r
+ # os.remove(tmp[t])\r
\r
# We need to know which platform we are on\r
os_platform = os.name\r
bb_lat = self._lat\r
bb_lng = self._long\r
\r
+ # Resource contour maps\r
+ contours = []\r
+\r
+ # Generate images for all resources\r
+ cnt_w = mlng * 20\r
+ cnt_h = mlat * 20\r
+ for l in mstr_ortho_layers:\r
+ if l[0] != "building":\r
+ cntimg = Image.new("RGBA", (cnt_w, cnt_h), (255,255,255,255))\r
+ contours.append([l[0], l[1], cntimg])\r
+ mstr_msg("orthographic", "Created base images for landuse contours")\r
+\r
# We will now prepare the graphic tile generation. We do this by only generating\r
# the masks and determine which sources to use in the actual images.\r
# Previously, I downloaded all XML files in one go - but to ease the\r
# stress on OSM servers and my server, we will do acquire the data\r
# only for the current processed part of the tile.\r
- """\r
+\r
for lat_grid in range(1, maxlatlng[0]+1):\r
for lng_grid in range(1, maxlatlng[1]+1):\r
# Adjust bounding box\r
mg = mstr_maskgen( [self._lat, cur_tile_y, self._long, cur_tile_x], self._vstep, layer[0], layer[1], layer[2])\r
mask = mg._build_mask(osmxml, is_prep=True) # We need an object here\r
\r
- tp = mstr_tileprep(self._lat, self._long, lat_grid, lng_grid, layer[0], layer[1], mask, False)\r
- tp._determineEdges()\r
+ mask = mask.resize((20,20), Image.Resampling.BILINEAR)\r
+ idx = 0\r
+ for c in contours:\r
+ if c[0] == layer[0] and c[1] == layer[1]:\r
+ break\r
+ else:\r
+ idx=idx+1\r
+ \r
+ cnx = (lng_grid-1) * 20\r
+ cny = cnt_h - (lat_grid * 20)\r
+ contours[idx][2].alpha_composite(mask, dest=(cnx,cny))\r
+\r
+ #tp = mstr_tileprep(self._lat, self._long, lat_grid, lng_grid, layer[0], layer[1], mask, False)\r
+ #tp._determineEdges()\r
\r
curlyr = curlyr+1\r
\r
if cur_tile_y > top_lat:\r
top_lat = cur_tile_y\r
\r
- exit(1)\r
- """\r
+\r
+ # Store all contour images\r
+ for c in contours:\r
+ c[2].save(mstr_datafolder + "_cache/contour_" + c[0] + "_" + c[1] + ".png")\r
+ mstr_msg("orthographic", "Saved contour images for each OSM tag")\r
+\r
\r
# We now need to "raytrace" the resources for correct placement\r
mstr_msg("orthographic", "Performing resource plamement tracing for tile")\r
\r
# Let's set up an array which keeps track of all used tiles, per resource\r
- \r
+ """\r
for l in mstr_ortho_layers:\r
self._tiles_visited.append([(l[0], l[1])]) # Store tag and value as tuple for each possible resource\r
\r
tp._setAlreadyVisitedTiles(self._tiles_visited[vstidx])\r
tp._placeTileSources(mlat, mlng)\r
self.adjust_tiles_visited(vstidx, tp._all_visited)\r
+ """\r
\r
\r
# Adjust the tiles visited for one resource\r