Skip to content

Commit

Permalink
b119
Browse files Browse the repository at this point in the history
  • Loading branch information
dkxce authored Jan 26, 2022
1 parent c0edcc8 commit 3922cd4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
61 changes: 33 additions & 28 deletions GPIReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ public class GPIWriter
private double MaxLat = 90;
private double MinLon = -180;
private double MaxLon = 180;
private Color TransColor = Color.FromArgb(0xFE,0xFE,0xFE);
private Color TransColor = Color.FromArgb(0xFE,0xFE,0xFE); // Almost white

private List<string> Categories = new List<string>();
private List<string> Styles = new List<string>();
Expand Down Expand Up @@ -1578,6 +1578,7 @@ private class POI
public int sty;

public POI() { }
public POI(string name, double lat, double lon) { this.name = name; this.description = null; this.lat = lat; this.lon = lon; }
public POI(string name, string description, double lat, double lon) { this.name = name; this.description = description; this.lat = lat; this.lon = lon; }
}

Expand All @@ -1593,9 +1594,9 @@ public byte[] Data
List<byte> res = new List<byte>();
res.AddRange(BitConverter.GetBytes(bType));
if(ExtraData.Count > 0)
res.AddRange(BitConverter.GetBytes((ushort)0x08));
res.AddRange(BitConverter.GetBytes((ushort)0x08)); // Has Extra
else
res.AddRange(BitConverter.GetBytes((ushort)0x00));
res.AddRange(BitConverter.GetBytes((ushort)0x00)); // No Extra
res.AddRange(BitConverter.GetBytes(((uint)(MainData.Count + ExtraData.Count))));
if(ExtraData.Count > 0)
res.AddRange(BitConverter.GetBytes(((uint)(MainData.Count))));
Expand All @@ -1617,14 +1618,14 @@ private FileBlock GetHeader0Block()
TimeSpan tsec = DateTime.Now.Subtract(new DateTime(1990, 1, 1));
uint sec = (uint)tsec.TotalSeconds;
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(sec)))); // Time
fb.MainData.AddRange(new byte[] { 1, 0 });
fb.MainData.AddRange(ToPString(String.IsNullOrEmpty(this.Name) ? "Exported Data" : this.Name, true));
fb.MainData.AddRange(new byte[] { 1, 0 }); // Must Have
fb.MainData.AddRange(ToPString(String.IsNullOrEmpty(this.Name) ? "Exported Data" : this.Name, true)); // File Name
};
// EXTRA
{
FileBlock b15 = new FileBlock();
b15.bType = 15;
b15.MainData.AddRange(new byte[] { 1, 7, 9, 0, 0 });
b15.MainData.AddRange(new byte[] { 1, 7, 9, 0, 0 }); // Must Have
fb.ExtraData.AddRange(b15.Data);
};
return fb;
Expand All @@ -1636,19 +1637,20 @@ private FileBlock GetHeader1Block()
fb.bType = 0x01;
//Main
{
fb.MainData.AddRange(Encoding.ASCII.GetBytes("POI\0"));
fb.MainData.AddRange(new byte[] { 0, 0 });
fb.MainData.AddRange(Encoding.ASCII.GetBytes("01"));
fb.MainData.AddRange(Encoding.ASCII.GetBytes("POI\0")); // Header Text
fb.MainData.AddRange(new byte[] { 0, 0 }); // Reserved
fb.MainData.AddRange(Encoding.ASCII.GetBytes("01")); // Version
fb.MainData.AddRange(BitConverter.GetBytes(((ushort)(0xFDE9)))); //UTF-8 Encoding
fb.MainData.AddRange(BitConverter.GetBytes(((ushort)(17)))); // Copyrights Exists
};
// Extra
{
FileBlock b17 = new FileBlock();
FileBlock b17 = new FileBlock(); // COPYRIGHTS
b17.bType = 17;
b17.MainData.AddRange(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
b17.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource));
b17.MainData.AddRange(ToLString("Created with KMZRebuilder"));
b17.MainData.AddRange(new byte[] { 20, 0, 0, 0, 0, 0, 0, 0 }); // Must Have Data
b17.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource)); // Data Source
b17.MainData.AddRange(ToLString("Created with KMZRebuilder")); // Copyrights
b17.MainData.AddRange(new byte[] { 0x01, 0x01, 0xE7, 0x4E }); // Must Have
fb.ExtraData.AddRange(b17.Data);
};
return fb;
Expand All @@ -1660,8 +1662,8 @@ private FileBlock GetPOIGroupBlock()
fb.bType = 9;
// Main
{
fb.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource));
fb.MainData.AddRange(GetMainAreaBlock().Data);
fb.MainData.AddRange(ToLString(String.IsNullOrEmpty(this.DataSource) ? "KMZRebuilder" : this.DataSource)); // POI Group Name
fb.MainData.AddRange(GetMainAreaBlock().Data); // Main Area Block
};
// Extra
{
Expand All @@ -1683,8 +1685,7 @@ private FileBlock GetMainAreaBlock()
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(MaxLon * Math.Pow(2, 32) / 360.0))));
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(MinLat * Math.Pow(2, 32) / 360.0))));
fb.MainData.AddRange(BitConverter.GetBytes(((uint)(MinLon * Math.Pow(2, 32) / 360.0))));
fb.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 0 });
fb.MainData.Add(0);
fb.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 2 }); // Must Have
};
// Extra
{
Expand All @@ -1707,7 +1708,7 @@ private FileBlock GetSubAreaBlock(uint zone)
f08.MainData.AddRange(BitConverter.GetBytes(((uint)((lon + 1) * Math.Pow(2, 32) / 360.0))));
f08.MainData.AddRange(BitConverter.GetBytes(((uint)(lat * Math.Pow(2, 32) / 360.0))));
f08.MainData.AddRange(BitConverter.GetBytes(((uint)(lon * Math.Pow(2, 32) / 360.0))));
f08.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 0 });
f08.MainData.AddRange(new byte[] { 0, 0, 0, 0, 1, 0, 2 }); // Must Have
};
// Extra
{
Expand All @@ -1726,8 +1727,8 @@ private FileBlock GetPOIBlock(POI poi)
{
f02.MainData.AddRange(BitConverter.GetBytes(((uint)(poi.lat * Math.Pow(2, 32) / 360.0))));
f02.MainData.AddRange(BitConverter.GetBytes(((uint)(poi.lon * Math.Pow(2, 32) / 360.0))));
f02.MainData.AddRange(new byte[] { 1, 0, 0 });
f02.MainData.AddRange(ToLString(String.IsNullOrEmpty(poi.name) ? "Unknown" : poi.name));
f02.MainData.AddRange(new byte[] { 1, 0, 0 }); // Reserved
f02.MainData.AddRange(ToLString(String.IsNullOrEmpty(poi.name) ? "Unknown" : poi.name)); // POI Name
};
// Extra
{
Expand Down Expand Up @@ -1756,23 +1757,24 @@ private FileBlock GetCatBlock(int cat)
{
FileBlock f07 = new FileBlock();
f07.bType = 7;
f07.MainData.AddRange(BitConverter.GetBytes((ushort)cat));
f07.MainData.AddRange(ToLString(Categories[cat]));
f07.MainData.AddRange(BitConverter.GetBytes((ushort)cat)); // ID
f07.MainData.AddRange(ToLString(Categories[cat])); // Name
return f07;
}

private FileBlock GetCatIDBlock(int cat)
{
FileBlock f06 = new FileBlock();
f06.bType = 6;
f06.MainData.AddRange(BitConverter.GetBytes((ushort)cat));
f06.MainData.AddRange(BitConverter.GetBytes((ushort)cat)); // ID
return f06;
}

private FileBlock GetBmpBlock(int sty)
{
FileBlock f05 = new FileBlock();
f05.bType = 5;

List<Color> palette;
Bitmap im = GetBitmapFromStyle(sty, out palette);

Expand Down Expand Up @@ -1816,16 +1818,16 @@ private FileBlock GetBmpIDBlock(int sty)
{
FileBlock f04 = new FileBlock();
f04.bType = 4;
f04.MainData.AddRange(BitConverter.GetBytes((ushort)sty));
f04.MainData.AddRange(BitConverter.GetBytes((ushort)sty)); // ID
return f04;
}

private FileBlock GetDescBlock(string desc)
{
FileBlock f14 = new FileBlock();
f14.bType = 14;
f14.MainData.Add(1);
f14.MainData.AddRange(ToLString(desc));
f14.MainData.Add(1); // Reserved
f14.MainData.AddRange(ToLString(desc)); // Text
return f14;
}

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

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

private byte[] ToLString(string value)
private byte[] ToLString(string value) // Multilang String
{
List<byte> res = new List<byte>();
res.AddRange(Encoding.ASCII.GetBytes("EN"));
Expand Down Expand Up @@ -1947,6 +1949,9 @@ private static uint ColorToUint(Color c)
}
}

/// <summary>
/// Lang Translit (RU -> EN)
/// </summary>
public class Translitter
{
private Dictionary<string, string> words = new Dictionary<string, string>();
Expand Down
4 changes: 2 additions & 2 deletions KMZRebuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
<DependentUpon>MapViewerForm.cs</DependentUpon>
</Compile>
<Compile Include="KMZRebuilederForm.cs">
<SubType>Form</SubType>
<SubType>Component</SubType>
</Compile>
<Compile Include="KMZRebuilederForm.Designer.cs">
<DependentUpon>KMZRebuilederForm.cs</DependentUpon>
Expand All @@ -164,7 +164,7 @@
<Compile Include="MemoryFile.cs" />
<Compile Include="MruList.cs" />
<Compile Include="MultiPointRouteForm.cs">
<SubType>Form</SubType>
<SubType>Component</SubType>
</Compile>
<Compile Include="MultiPointRouteForm.Designer.cs">
<DependentUpon>MultiPointRouteForm.cs</DependentUpon>
Expand Down
1 change: 1 addition & 0 deletions KMZRebuilederForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,7 @@ protected override void WndProc(ref Message m)
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
string text = fvi.ProductName + " " + fvi.FileVersion + " by " + fvi.CompanyName + "\r\n";
text += fvi.LegalCopyright + "\r\n";
text += "\r\n-- with GPI Direct Import/Export Support --";
text += "\r\n-- with dkxce Route Engine Support --";
text += "\r\n-- support Raster MBTiles --\r\n";
try
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("22.1.24.117")]
[assembly: AssemblyFileVersion("22.1.24.117")]
[assembly: AssemblyVersion("22.1.26.119")]
[assembly: AssemblyFileVersion("22.1.26.119")]
Binary file modified bin/Debug/KMZRebuilder.exe
Binary file not shown.

0 comments on commit 3922cd4

Please sign in to comment.