Skip to content

Commit b1695c3

Browse files
layer metadata working
1 parent c2f4e6d commit b1695c3

2 files changed

Lines changed: 62 additions & 34 deletions

File tree

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,51 @@
1-
using System.Collections.Generic;
2-
using System.IO;
3-
4-
namespace RaveAddIn.ProjectTree
5-
{
6-
class GISDataset : FileSystemDataset, IGISLayer
7-
{
8-
public string SymbologyKey { get; private set; }
9-
public short Transparency { get; private set; }
10-
11-
public string GISPath { get { return Path.FullName; } }
12-
13-
public readonly Dictionary<string, string> Metadata;
14-
15-
public GISDataset(RaveProject project, string name, FileSystemInfo fsInfo, string symbologyKey, short transparency, int imageIndex_Exists, int imageIndex_Missing, string id, Dictionary<string, string> metadata)
16-
: base(project, name, fsInfo, imageIndex_Exists, imageIndex_Missing, id)
17-
{
18-
SymbologyKey = symbologyKey;
19-
Transparency = transparency;
20-
21-
Metadata = metadata;
22-
}
23-
}
24-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
5+
namespace RaveAddIn.ProjectTree
6+
{
7+
class GISDataset : FileSystemDataset, IGISLayer
8+
{
9+
public const string ProgramKey = "_rs_wh_program";
10+
public const string ProjectKey = "_rs_wh_id";
11+
12+
public string SymbologyKey { get; private set; }
13+
public short Transparency { get; private set; }
14+
15+
public string GISPath { get { return Path.FullName; } }
16+
17+
public readonly Dictionary<string, string> Metadata;
18+
19+
public bool HasWarehouseRefernce
20+
{
21+
get
22+
{
23+
return Metadata != null && Metadata.Count >= 2 &&
24+
Metadata.ContainsKey(ProgramKey) && Metadata.ContainsKey(ProjectKey);
25+
26+
}
27+
}
28+
29+
public Uri WarehouseReference
30+
{
31+
get
32+
{
33+
if (!HasWarehouseRefernce)
34+
return null;
35+
36+
Uri baseUri = new Uri(Properties.Resources.DataWarehouseURL);
37+
Uri projectUri = new Uri(baseUri, string.Format("#/{0}/{1}", Metadata[ProgramKey], Metadata[ProjectKey]));
38+
return projectUri;
39+
}
40+
}
41+
42+
public GISDataset(RaveProject project, string name, FileSystemInfo fsInfo, string symbologyKey, short transparency, int imageIndex_Exists, int imageIndex_Missing, string id, Dictionary<string, string> metadata)
43+
: base(project, name, fsInfo, imageIndex_Exists, imageIndex_Missing, id)
44+
{
45+
SymbologyKey = symbologyKey;
46+
Transparency = transparency;
47+
48+
Metadata = metadata;
49+
}
50+
}
51+
}

RaveAddIn/ucProjectExplorer.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public ucProjectExplorer(object hook)
5757
ToolStripItem ts = cmsGIS.Items.Add("View Layer MetaData", Properties.Resources.metadata, OnGISMetadata);
5858
ts.Name = "tsiViewLayerMetadata";
5959

60-
cmsGIS.Items.Add("View Layer Source Project", Properties.Resources.RAVE, OnGISSource);
60+
ToolStripItem tss = cmsGIS.Items.Add("View Source Riverscapes Project", Properties.Resources.RAVE, OnGISSource);
61+
tss.Name = "tsiViewLayerSourceProject";
62+
6163
cmsGIS.Items.Add("Browse Folder", Properties.Resources.BrowseFolder, OnExplore);
6264
//cmsGIS.Opening += onGISMenuOpening;
6365

@@ -83,6 +85,12 @@ public void AfterTreeNodeSelect(object sender, TreeViewEventArgs e)
8385
{
8486
matches[0].Enabled = ((GISDataset)e.Node.Tag).Metadata != null;
8587
}
88+
89+
ToolStripItem[] matches2 = e.Node.ContextMenuStrip.Items.Find("tsiViewLayerSourceProject", false);
90+
if (matches2.Length == 1)
91+
{
92+
matches2[0].Enabled = ((GISDataset)e.Node.Tag).HasWarehouseRefernce;
93+
}
8694
}
8795
}
8896

@@ -329,15 +337,8 @@ public void OnGISSource(object sender, EventArgs e)
329337
IGroupLayer parentGrpLyr = BuildArcMapGroupLayers(selNode);
330338
GISDataset layer = (GISDataset)selNode.Tag;
331339

332-
if (layer.Metadata != null && layer.Metadata.Count > 0)
333-
{
334-
if (layer.Metadata.ContainsKey("_rs_wh_program") && layer.Metadata.ContainsKey("_rs_wh_id"))
335-
{
336-
Uri baseUri = new Uri(Properties.Resources.DataWarehouseURL);
337-
Uri projectUri = new Uri(baseUri, string.Format("#/{0}/{1}", layer.Metadata["_rs_wh_program"], layer.Metadata["_rs_wh_id"]));
338-
System.Diagnostics.Process.Start(projectUri.ToString());
339-
}
340-
}
340+
if (layer.HasWarehouseRefernce)
341+
System.Diagnostics.Process.Start(layer.WarehouseReference.ToString());
341342
}
342343
catch (Exception ex)
343344
{

0 commit comments

Comments
 (0)