@@ -99,6 +99,11 @@ public KMZRebuilederForm(string[] args)
99
99
MapIcons.InitZip(CurrentDirectory() + @"\mapicons\default.zip");
100
100
}
101
101
102
+ private void AfterLoadPrefs()
103
+ {
104
+ convertToToolStripMenuItem.Visible = Properties.GetBoolValue("gpiwriter_hide_old_menus_items");
105
+ }
106
+
102
107
public static void ConvertGPI2KMZ(string gpiFile, string kmzFile)
103
108
{
104
109
if (String.IsNullOrEmpty(gpiFile)) return;
@@ -764,6 +769,8 @@ private void Save2WPT(string filename, KMLayer kml)
764
769
if ((std != null) && (std.ChildNodes.Count > 0))
765
770
desc = std.ChildNodes[0].Value;
766
771
772
+ if (desc.Contains("wpt_skip=true")) continue;
773
+
767
774
bool toTop = false;
768
775
if (!String.IsNullOrEmpty(desc))
769
776
{
@@ -954,10 +961,15 @@ private void Save2ReportHTML(string filename, IDictionary<string, string[]> fiel
954
961
955
962
private string Save2KMZ(string filename, bool multilayers)
956
963
{
957
- return Save2KMZ(filename, multilayers, true);
964
+ return Save2KMZ(filename, multilayers, true, null );
958
965
}
959
966
960
967
private string Save2KMZ(string filename, bool multilayers, bool createArchive)
968
+ {
969
+ return Save2KMZ(filename, multilayers, createArchive, null);
970
+ }
971
+
972
+ private string Save2KMZ(string filename, bool multilayers, bool createArchive, string desc_filter_skip)
961
973
{
962
974
log.Text = "";
963
975
@@ -991,20 +1003,37 @@ private string Save2KMZ(string filename, bool multilayers, bool createArchive)
991
1003
int ttlpm = 0;
992
1004
for (int i = 0; i < kmzLayers.CheckedItems.Count; i++)
993
1005
{
1006
+ bool skiplay = false;
1007
+
994
1008
KMLayer kml = (KMLayer)kmzLayers.CheckedItems[i];
995
1009
CopySounds(kml.file, zdir);
996
1010
XmlNode xn = kml.file.kmlDoc.SelectNodes("kml/Document/Folder")[kml.id];
997
1011
998
- ttlpm += kml.placemarks;
999
-
1000
1012
// remove names
1001
1013
if (!multilayers)
1002
1014
{
1003
1015
XmlNode nn = xn.SelectSingleNode("name");
1004
1016
if (nn != null) xn.RemoveChild(nn);
1005
1017
nn = xn.SelectSingleNode("description");
1006
- if (nn != null) xn.RemoveChild(nn);
1007
- };
1018
+ if (nn != null)
1019
+ {
1020
+ if (!String.IsNullOrEmpty(desc_filter_skip))
1021
+ {
1022
+ try
1023
+ {
1024
+ string description = nn.ChildNodes[0].Value;
1025
+ if (!String.IsNullOrEmpty(description))
1026
+ if (description.Contains(desc_filter_skip))
1027
+ skiplay = true;
1028
+ }
1029
+ catch { };
1030
+ };
1031
+ xn.RemoveChild(nn);
1032
+ };
1033
+ };
1034
+
1035
+ if (skiplay) continue;
1036
+ ttlpm += kml.placemarks;
1008
1037
1009
1038
// styles
1010
1039
{
@@ -1899,6 +1928,14 @@ public int Compare(DictionaryEntry a, DictionaryEntry b)
1899
1928
}
1900
1929
}
1901
1930
1931
+ private static string GetFolderDesc(XmlNode placemark)
1932
+ {
1933
+ string desc = "";
1934
+ try { desc = placemark.ParentNode.SelectSingleNode("description").ChildNodes[0].Value; }
1935
+ catch { return ""; };
1936
+ return desc;
1937
+ }
1938
+
1902
1939
private static void Save2GPIInt(string gpifile, KMFile kmfile, string proj_name, GPIReader.Add2LogProc Add2Log, Preferences Props)
1903
1940
{
1904
1941
GPIReader.LOCALE_LANGUAGE = Props["gpi_localization"].ToUpper();
@@ -1953,6 +1990,9 @@ private static void Save2GPIInt(string gpifile, KMFile kmfile, string proj_name,
1953
1990
catch { };
1954
1991
string[] ll = n.ChildNodes[0].Value.Split(new string[] { "," }, StringSplitOptions.None);
1955
1992
1993
+ if (GetFolderDesc(n.ParentNode.ParentNode).Contains("gpi_skip=true")) continue;
1994
+ if (desc.Contains("gpi_skip=true")) continue;
1995
+
1956
1996
string styleUrl = "";
1957
1997
if (n.ParentNode.ParentNode.SelectSingleNode("styleUrl") != null) styleUrl = n.ParentNode.ParentNode.SelectSingleNode("styleUrl").ChildNodes[0].Value;
1958
1998
if (styleUrl.IndexOf("#") == 0) styleUrl = styleUrl.Remove(0, 1);
@@ -3564,6 +3604,8 @@ private void Export2WPT(KMLayer kml)
3564
3604
if ((std != null) && (std.ChildNodes.Count > 0))
3565
3605
desc = std.ChildNodes[0].Value;
3566
3606
3607
+ if (desc.Contains("wpt_skip=true")) continue;
3608
+
3567
3609
bool toTop = false;
3568
3610
if (!String.IsNullOrEmpty(desc))
3569
3611
{
@@ -3760,7 +3802,10 @@ private void contextMenuStrip3_Opening(object sender, CancelEventArgs e)
3760
3802
export2DatToolStripMenuItem.Enabled = kmzLayers.CheckedIndices.Count > 0;
3761
3803
export2GDBToolStripMenuItem.Enabled = kmzLayers.CheckedIndices.Count > 0;
3762
3804
export2WPTnoIconsToolStripMenuItem.Enabled = kmzLayers.CheckedIndices.Count > 0;
3805
+
3806
+ convertToToolStripMenuItem.Visible = !Properties.GetBoolValue("gpiwriter_hide_old_menus_items");
3763
3807
convertToGarminPointsOfInterestsFileGPIToolStripMenuItem.Enabled = saveBTNG.Enabled;
3808
+
3764
3809
c2DGPIToolStripMenuItem.Enabled = saveBTNG.Enabled;
3765
3810
}
3766
3811
@@ -5465,6 +5510,8 @@ private void Export2Dat(KMLayer kml)
5465
5510
if ((std != null) && (std.ChildNodes.Count > 0))
5466
5511
desc = std.ChildNodes[0].Value;
5467
5512
5513
+ if (desc.Contains("progorod_skip=true")) continue;
5514
+
5468
5515
ProGorodPOI.FavRecord rec = new ProGorodPOI.FavRecord();
5469
5516
rec.Name = name;
5470
5517
rec.Lat = double.Parse(llz[1].Replace("\r", "").Replace("\n", "").Replace(" ", ""), System.Globalization.CultureInfo.InvariantCulture);
@@ -6617,6 +6664,8 @@ private void Export2GDB(KMLayer kml)
6617
6664
if ((std != null) && (std.ChildNodes.Count > 0))
6618
6665
desc = std.ChildNodes[0].Value;
6619
6666
6667
+ if (desc.Contains("navitel_skip=true")) continue;
6668
+
6620
6669
bool toTop = false;
6621
6670
if (!String.IsNullOrEmpty(desc))
6622
6671
{
@@ -7664,7 +7713,7 @@ private void ReloadOriginalFiles()
7664
7713
private void exportToWPTToolStripMenuItem_Click(object sender, EventArgs e)
7665
7714
{
7666
7715
if (kmzLayers.CheckedIndices.Count == 0) return;
7667
- string zdir = Save2KMZ(null, false, false);
7716
+ string zdir = Save2KMZ(null, false, false, "wpt_skip=true" );
7668
7717
KMFile kf = KMFile.FromZDir(zdir);
7669
7718
Export2WPT(kf.kmLayers[0]);
7670
7719
ReloadOriginalFiles();
@@ -7673,7 +7722,7 @@ private void exportToWPTToolStripMenuItem_Click(object sender, EventArgs e)
7673
7722
private void export2DatToolStripMenuItem_Click(object sender, EventArgs e)
7674
7723
{
7675
7724
if (kmzLayers.CheckedIndices.Count == 0) return;
7676
- string zdir = Save2KMZ(null, false, false);
7725
+ string zdir = Save2KMZ(null, false, false, "progorod_skip=true" );
7677
7726
KMFile kf = KMFile.FromZDir(zdir);
7678
7727
Export2Dat(kf.kmLayers[0]);
7679
7728
ReloadOriginalFiles();
@@ -7682,7 +7731,7 @@ private void export2DatToolStripMenuItem_Click(object sender, EventArgs e)
7682
7731
private void export2GDBToolStripMenuItem_Click(object sender, EventArgs e)
7683
7732
{
7684
7733
if (kmzLayers.CheckedIndices.Count == 0) return;
7685
- string zdir = Save2KMZ(null, false, false);
7734
+ string zdir = Save2KMZ(null, false, false, "navitel_skip=true" );
7686
7735
KMFile kf = KMFile.FromZDir(zdir);
7687
7736
Export2GDB(kf.kmLayers[0]);
7688
7737
ReloadOriginalFiles();
@@ -7691,17 +7740,19 @@ private void export2GDBToolStripMenuItem_Click(object sender, EventArgs e)
7691
7740
private void export2WPTnoIconsToolStripMenuItem_Click(object sender, EventArgs e)
7692
7741
{
7693
7742
if (kmzLayers.CheckedIndices.Count == 0) return;
7694
- string zdir = Save2KMZ(null, false, false);
7743
+ string zdir = Save2KMZ(null, false, false, "wpt_skip=true" );
7695
7744
KMFile kf = KMFile.FromZDir(zdir);
7696
7745
Save2WPTNoIcons(kf.kmLayers[0]);
7697
7746
ReloadOriginalFiles();
7698
7747
}
7699
7748
7700
7749
private void HelpDesc_Click(object sender, EventArgs e)
7701
7750
{
7702
- string help = "To Create GPI:\r\n";
7703
- help += " gpi_name_<IMAGECRC>=<FULLNAME>\r\n";
7704
- help += " gpi_subname_<IMAGECRC>=<SUBNAME>\r\n";
7751
+ string help = "To Export GPI/WPT/DAT/GDB:\r\n";
7752
+ help += " gpi_skip=true\r\n";
7753
+ help += " wpt_skip=true\r\n";
7754
+ help += " navitel_skip=true\r\n";
7755
+ help += " progorod_skip=true\r\n";
7705
7756
help += "\r\nFor Route Planner\r\n";
7706
7757
help += " route_planner_skip=true\r\n";
7707
7758
help += " route_planner_skip=false\r\n";
@@ -8540,6 +8591,67 @@ private void bchelpb_Click(object sender, EventArgs e)
8540
8591
helptext += " MapPolygonCreator: /mpc\r\n\r\n";
8541
8592
MessageBox.Show(helptext, "Command Line Syntax", MessageBoxButtons.OK, MessageBoxIcon.Information);
8542
8593
}
8594
+
8595
+ private void SetLayersCheckByDescIf(string condition, bool check)
8596
+ {
8597
+ if (kmzLayers.Items.Count == 0) return;
8598
+ for (int i = 0; i < kmzLayers.Items.Count; i++)
8599
+ {
8600
+ KMLayer kml = (KMLayer)kmzLayers.Items[i];
8601
+ XmlNode pmk = kml.file.kmlDoc.SelectNodes("kml/Document/Folder")[kml.id];
8602
+ string description = "";
8603
+ try
8604
+ {
8605
+ description = pmk.SelectSingleNode("description").ChildNodes[0].Value;
8606
+ if (!String.IsNullOrEmpty(description))
8607
+ if (description.Contains(condition))
8608
+ kmzLayers.SetItemChecked(i, check);
8609
+ }
8610
+ catch { };
8611
+ };
8612
+ }
8613
+
8614
+ private void checkIfDescriptionContainsToolStripMenuItem_Click(object sender, EventArgs e)
8615
+ {
8616
+ if (kmzLayers.Items.Count == 0) return;
8617
+ string tc = "main=true";
8618
+ if (InputBox("Check Layers", "If description contains text:", ref tc) != DialogResult.OK) return;
8619
+ SetLayersCheckByDescIf(tc, true);
8620
+ }
8621
+
8622
+ private void uncheckIfDescriptionContainsToolStripMenuItem_Click_1(object sender, EventArgs e)
8623
+ {
8624
+ if (kmzLayers.Items.Count == 0) return;
8625
+ string tc = "main=true";
8626
+ if (InputBox("Uncheck Layers", "If description contains text:", ref tc) != DialogResult.OK) return;
8627
+ SetLayersCheckByDescIf(tc, false);
8628
+ }
8629
+
8630
+ private void uncheckgpiskiptrueToolStripMenuItem_Click(object sender, EventArgs e)
8631
+ {
8632
+ if (kmzLayers.Items.Count == 0) return;
8633
+ SetLayersCheckByDescIf("gpi_skip=true", false);
8634
+ }
8635
+
8636
+ private void uncheckprogorodskiptrueToolStripMenuItem_Click(object sender, EventArgs e)
8637
+ {
8638
+ if (kmzLayers.Items.Count == 0) return;
8639
+ SetLayersCheckByDescIf("progorod_skip=true", false);
8640
+ }
8641
+
8642
+ private void unchecknavitelskiptrueToolStripMenuItem_Click(object sender, EventArgs e)
8643
+ {
8644
+ if (kmzLayers.Items.Count == 0) return;
8645
+ SetLayersCheckByDescIf("navitel_skip=true", false);
8646
+ }
8647
+
8648
+ private void uncheckwptskiptrueToolStripMenuItem_Click(object sender, EventArgs e)
8649
+ {
8650
+ if (kmzLayers.Items.Count == 0) return;
8651
+ SetLayersCheckByDescIf("wpt_skip=true", false);
8652
+ }
8653
+
8654
+
8543
8655
}
8544
8656
8545
8657
public class FilesListBox : CheckedListBox
@@ -10239,7 +10351,7 @@ public void GarminGDB2KML(string origin_name)
10239
10351
//List<string> types = new List<string>();
10240
10352
//for (int i = 0; i < 20; i++) types.Add(((ProGorodPOI.TType)i).ToString());
10241
10353
10242
- FileStream fs = new FileStream(this.tmp_file_dir + "doc ", FileMode.Create, FileAccess.Write);
10354
+ FileStream fs = new FileStream(this.tmp_file_dir + "doc.kml ", FileMode.Create, FileAccess.Write);
10243
10355
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
10244
10356
sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
10245
10357
sw.WriteLine("<kml>");
0 commit comments