# Create a water mask we need to remove from the DDS later\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"):\r
mstr_msg("layergen", "Generating inland water mask")\r
- inl_mask = Image.new("RGBA", (self._imgsize, self._imgsize), (255,255,255,255))\r
+ inl_mask = Image.new("RGBA", (self._imgsize, self._imgsize), (0,0,0,0))\r
lyr_pix = layer_comp.load()\r
inl_pix = inl_mask.load()\r
for y in range(self._imgsize):\r
for x in range(self._imgsize):\r
l = lyr_pix[x,y]\r
- if l[3] > 0:\r
+ if l[3] > 65:\r
b = 255 - l[3]\r
- inl_pix[x,y] = (b,b,b,255)\r
+ inl_pix[x,y] = (255,0,255,255)\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
mstr_msg("layergen", "Inland water mask generated and saved")\r
\r
mstr_msg("osmxml", "Acquiring OSM data for " + str(self._lat)+","+str(self._lng)+" - "+str(self._curB_lat)+","+str(self._curB_lng))\r
\r
# We will use our self-hosted API for this.\r
- data = { \r
- "bbox": { \r
- "lat": str(self._lat),\r
- "lng": str(self._lng),\r
- "lat_b": str(self._curB_lat),\r
- "lng_b": str(self._curB_lng)\r
- },\r
- "tile_lat": str(self._lat),\r
- "tile_lng": str(self._lng),\r
- "square_lat": str(v),\r
- "square_lng": str(h)\r
- }\r
- r = requests.post(mstr_osm_endpoint, json=data)\r
-\r
- xmlf = mstr_datafolder + "_cache/tile.xml"\r
- if os.path.isfile(xmlf):\r
- os.remove(xmlf)\r
- with open(xmlf, 'wb') as textfile:\r
- textfile.write(r.content)\r
+ while os.path.isfile(mstr_datafolder + "_cache/tile.xml") == False:\r
+ data = { \r
+ "bbox": { \r
+ "lat": str(self._lat),\r
+ "lng": str(self._lng),\r
+ "lat_b": str(self._curB_lat),\r
+ "lng_b": str(self._curB_lng)\r
+ },\r
+ "tile_lat": str(self._lat),\r
+ "tile_lng": str(self._lng),\r
+ "square_lat": str(v),\r
+ "square_lng": str(h)\r
+ }\r
+ r = requests.post(mstr_osm_endpoint, json=data)\r
+\r
+ xmlf = mstr_datafolder + "_cache/tile.xml"\r
+ if os.path.isfile(xmlf):\r
+ os.remove(xmlf)\r
+ with open(xmlf, 'wb') as textfile:\r
+ textfile.write(r.content)\r
+\r
+ # 1 second delay in case the request fails\r
+ if os.path.isfile(mstr_datafolder + "_cache/tile.xml") == False:\r
+ sleep(1)\r
\r
# Provide the object directly\r
if asobject == True:\r
for y in range(wtr.height):\r
for x in range(wtr.width):\r
wp = wtr_pix[x,y]\r
- if wp[0] == 0:\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
# We are now in posession of the final image.\r
\r
# This returns a mask of the empty space to cover, should there be any\r
def buildCompletionMask(self):\r
- mask = Image.new("RGBA", (self._imgsize, self._imgsize))\r
- mask_pix = mask.load()\r
+ mask = Image.new("RGBA", (self._imgsize, self._imgsize), (0,0,0,255))\r
+ #mask_pix = mask.load()\r
\r
# Load photo\r
- layer_pix = self._tile.load() \r
+ #layer_pix = self._tile.load() \r
\r
# Scan!\r
- for y in range(self._tile.width-1):\r
- for x in range(self._tile.height-1):\r
- p = layer_pix[x,y]\r
- if p[3] < 255: # <- Check for empty or non-complete alpha\r
- mask_pix[x,y] = (0,0,0,255)\r
+ #for y in range(self._tile.width-1):\r
+ # for x in range(self._tile.height-1):\r
+ # p = layer_pix[x,y]\r
+ # if p[3] < 255: # <- Check for empty or non-complete alpha\r
+ # mask_pix[x,y] = (0,0,0,255)\r
# We do not apply any blur or other effects here - we only want the\r
# exact pixel positions.\r
\r