]> marstr Code Repo - orthographic/commitdiff
Correction to make streams appear correctly. Refinement to streets, roads, highways...
authorMarcus Str. <marcus@marstr.online>
Sun, 6 Oct 2024 21:16:06 +0000 (23:16 +0200)
committerMarcus Str. <marcus@marstr.online>
Sun, 6 Oct 2024 21:16:06 +0000 (23:16 +0200)
defines.py
layergen.py
orthographic.py

index ab30c06fc7b2b2dfe81ab08abf12d29eb9f05d07..b1629371afcb70809310238254a25556d1dd1bf8 100644 (file)
@@ -154,7 +154,7 @@ mstr_ortho_layers = [
     ("highway", "unclassified", 17),\r
     ("highway", "living_street", 12),\r
     ("waterway", "river", 10),\r
-    ("waterway", "stream", 10),\r
+    ("waterway", "stream", 2),\r
     ("leisure", "nature_reserve", "landuse", "forest"),\r
     ("landuse", "forest", "landuse", "forest"),\r
     ("natural", "wood", "natural", "wood"),\r
index 3abcd5f70f9569544e1dd681b842a16ff0459972..75f1e3a0964ef372ae3208d861fdce73022e73b6 100644 (file)
@@ -445,7 +445,7 @@ class mstr_layergen:
                         for y in range(img.height):\r
                             for x in range(img.width):\r
                                 c = imgp[x,y]\r
-                                nc = (c[0], c[1], c[2], int(imgp[x,y][3]*0.5))\r
+                                nc = (c[0], c[1], c[2], int(imgp[x,y][3]*0.4))\r
                                 imgp[x,y] = nc\r
                         lx = randrange( self._imgsize - img.width ) \r
                         ly = randrange( self._imgsize - img.height )\r
@@ -910,12 +910,30 @@ class mstr_layergen:
                             w = randrange(60, 96)\r
                             a=mask_pix[x,y]\r
                             layer_comp_pix[x, y] = ( w,w,w,a[3] )\r
+                mstr_msg("layergen", "Street lines added")\r
 \r
 \r
-                mstr_msg("layergen", "Street lines added")\r
+            # Same as above, except that streams are lines and are not drawn as polygons.\r
+            # Therefore this part needs to be in here as well.\r
+            if self._tag == "waterway" and self._value == "stream":\r
+                mstr_msg("layergen", "Generating inland water mask")\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] > 65:\r
+                            b = 255 - l[3]\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
+            \r
+            # Blur roads a bit\r
+            if self._tag == "highway":\r
+                layer_comp = layer_comp.filter(ImageFilter.GaussianBlur(radius=1))\r
 \r
-            if self._tag == "waterway" and (self._value == "river" or self._value == "stream"):\r
-                layer_comp = layer_comp.filter(ImageFilter.GaussianBlur(radius=4))\r
 \r
             # Store layer\r
             layer_comp.save( mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer.png" )\r
index 4c076aad56de90c06e03ccee559c4a699d5ab1ec..04353f2435896a9c6cad5822c001b43438efd695 100644 (file)
@@ -169,8 +169,8 @@ class mstr_orthographic:
         # 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
-        while bb_lat < self._lat + 1:\r
-            while bb_lng < self._long + 1:\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
                 osmxml.adjust_bbox(bb_lat, bb_lng, bb_lat_edge, bb_lng_edge)\r
                 mstr_msg("orthographic", "Adjusted bounding box for XML object")\r