\r
\r
# Create a water mask we need to remove from the DDS later\r
+ """\r
if (self._tag == "natural" and self._value == "water") or (self._tag == "water" and self._value == "lake") or (self._tag == "water" and self._value == "pond") or (self._tag == "water" and self._value == "river") or (self._tag == "leisure" and self._value == "swimming_pool"):\r
mstr_msg("layergen", "Generating inland water mask")\r
water_file = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._lat_number) + "_" + str(self._lng_number) + "_water.png"\r
if os.path.isfile(water_file):\r
inl_mask = Image.open(water_file)\r
else:\r
- inl_mask = Image.new("RGBA", (self._imgsize, self._imgsize), (255,255,255,255))\r
+ inl_mask = Image.new("L", (self._imgsize, self._imgsize), (255))\r
lyr_pix = layer_comp.load()\r
inl_pix = inl_mask.load()\r
for y in range(self._imgsize):\r
l = lyr_pix[x,y]\r
if l[3] > 50:\r
clr = 255-l[3]\r
- c = (clr,clr,clr,255)\r
+ c = (clr)\r
inl_pix[x,y] = c\r
inl_mask.save(water_file)\r
#if l[3] > 65:\r
#inl_mask.save(mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer_mask.png")\r
#layer_comp = inl_mask\r
mstr_msg("layergen", "Inland water mask generated and saved")\r
+ """\r
\r
# Return the completed image\r
return layer_comp\r
\r
# In here we store the layers\r
photolayers = []\r
+ waterlayers = []\r
\r
# The masks are handed to layergen in sequence. The layers are then\r
# in turn handed to photogen.\r
\r
curlyr = 1\r
+ wtr_info = False\r
for layer in layers:\r
# Let the user know\r
mstr_msg("orthographic", "Processing layer " + str(curlyr) + " of " + str(len(layers)))\r
lg.set_latlng_folder(self._latlngfld)\r
#lg.open_db()\r
lg.open_tile_info()\r
- photolayers.append(lg.genlayer(mask, osmxml))\r
+ lyr = lg.genlayer(mask, osmxml)\r
+ photolayers.append(lyr)\r
+ if (layer[0] == "natural" and layer[1] == "water") or (layer[0] == "water" and layer[1] == "lake") or (layer[0] == "water" and layer[1] == "pond") or (layer[0] == "water" and layer[1] == "river") or (layer[0] == "waterway" and layer[1] == "river"):\r
+ waterlayers.append(lyr)\r
+ if wtr_info == False:\r
+ wtr_info = True\r
+ wtrfile = mstr_datafolder + "z_orthographic/data/" + self._latlngfld + "/wtrfile"\r
+ with open(wtrfile, 'a') as textfile:\r
+ textfile.write(str(grid_lat) + " " + str(grid_lng) + "\r\n")\r
curlyr = curlyr+1\r
mstr_msg("orthographic", "All layers created")\r
\r
# Snap a photo with our satellite :)\r
mstr_msg("orthographic", "Generating ortho photo")\r
pg = mstr_photogen(self._lat, self._long, grid_lat, grid_lng, maxlatlng[0], maxlatlng[1])\r
- pg.genphoto(photolayers)\r
+ pg.genphoto(photolayers, waterlayers)\r
mstr_msg("orthographic", " -- Ortho photo generated -- ")\r
print("")\r
print("")\r
\r
\r
# This puts it all together. Bonus: AND saves it.\r
- def genphoto(self, layers):\r
+ def genphoto(self, layers, waterlayers):\r
# Template for the file name which is always the same\r
#root_filename = mstr_datafolder + "/_cache/" + str(self._lat) + "-" + str(self._ty) + "_" + str(self._lng) + "-" + str(self._tx) + "_"\r
\r
t = (0,0,0,0)\r
ocean_pix[x,y] = t\r
\r
- # Now cut out inland water\r
- water_layers = (\r
- ["natural", "water"],\r
- ["water", "lake"],\r
- ["water", "pond"],\r
- ["water", "river"],\r
- ["leisure", "swimming_pool"]\r
- )\r
- for l in water_layers:\r
- fn = mstr_datafolder + "_cache/" + str(self._lat) + "-" + str(self._ty) + "_" + str(self._lng) + "-" + str(self._tx) + "_" + l[0] + "-" + l[1] + "_layer_mask.png"\r
- if os.path.isfile(fn) == True:\r
- wtr = Image.open(fn)\r
- wtr_pix = wtr.load()\r
- tilepix = self._tile.load()\r
- for y in range(wtr.height):\r
- for x in range(wtr.width):\r
- wp = wtr_pix[x,y]\r
- if wp[0] == 255 and wp[1] == 0 and wp[2] == 255 and wp[3] == 255:\r
- tilepix[x,y] = (0,0,0,0)\r
-\r
# Alpha correction on final image\r
corrpix = self._tile.load()\r
for y in range(0, self._tile.height):\r
corrpix[x,y] = nc\r
if c[3] == 0:\r
corrpix[x,y] = (0,0,0,0)\r
+\r
+ # Now cut out inland water\r
+ for w in waterlayers:\r
+ wtr_pix = w.load()\r
+ for y in range(w.height):\r
+ for x in range(w.width):\r
+ v = wtr_pix[x,y]\r
+ if v[3] >= 50:\r
+ c = (0,0,0,0)\r
+ corrpix[x,y] = c\r
+\r
+ """\r
+ ddsf_water = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._ty) + "_" + str(self._tx) + "_water.png"\r
+ if os.path.isfile(ddsf_water) == True:\r
+ wtr = Image.open(ddsf_water)\r
+ wtr_pix = wtr.load()\r
+ for y in range(wtr.height):\r
+ for x in range(wtr.width):\r
+ v = wtr_pix[x,y]\r
+ if v <= 50:\r
+ c = (0,0,0,0)\r
+ corrpix[x,y] = c\r
+ """\r
\r
# We are now in posession of the final image.\r
\r
cnt_x = cur_lat + (self._vstep/2)
cnt_y = cur_lng + (mstr_zl_18/2)
- ddsf_water = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + "_water.png"
-
terstr = ""
terstr = terstr + "A\r\n"
terstr = terstr + "800\r\n"
terstr = terstr + "TERRAIN\r\n"
terstr = terstr + "\r\n"
terstr = terstr + "LOAD_CENTER " + str(cnt_x) + " " + str(cnt_y) + " " + str(dmt) + " 2048\r\n"
+ #terstr = terstr + "BASE_TEX_NOWRAP ../../orthos/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".dds\r\n"
terstr = terstr + "TEXTURE_NOWRAP ../../orthos/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".dds\r\n"
if mstr_xp_scn_normalmaps == True:
terstr = terstr + "NORMAL_TEX 1.0 ../../normals/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".png\r\n"
- if os.path.isfile(ddsf_water) == True:
- terstr = terstr + "BORDER_TEX ../../orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + "_water.png\r\n"
-
terfln = mstr_datafolder + "z_orthographic/terrain/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".ter"
with open(terfln, 'w') as textfile: