Skip to content

Commit 3922cd4

Browse files
authored
b119
1 parent c0edcc8 commit 3922cd4

5 files changed

Lines changed: 38 additions & 32 deletions

File tree

GPIReader.cs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ public class GPIWriter
14771477
private double MaxLat = 90;
14781478
private double MinLon = -180;
14791479
private double MaxLon = 180;
1480-
private Color TransColor = Color.FromArgb(0xFE,0xFE,0xFE);
1480+
private Color TransColor = Color.FromArgb(0xFE,0xFE,0xFE); // Almost white
14811481

14821482
private List<string> Categories = new List<string>();
14831483
private List<string> Styles = new List<string>();
@@ -1578,6 +1578,7 @@ private class POI
15781578
public int sty;
15791579

15801580
public POI() { }
1581+
public POI(string name, double lat, double lon) { this.name = name; this.description = null; this.lat = lat; this.lon = lon; }
15811582
public POI(string name, string description, double lat, double lon) { this.name = name; this.description = description; this.lat = lat; this.lon = lon; }
15821583
}
15831584

@@ -1593,9 +1594,9 @@ public byte[] Data
15931594
List<byte> res = new List<byte>();
15941595
res.AddRange(BitConverter.GetBytes(bType));
15951596
if(ExtraData.Count > 0)
1596-
res.AddRange(BitConverter.GetBytes((ushort)0x08));
1597+
res.AddRange(BitConverter.GetBytes((ushort)0x08)); // Has Extra
15971598
else
1598-
res.AddRange(BitConverter.GetBytes((ushort)0x00));
1599+
res.AddRange(BitConverter.GetBytes((ushort)0x00)); // No Extra
15991600
res.AddRange(BitConverter.GetBytes(((uint)(MainData.Count + ExtraData.Count))));
16001601
if(ExtraData.Count > 0)
16011602
res.AddRange(BitConverter.GetBytes(((uint)(MainData.Count))));
@@ -1617,14 +1618,14 @@ private FileBlock GetHeader0Block()
16171618
TimeSpan tsec = DateTime.Now.Subtract(new DateTime(1990, 1, 1));
16181619
uint sec = (uint)tsec.TotalSeconds;
16191620
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(sec)))); // Time
1620-
fb.MainData.AddRange(new byte[] { 1, 0 });
1621-
fb.MainData.AddRange(ToPString(String.IsNullOrEmpty(this.Name) ? "Exported Data" : this.Name, true));
1621+
fb.MainData.AddRange(new byte[] { 1, 0 }); // Must Have
1622+
fb.MainData.AddRange(ToPString(String.IsNullOrEmpty(this.Name) ? "Exported Data" : this.Name, true)); // File Name
16221623
};
16231624
// EXTRA
16241625
{
16251626
FileBlock b15 = new FileBlock();
16261627
b15.bType = 15;
1627-
b15.MainData.AddRange(new byte[] { 1, 7, 9, 0, 0 });
1628+
b15.MainData.AddRange(new byte[] { 1, 7, 9, 0, 0 }); // Must Have
16281629
fb.ExtraData.AddRange(b15.Data);
16291630
};
16301631
return fb;
@@ -1636,19 +1637,20 @@ private FileBlock GetHeader1Block()
16361637
fb.bType = 0x01;
16371638
//Main
16381639
{
1639-
fb.MainData.AddRange(Encoding.ASCII.GetBytes("POI\0"));
1640-
fb.MainData.AddRange(new byte[] { 0, 0 });
1641-
fb.MainData.AddRange(Encoding.ASCII.GetBytes("01"));
1640+
fb.MainData.AddRange(Encoding.ASCII.GetBytes("POI\0")); // Header Text
1641+
fb.MainData.AddRange(new byte[] { 0, 0 }); // Reserved
1642+
fb.MainData.AddRange(Encoding.ASCII.GetBytes("01")); // Version
16421643
fb.MainData.AddRange(BitConverter.GetBytes(((ushort)(0xFDE9)))); //UTF-8 Encoding
16431644
fb.MainData.AddRange(BitConverter.GetBytes(((ushort)(17)))); // Copyrights Exists
16441645
};
16451646
// Extra
16461647
{
1647-
FileBlock b17 = new FileBlock();
1648+
FileBlock b17 = new FileBlock(); // COPYRIGHTS
16481649
b17.bType = 17;
1649-
b17.MainData.AddRange(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
1650-
b17.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource));
1651-
b17.MainData.AddRange(ToLString("Created with KMZRebuilder"));
1650+
b17.MainData.AddRange(new byte[] { 20, 0, 0, 0, 0, 0, 0, 0 }); // Must Have Data
1651+
b17.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource)); // Data Source
1652+
b17.MainData.AddRange(ToLString("Created with KMZRebuilder")); // Copyrights
1653+
b17.MainData.AddRange(new byte[] { 0x01, 0x01, 0xE7, 0x4E }); // Must Have
16521654
fb.ExtraData.AddRange(b17.Data);
16531655
};
16541656
return fb;
@@ -1660,8 +1662,8 @@ private FileBlock GetPOIGroupBlock()
16601662
fb.bType = 9;
16611663
// Main
16621664
{
1663-
fb.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource));
1664-
fb.MainData.AddRange(GetMainAreaBlock().Data);
1665+
fb.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource)); // POI Group Name
1666+
fb.MainData.AddRange(GetMainAreaBlock().Data); // Main Area Block
16651667
};
16661668
// Extra
16671669
{
@@ -1683,8 +1685,7 @@ private FileBlock GetMainAreaBlock()
16831685
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(MaxLon * Math.Pow(2, 32) / 360.0))));
16841686
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(MinLat * Math.Pow(2, 32) / 360.0))));
16851687
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(MinLon * Math.Pow(2, 32) / 360.0))));
1686-
fb.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 0 });
1687-
fb.MainData.Add(0);
1688+
fb.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 2 }); // Must Have
16881689
};
16891690
// Extra
16901691
{
@@ -1707,7 +1708,7 @@ private FileBlock GetSubAreaBlock(uint zone)
17071708
f08.MainData.AddRange(BitConverter.GetBytes(((uint)((lon + 1) * Math.Pow(2, 32) / 360.0))));
17081709
f08.MainData.AddRange(BitConverter.GetBytes(((uint)(lat * Math.Pow(2, 32) / 360.0))));
17091710
f08.MainData.AddRange(BitConverter.GetBytes(((uint)(lon * Math.Pow(2, 32) / 360.0))));
1710-
f08.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 0 });
1711+
f08.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 2 }); // Must Have
17111712
};
17121713
// Extra
17131714
{
@@ -1726,8 +1727,8 @@ private FileBlock GetPOIBlock(POI poi)
17261727
{
17271728
f02.MainData.AddRange(BitConverter.GetBytes(((uint)(poi.lat * Math.Pow(2, 32) / 360.0))));
17281729
f02.MainData.AddRange(BitConverter.GetBytes(((uint)(poi.lon * Math.Pow(2, 32) / 360.0))));
1729-
f02.MainData.AddRange(new byte[] { 1, 0, 0 });
1730-
f02.MainData.AddRange(ToLString(String.IsNullOrEmpty(poi.name) ? "Unknown" : poi.name));
1730+
f02.MainData.AddRange(new byte[] { 1, 0, 0 }); // Reserved
1731+
f02.MainData.AddRange(ToLString(String.IsNullOrEmpty(poi.name) ? "Unknown" : poi.name)); // POI Name
17311732
};
17321733
// Extra
17331734
{
@@ -1756,23 +1757,24 @@ private FileBlock GetCatBlock(int cat)
17561757
{
17571758
FileBlock f07 = new FileBlock();
17581759
f07.bType = 7;
1759-
f07.MainData.AddRange(BitConverter.GetBytes((ushort)cat));
1760-
f07.MainData.AddRange(ToLString(Categories[cat]));
1760+
f07.MainData.AddRange(BitConverter.GetBytes((ushort)cat)); // ID
1761+
f07.MainData.AddRange(ToLString(Categories[cat])); // Name
17611762
return f07;
17621763
}
17631764

17641765
private FileBlock GetCatIDBlock(int cat)
17651766
{
17661767
FileBlock f06 = new FileBlock();
17671768
f06.bType = 6;
1768-
f06.MainData.AddRange(BitConverter.GetBytes((ushort)cat));
1769+
f06.MainData.AddRange(BitConverter.GetBytes((ushort)cat)); // ID
17691770
return f06;
17701771
}
17711772

17721773
private FileBlock GetBmpBlock(int sty)
17731774
{
17741775
FileBlock f05 = new FileBlock();
17751776
f05.bType = 5;
1777+
17761778
List<Color> palette;
17771779
Bitmap im = GetBitmapFromStyle(sty, out palette);
17781780

@@ -1816,16 +1818,16 @@ private FileBlock GetBmpIDBlock(int sty)
18161818
{
18171819
FileBlock f04 = new FileBlock();
18181820
f04.bType = 4;
1819-
f04.MainData.AddRange(BitConverter.GetBytes((ushort)sty));
1821+
f04.MainData.AddRange(BitConverter.GetBytes((ushort)sty)); // ID
18201822
return f04;
18211823
}
18221824

18231825
private FileBlock GetDescBlock(string desc)
18241826
{
18251827
FileBlock f14 = new FileBlock();
18261828
f14.bType = 14;
1827-
f14.MainData.Add(1);
1828-
f14.MainData.AddRange(ToLString(desc));
1829+
f14.MainData.Add(1); // Reserved
1830+
f14.MainData.AddRange(ToLString(desc)); // Text
18291831
return f14;
18301832
}
18311833

@@ -1870,7 +1872,7 @@ private Bitmap GetBitmapFromStyle(int sty, out List<Color> palette)
18701872
return mi.ToBitmap();
18711873
}
18721874

1873-
private byte[] ToPString(string value, bool translit)
1875+
private byte[] ToPString(string value, bool translit) // Pascal-like String
18741876
{
18751877
List<byte> res = new List<byte>();
18761878
byte[] tnArr = Encoding.UTF8.GetBytes(translit ? ml.Translit(value) : value);
@@ -1879,7 +1881,7 @@ private byte[] ToPString(string value, bool translit)
18791881
return res.ToArray();
18801882
}
18811883

1882-
private byte[] ToLString(string value)
1884+
private byte[] ToLString(string value) // Multilang String
18831885
{
18841886
List<byte> res = new List<byte>();
18851887
res.AddRange(Encoding.ASCII.GetBytes("EN"));
@@ -1947,6 +1949,9 @@ private static uint ColorToUint(Color c)
19471949
}
19481950
}
19491951

1952+
/// <summary>
1953+
/// Lang Translit (RU -> EN)
1954+
/// </summary>
19501955
public class Translitter
19511956
{
19521957
private Dictionary<string, string> words = new Dictionary<string, string>();

KMZRebuilder.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<DependentUpon>MapViewerForm.cs</DependentUpon>
145145
</Compile>
146146
<Compile Include="KMZRebuilederForm.cs">
147-
<SubType>Form</SubType>
147+
<SubType>Component</SubType>
148148
</Compile>
149149
<Compile Include="KMZRebuilederForm.Designer.cs">
150150
<DependentUpon>KMZRebuilederForm.cs</DependentUpon>
@@ -164,7 +164,7 @@
164164
<Compile Include="MemoryFile.cs" />
165165
<Compile Include="MruList.cs" />
166166
<Compile Include="MultiPointRouteForm.cs">
167-
<SubType>Form</SubType>
167+
<SubType>Component</SubType>
168168
</Compile>
169169
<Compile Include="MultiPointRouteForm.Designer.cs">
170170
<DependentUpon>MultiPointRouteForm.cs</DependentUpon>

KMZRebuilederForm.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,7 @@ protected override void WndProc(ref Message m)
36153615
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
36163616
string text = fvi.ProductName + " " + fvi.FileVersion + " by " + fvi.CompanyName + "\r\n";
36173617
text += fvi.LegalCopyright + "\r\n";
3618+
text += "\r\n-- with GPI Direct Import/Export Support --";
36183619
text += "\r\n-- with dkxce Route Engine Support --";
36193620
text += "\r\n-- support Raster MBTiles --\r\n";
36203621
try

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
// Build Number
3030
// Revision
3131
//
32-
[assembly: AssemblyVersion("22.1.24.117")]
33-
[assembly: AssemblyFileVersion("22.1.24.117")]
32+
[assembly: AssemblyVersion("22.1.26.119")]
33+
[assembly: AssemblyFileVersion("22.1.26.119")]

bin/Debug/KMZRebuilder.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)