private void Initialize(CIMLayerDocument layerDoc) { // If a layer doc has only one layer, pose as that layer, otherwise pose as a group layer if (layerDoc.Layers.Length == 1) { var proxy = new ProLayer(_path, layerDoc, layerDoc.Layers[0]); Container = proxy.Container; ContainerType = proxy.ContainerType; DataSetName = proxy.DataSetName; DataSetType = proxy.DataSetType; DataSource = proxy.DataSource; DataSourceName = proxy.DataSourceName; DataType = proxy.DataType; IsGroup = proxy.IsGroup; SubLayers = proxy.SubLayers; Name = proxy.Name; WorkspacePath = proxy.WorkspacePath; WorkspaceProgId = proxy.WorkspaceProgId; WorkspaceType = proxy.WorkspaceType; } else if (layerDoc.Layers.Length > 1) { IsGroup = true; DataType = "Group Layer"; SubLayers = layerDoc.Layers.Select(l => new ProLayer(_path, layerDoc, l)); } else { throw new ApplicationException("The layer file has less than 1 layer"); } }
private void Open() { var text = System.IO.File.ReadAllText(_path, Encoding.UTF8); var layerDoc = CIMLayerDocument.FromJson(text); Initialize(layerDoc); }
public static T GetRenderer <T>([NotNull] LayerDocument template) where T : CIMRenderer { CIMLayerDocument layerDocument = template.GetCIMLayerDocument(); // todo daro: implement more robust CIMDefinition definition = layerDocument.LayerDefinitions[0]; return(((CIMFeatureLayer)definition)?.Renderer as T); }
public static LayerDocument CreateLayerDocument([NotNull] string path, string layerName) { var layerDocument = CreateLayerDocument(path); CIMLayerDocument cimLayerDocument = layerDocument.GetCIMLayerDocument(); cimLayerDocument.LayerDefinitions[0].Name = layerName; return(new LayerDocument(cimLayerDocument)); }
public ProLayer(string path, CIMLayerDocument doc, string uri) { _path = path; _layerDoc = doc; _layer = doc.LayerDefinitions.FirstOrDefault(l => l.URI == uri); try { Initialize(); } catch (Exception ex) { DataType = "Error: " + ex.Message; } if (DataType == null) { DataType = LayerDescription; } SubLayers = GetSubLayers(); }