]> marstr Code Repo - marstr/orthographic.git/commitdiff
Added mechanism to remember the resource used in case affected water tiles needed...
authorMarcus Str. <marcus@marstr.online>
Thu, 6 Feb 2025 18:01:58 +0000 (19:01 +0100)
committerMarcus Str. <marcus@marstr.online>
Thu, 6 Feb 2025 18:01:58 +0000 (19:01 +0100)
defines.py
layergen.py
orthographic.py

index de6c72725ee2220dc9f95b233ebcd10a6fa4f399..2d043359be693c5b3dbb1350f56cdd2809be7142 100644 (file)
@@ -129,6 +129,7 @@ mstr_ortho_layers = [
     ("highway", "residential", 4),\r
     ("highway", "primary", 6),\r
     ("highway", "secondary", 3),\r
+    ("highway", "trunk", 3)\r
     ("highway", "tertiary", 5),\r
     ("highway", "unclassified", 4),\r
     ("highway", "living_street", 3),\r
@@ -239,6 +240,7 @@ mstr_mask_blur = [
     # Z-Order 4\r
     ("highway", "motorway", 0.5),\r
     ("highway", "primary", 0.5),\r
+    ("highway", "trunk", 0.5),\r
     ("highway", "secondary", 0.5),\r
     ("highway", "tertiary", 0.5),\r
     ("highway", "unclassified", 0.5),\r
index 6f040d76562ee66257130864fd8a1f8418e5ba02..988573defd5268a4c37c612e29078dd556020352 100644 (file)
@@ -67,9 +67,19 @@ class mstr_layergen:
         self._latlngfld = latlngfld\r
 \r
     # Set the resource to use\r
-    def set_resource(self, res):\r
-        self._resource = res\r
+    def load_resource(self):\r
+        self._resource = -1\r
+        fnlines = []\r
+        fn = mstr_datafolder + "z_orthographic/data/" + self._latlngfld + "/resdata"\r
+        with open(fn) as textfile:\r
+            fnlines = textfile.readlines()\r
+        for l in range(0, len(fnlines)):\r
+            linedata = fnlines[l].split(" ")\r
+            if linedata[0] == self._tag and linedata[1] == self._value:\r
+                self._resource = int(linedata[2])\r
+                break\r
 \r
+        \r
     # Tile info object\r
     def open_tile_info(self):\r
         self._tileinfo = mstr_tileinfo(self._latitude, self._longitude, self._lat_number, self._lng_number, self._latlngfld)\r
@@ -654,7 +664,7 @@ class mstr_layergen:
 \r
             \r
             # Highways and runways of any kind get some special treatment\r
-            if (self._tag == "highway" and self._value == "motorway") or (self._tag == "highway" and self._value == "primary") or (self._tag == "highway" and self._value == "secondary") or (self._tag == "highway" and self._value == "tertiary") or (self._tag == "aeroway" and self._value == "runway"):\r
+            if (self._tag == "highway" and self._value == "motorway") or (self._tag == "highway" and self._value == "primary") or (self._tag == "highway" and self._value == "secondary") or (self._tag == "highway" and self._value == "tertiary") or (self._tag == "aeroway" and self._value == "runway") or (self._tag == "highway" and self._value == "trunk"):\r
                 # We will now add some white lines for coolness\r
                 osm_edge = mask.filter(ImageFilter.FIND_EDGES)\r
                 mask_pix = osm_edge.load()\r
index 3f5d3163a93f889b8ce350ab4841fc61fb083e2f..cff11831bd3bf171e78af4396b0635f9056248e2 100644 (file)
@@ -74,6 +74,14 @@ class mstr_orthographic:
             rs = [ l[0], l[1], randrange(1, 16) ]\r
             self._tile_resources.append(rs)\r
 \r
+        # Save to disk\r
+        fn = mstr_datafolder + "z_orthographic/data/" + self._latlngfld + "/resdata"\r
+        if os.path.isfile(fn) == False:\r
+            for rsd in range(0, len(self._tile_resources)):\r
+                line = self._tile_resources[rsd][0] + " " + self._tile_resources[rsd][1] + " " + str(self._tile_resources[rsd][2]) + "\r\n"\r
+                with open(fn, 'a') as textfile:\r
+                    textfile.write(line)\r
+\r
 \r
     # This will determine the vertical stepping in degrees in order to generate\r
     # masks with a 1:1 square ratio. This is important as X-Plane textures for\r
@@ -371,12 +379,7 @@ class mstr_orthographic:
                     lg.set_zoomlevel(self._zoomlevelfactor)\r
 \r
                     # Find resource to use\r
-                    rs = -1\r
-                    for r in self._tile_resources:\r
-                        if r[0] == layer[0] and r[1] == layer[1]:\r
-                            rs = r[2]\r
-                            break\r
-                    lg.set_resource(rs)\r
+                    lg.load_resource()\r
 \r
                     #lg.open_tile_info()\r
                     lyr = lg.genlayer(mask, osmxml)\r