("landuse", "farmyard", "landuse", "farmland"),
("landuse", "military", "landuse", "residential-boundary"),
# Z-Order 2
+ ("highway", "service", 6),
("waterway", "river", 10),
("waterway", "stream", 10),
("leisure", "nature_reserve", "landuse", "forest"),
("highway", "primary", 25),
("highway", "secondary", 13),
("highway", "tertiary", 20),
- ("highway", "unclassified", 12),
+ ("highway", "unclassified", 17),
("highway", "living_street", 12),
("highway", "residential", 12),
- ("highway", "service", 6),
("highway", "footway", 4),
("railway", "rail", 5),
# Z-Order 5
("highway", "primary", 5),
("highway", "secondary", 5),
("highway", "tertiary", 5),
- ("highway", "unclassified", 10),
- ("highway", "living_street", 10),
- ("highway", "residential", 10),
- ("highway", "service", 5),
- ("highway", "footway", 5),
+ ("highway", "unclassified", 5),
+ ("highway", "living_street", 5),
+ ("highway", "residential", 5),
+ ("highway", "service", 3),
+ ("highway", "footway", 3),
("highway", "track", 3),
("highway", "path", 3),
("railway", "rail", 4),
tr.append(tl)
tiles.append(tr)
- return tiles
\ No newline at end of file
+ return tiles
+
+
+
+# Testing
+def in_circle(center_x, center_y, radius, x, y):
+ square_dist = (center_x - x) ** 2 + (center_y - y) ** 2
+ return square_dist <= radius ** 2
\ No newline at end of file
import os
from random import randrange
import random
-from PIL import Image, ImageFilter
+from PIL import Image, ImageFilter, ImageDraw, ImagePath
from defines import *
from log import *
from tiledb import *
from osmxml import *
+from functions import *
class mstr_layergen:
osm_edge = osm_edge.filter(ImageFilter.MaxFilter)
mstr_msg("mstr_layergen", "Edge mask generated")
+ # This adds some natural looking shapes to these types of features
+ if self._value == "forest" or self._value == "nature_reserve":
+ epx = osm_edge.load()
+ imgd = ImageDraw.Draw(osm_mask)
+
+ # Walk through a grid of 200x200 - on the edge image
+ for y in range(0, osm_mask.height, int(osm_mask.height/200)):
+ for x in range(0, osm_mask.width, int(osm_mask.width/200)):
+ px = epx[x,y]
+ if px[3] == 255:
+ rx = randrange(30,60)
+ ry = randrange(30,60)
+ f = randrange(1,10)
+
+ # Do some magic
+ if f != 5:
+ imgd.ellipse((x-int(rx/2), y-int(ry/2), x+rx, y+ry), fill="black")
+ if f == 3 or f == 7:
+ imgd.ellipse((x-int(rx/2), y-int(ry/2), x+rx, y+ry), fill=(0,0,0,0))
+
+
# We need to change the image in certain conditions
if self._value == "hedge" and self._tag == "barrier":
osm_mask = osm_edge
layer.alpha_composite( ptc_src[imgid], ( randrange(l, r), randrange(t, b) ) )
mstr_msg("mstr_layergen", "Layer image generated")
+
+ # Here we need to do some magic to make some features look more natural
+ if (self._tag == "landuse" and self._value == "meadow") or (self._tag == "natural" and self._value == "grassland") or (self._tag == "natural" and self._value == "heath"):
+ amt = randrange(1,3)
+ for i in range(1, amt):
+ ptc = randrange(1, 7)
+ img = Image.open(mstr_datafolder + "Textures\\tile\\completion\\p" + str(ptc)+".png")
+ lx = randrange( int(layer.width/20), layer.width - (int(layer.width/20)) - img.width )
+ ly = randrange( int(layer.width/20), layer.width - (int(layer.width/20)) - img.width )
+ layer.alpha_composite( img, (lx, ly) )
+
+
# We now need to add the seamless border
layer.alpha_composite( brd_src )
mstr_msg("mstr_layergen", "Layer image completed")
layer_border = self.genborder(osm_edge, "landuse", "meadow")
layer_comp.alpha_composite(layer_border)
- # If this is the completion layer, we may add some aditional patches to the image
- # for more realism
- if self._is_completion == True:
- cl = randrange(1, 10)
- for i in range(1, cl):
- p = randrange(1, 2)
- ptc = Image.open(mstr_datafolder + "Textures\\tile\\completion\\p"+str(p)+".png")
- rdx = randrange(1, self._imgsize-1-ptc.width)
- rdy = randrange(1, self._imgsize-1-ptc.height)
- layer_comp.alpha_composite(ptc, (rdx, rdy))
-
# Store layer
if self._is_completion == False:
if self._tag == "railway":
d = randrange(41, 61)
layer_comp_pix[x, y] = ( d,d,d,a[3] )
- if self._tag == "highway":
- d = randrange(160,180)
+ if self._tag == "highway" and self._value != "motorway":
+ d = randrange(140,160)
layer_comp_pix[x, y] = ( d,d,d,a[3] )
+ if self._tag == "highway" and self._value == "motorway":
+ d = randrange(1,20)
+ r = 86-d
+ g = 97-d
+ b = 106-d
+ layer_comp_pix[x, y] = ( r,g,b,a[3] )
if self._tag == "waterway" and (self._value == "stream" or self._value == "river"):
d = randrange(1, 15)
layer_comp_pix[x, y] = ( 129-d, 148-d, 159-d, a[3] )
mstr_msg("mstr_layergen", "Shadow layer completed")
# Highways and runways of any kind get some special treatment
- if (self._tag == "highway" and self._value == "motorway") or (self._tag == "aeroway" and self._value == "runway"):
+ if (self._tag == "highway" and self._value == "motorway") or (self._tag == "highway" and self._value == "unclassified") or (self._tag == "aeroway" and self._value == "runway"):
# We will now add some white lines for coolness
mask_pix = osm_edge.load()
layer_comp_pix = layer_comp.load()
from defines import *
from log import *
from PIL import Image, ImageFilter, ImageDraw, ImagePath
+from random import randrange
+import random
class mstr_maskgen:
if mstr_ortho_layers[i][0] == self._tag and mstr_ortho_layers[i][1] == self._value:
idx = i
break
- imgd.line(pts, fill="#000000", width=mstr_ortho_layers[idx][2])
+ imgd.line(pts, fill="#000000", width=mstr_ortho_layers[idx][2], joint="curve")
# Save image
mask_img.save(mstr_datafolder + "_cache\\" + fstr + "_" + self._tag + "-" + self._value + ".png")
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "natural", "bare_rock")
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "highway", "track")
-#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "landuse", "forest")
+#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "landuse", "forest", False)
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "natural", "water")
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "leisure", "golf_course")
#mg = mstr_maskgen([51, 2, 7, 5], 0.0100691262567974, "boundary", "administrative", "admin_level", ["6"])
os.makedirs(self._output + "/Tiles/"+str(self._lat)+"_"+str(self._long)+"\\terrain")
mstr_msg("mstr_orthographic", "Created tile terrain folder")
+ curlyr = 1
for layer in layers:
+ # Let the user know
+ mstr_msg("mstr_orthographic", "Processing layer " + str(curlyr) + " of " + str(len(layers)))
+
# Generate the mask
mg = mstr_maskgen( [self._lat, cur_tile_y, self._long, cur_tile_x], self._vstep, layer[0], layer[1], layer[2] )
mg._build_mask()
# Generate the layer
lg = mstr_layergen(layer[0], layer[1], self._lat, cur_tile_y, self._long, cur_tile_x, layer[2])
lg.genlayer()
+ curlyr = curlyr+1
mstr_msg("mstr_orthographic", "All layers created")
# We should have all layers now.
# aforementioned fix:
if emptyspace == True:
# Choose a suitable layer type
- lt = [5,14,15]
+ lt = [6,14,17]
pick = randrange(0,len(lt)-1)
ltp = lt[pick]
tag = mstr_ortho_layers[ltp][0]