v2 adds new option "show-profiles" to enable or disable this feature. Default is disabled.

-------- Original-Nachricht --------
Betreff: [PATCH] Enable elevation profile in MapSource
Datum: Sun, 14 Feb 2010 23:53:31 +0100
Von: Ronny Klier <[email protected]>
Antwort an: Development list for mkgmap <[email protected]>
An: Development list for mkgmap <[email protected]>
Newsgruppen: gmane.comp.gis.openstreetmap.mkgmap.devel

Hi,

there seems to be a way to show elevation profiles for a route without
having the DEM subfiles stored in the map.
There is a byte in TDB file's header section which can be set to 1. If
set MapSource generates the profile from the contour lines. The result
is not as good as having the full information from DEM subfiles but
better than nothing.

Please try this patch, especially with maps without contour lines. Maybe
setting this flag has to be bound to existing contour lines.

Ronny


Index: resources/help/en/options
===================================================================
--- resources/help/en/options   (revision 1569)
+++ resources/help/en/options   (working copy)
@@ -370,6 +370,11 @@
 --tdbfile
        Write a .tdb file.
 
+--show-profiles=1
+       Sets a flag in tdb file which marks set mapset as having contour 
+       lines and allows showing profile in MapSource. Default is 0 
+       which means disabled. 
+
 --draw-priority=25
        When two maps cover the same area, this option controls what
        order they are drawn in and therefore which map is on top of
Index: src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java (revision 1569)
+++ src/uk/me/parabola/mkgmap/combiners/TdbBuilder.java (working copy)
@@ -84,10 +84,17 @@
                } else {
                        tdbVersion = TdbFile.TDB_V407;
                }
+               // enable "show profile" button for routes in mapsource 
+               byte enableProfile = 0;
+               if (tdbVersion == TdbFile.TDB_V407)
+               {
+                       // this is supported only in version 403 and above 
+                       enableProfile = (byte)args.get("show-profiles", 0);
+               }
 
                tdb = new TdbFile(tdbVersion);
                tdb.setProductInfo(familyId, productId, productVersion, 
seriesName,
-                               familyName, areaName);
+                               familyName, areaName, enableProfile);
        }
 
        /**
Index: src/uk/me/parabola/tdbfmt/HeaderBlock.java
===================================================================
--- src/uk/me/parabola/tdbfmt/HeaderBlock.java  (revision 1569)
+++ src/uk/me/parabola/tdbfmt/HeaderBlock.java  (working copy)
@@ -49,6 +49,8 @@
         */
        private String familyName;
 
+       private byte enableProfile;
+
        HeaderBlock(int tdbVersion) {
                this.tdbVersion = tdbVersion;
        }
@@ -92,8 +94,12 @@
                        os.write3(0);
                        os.write4(1252);
                        os.write4(10000);
-                       os.write(1);
-                       os.write2(0);
+                       os.write(1);    // map is routable
+                       if (enableProfile == 1)
+                               os.write(1);    // map has profile information
+                       else
+                               os.write(0);
+                       os.write(0);    // map has DEM sub files
                }
        }
 
@@ -154,4 +160,8 @@
        public int getTdbVersion() {
                return tdbVersion;
        }
+
+       public void setEnableProfile(byte enableProfile) {
+               this.enableProfile = enableProfile;             
+       }
 }
Index: src/uk/me/parabola/tdbfmt/TdbFile.java
===================================================================
--- src/uk/me/parabola/tdbfmt/TdbFile.java      (revision 1569)
+++ src/uk/me/parabola/tdbfmt/TdbFile.java      (working copy)
@@ -92,7 +92,8 @@
        }
 
        public void setProductInfo(int familyId, int productId,
-                       short productVersion, String seriesName, String 
familyName, String overviewDescription)
+                       short productVersion, String seriesName, String 
familyName, String overviewDescription,
+                       byte enableProfile)
        {
                headerBlock = new HeaderBlock(tdbVersion);
                headerBlock.setFamilyId((short) familyId);
@@ -100,6 +101,7 @@
                headerBlock.setProductVersion(productVersion);
                headerBlock.setSeriesName(seriesName);
                headerBlock.setFamilyName(familyName);
+               headerBlock.setEnableProfile(enableProfile);
                this.overviewDescription = overviewDescription;
        }
 
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to