/// <summary> /// Load the data from the datasource and create a featurelayer with custom dictionairy renderer. /// </summary> public static void ShowActualWeather() { PluginDatasourceConnectionPath pluginDataSource = new PluginDatasourceConnectionPath("BuienRadarDataSource_Datasource", new Uri(@"https://data.buienradar.nl/2.0/feed/json")); // Load the data and create a futurelayer using (PluginDatastore pluginDataStore = new PluginDatastore(pluginDataSource)) { foreach (string tableName in pluginDataStore.GetTableNames()) { using (Table table = pluginDataStore.OpenTable(tableName)) { if (table is FeatureClass weatherFeatureClass) { //Add as a layer to the active map or scene. FeatureLayer weatherLayer = LayerFactory.Instance.CreateFeatureLayer(weatherFeatureClass, MapView.Active.Map); // Create and add the weatherlabels. SetLabeling(weatherLayer); // Show the layer weatherLayer.SetLabelVisibility(true); // Create a renderer based on the weather data. CIMUniqueValueRenderer weatherRenderer = CreateRedenderer(table); // Set the renderer on the featurelayer weatherLayer.SetRenderer(weatherRenderer); } } } } }
protected async override void OnClick() { //Change this path to the path of your sample csv data string csv_path = @"C:\Data\SimplePointPlugin\SimplePointData"; await QueuedTask.Run(() => { using (var pluginws = new PluginDatastore( new PluginDatasourceConnectionPath("SimplePointPlugin_Datasource", new Uri(csv_path, UriKind.Absolute)))) { System.Diagnostics.Debug.Write("==========================\r\n"); foreach (var table_name in pluginws.GetTableNames()) { System.Diagnostics.Debug.Write($"Table: {table_name}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder using (var table = pluginws.OpenTable(table_name)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } } }); }
private FeatureLayer AddLayer([NotNull] Uri dataSource, string worklistName, [NotNull] string layerName) { PluginDatasourceConnectionPath connector = new PluginDatasourceConnectionPath(PluginIdentifier, dataSource); using (var datastore = new PluginDatastore(connector)) { using (Table table = datastore.OpenTable(worklistName)) { FeatureLayer worklistLayer = LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map, LayerPosition.AddToTop, layerName); LayerUtils.SetLayerSelectability(worklistLayer, false); if (!_uriByWorklistName.ContainsKey(worklistName)) { _uriByWorklistName.Add(worklistName, LayerUtils.GetUri(worklistLayer)); } return(worklistLayer); } } }
protected async override void OnClick() { //Change this path to the path of your sample csv data string csv_path = @"C:\Data\SimplePointPlugin\SimplePointData"; await QueuedTask.Run(() => { using (PluginDatastore pluginws = new PluginDatastore( new PluginDatasourceConnectionPath("SimplePointPlugin_Datasource", new Uri(csv_path, UriKind.Absolute)))) { System.Diagnostics.Debug.Write("==========================\r\n"); foreach (var table_name in pluginws.GetTableNames()) { System.Diagnostics.Debug.Write($"Table: {table_name}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder using (var table = pluginws.OpenTable(table_name)) { //get information about the table using (var def = table.GetDefinition() as FeatureClassDefinition) { } //query and return all rows //TODO - use a QueryFilter and Whereclause //var qf = new QueryFilter() //{ // WhereClause = "OBJECTID > 0" //}; //var rc = table.Search(qf); using (var rc = table.Search(null)) { while (rc.MoveNext()) { using (var feat = rc.Current as Feature) { //Get information from the feature var oid = feat.GetObjectID(); var shape = feat.GetShape(); //Access all the values var count = feat.GetFields().Count(); for (int i = 0; i < count; i++) { var val = feat[i]; //TODO use the value(s) } } } } } } } }); }
private void Button_Click(object sender, RoutedEventArgs e) { String uri = String.Format("{0}:{1}|{2}", hostnameTbx.Text, portTbx.Text, catalogTbx.Text); QueuedTask.Run(() => { using (PluginDatastore pluginws = new PluginDatastore(new PluginDatasourceConnectionPath("HbasePlugin1_Datasource", new Uri(uri, UriKind.Absolute)))) { using (var table = pluginws.OpenTable("gdelt-quickstart")) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } }); this.Close(); }
protected async override void OnClick() { try { //Change this path to the path of your sample csv data string csvPath = @"C:\Data\SimplePointPlugin\SimplePointData"; var dirCsv = new DirectoryInfo(csvPath); if (!dirCsv.Exists) { throw new Exception($@"The sample cannot find and csv files in this folder: {csvPath}"); } var csvFiles = dirCsv.GetFiles(); if (csvFiles.Length <= 0) { throw new Exception($@"The test folder has no csv files: {csvPath}"); } await QueuedTask.Run(() => { using (var pluginws = new PluginDatastore( new PluginDatasourceConnectionPath("SimplePointPlugin_Datasource", new Uri(csvPath, UriKind.Absolute)))) { System.Diagnostics.Debug.Write("==========================\r\n"); foreach (var table_name in pluginws.GetTableNames()) { System.Diagnostics.Debug.Write($"Table: {table_name}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder using (var table = pluginws.OpenTable(table_name)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateLayer <FeatureLayer>(new FeatureLayerCreationParams((FeatureClass)table), MapView.Active.Map); } } } }); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private FeatureLayer AddLayer([NotNull] string workListName) { PluginDatasourceConnectionPath connector = GetWorkListConnectionPath(workListName); // todo daro: disposing our own datastore and table?!? using (var datastore = new PluginDatastore(connector)) { using (Table table = datastore.OpenTable(workListName)) { FeatureLayer workListLayer = LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map, LayerPosition.AddToTop); Commons.LayerUtils.SetLayerSelectability(workListLayer, false); return(workListLayer); } } }
protected async override void OnClick() { await QueuedTask.Run(() => { //Uri pluginUri = new Uri(@"D:\GisTech\TreasureHuntingDemo\TestData.json", UriKind.Absolute); Uri pluginUri = new Uri(@"D:\Esri Nederland\DevTeam - DevDay\2019\Demos\WhatsNew\ProSDK\TreasureHuntingDemo\TestData.json", UriKind.Absolute); PluginDatasourceConnectionPath pluginDataSource = new PluginDatasourceConnectionPath("TreasureHuntingProPlugin_Datasource", pluginUri); using (var pluginDataStore = new PluginDatastore(pluginDataSource)) { foreach (var tableName in pluginDataStore.GetTableNames()) { using (var table = pluginDataStore.OpenTable(tableName)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } } }); }
protected async override void OnClick() { if (MapView.Active?.Map == null) { MessageBox.Show("There is no active map"); return; } var catalog = Project.GetCatalogPane(); var items = catalog.SelectedItems; var ProDataSubItems = items.OfType <ProDataSubItem>(); foreach (var item in ProDataSubItems) { try { await QueuedTask.Run(() => { switch (item.SubItemType) { case ProDataSubItem.EnumSubItemType.DirType: break; case ProDataSubItem.EnumSubItemType.DataSet: // path is comprised for sql DB path followed by '|' and the table name var parts = item.Path.Split('|'); if (parts.Length != 3) { MessageBox.Show($@"Item path can't be parsed: {item.Path}"); break; } var sqlPath = parts[0]; var sqlConStr = parts[1]; var dataset = parts[2]; var conSql = new PluginDatasourceConnectionPath("ProSqlExpressPluginDatasource", new Uri(item.Path.Replace(";", "||"), UriKind.Absolute)); using (var pluginSql = new PluginDatastore(conSql)) { foreach (var tn in pluginSql.GetTableNames()) { if (tn.StartsWith($@"\{dataset}\")) { using (var table = pluginSql.OpenTable(tn)) { if (table is FeatureClass) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } else { //add as a standalone table StandaloneTableFactory.Instance.CreateStandaloneTable(table, MapView.Active.Map); } } } } } break; case ProDataSubItem.EnumSubItemType.SqlType: // path is comprised for sql DB path followed by '|' and the table name parts = item.Path.Split('|'); if (parts.Length < 2) { MessageBox.Show($@"Item path can't be parsed: {item.Path}"); break; } sqlPath = parts[0]; sqlConStr = parts[1]; var tableName = string.Empty; if (parts.Length == 3) { tableName = parts[2]; } conSql = new PluginDatasourceConnectionPath("ProSqlExpressPluginDatasource", new Uri(item.Path.Replace(";", "||"), UriKind.Absolute)); using (var pluginSql = new PluginDatastore(conSql)) { var tableNames = new List <string>(); if (string.IsNullOrEmpty(tableName)) { tableNames = new List <string>(pluginSql.GetTableNames()); } else { tableNames.Add(tableName); } foreach (var tn in tableNames) { System.Diagnostics.Debug.Write($"Open table: {tn}\r\n"); //open the table using (var table = pluginSql.OpenTable(tn)) { if (table is FeatureClass) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } else { //add as a standalone table StandaloneTableFactory.Instance.CreateStandaloneTable(table, MapView.Active.Map); } } } } break; } }); } catch (Exception ex) { MessageBox.Show($@"Unable to add to map: {ex.Message}"); } } }
public static async Task AddProDataSubItemsAsync(IEnumerable <ProDataSubItem> proDataSubItems, Map mapToAddTo, GroupLayer grpLyr = null, int lyrIdx = -1) { foreach (ProDataSubItem item in proDataSubItems) { try { await QueuedTask.Run(() => { switch (item.SubItemType) { case ProDataSubItem.EnumSubItemType.DirType: break; case ProDataSubItem.EnumSubItemType.DataSet: // path is comprised for sql DB path followed by '|' and the table name var parts = item.Path.Split('|'); if (parts.Length != 3) { MessageBox.Show($@"Item path can't be parsed: {item.Path}"); break; } var sqlPath = parts[0]; var sqlConStr = parts[1]; var dataset = parts[2]; var conSql = new PluginDatasourceConnectionPath("ProSqlExpressPluginDatasource", new Uri(item.Path.Replace(";", "||"), UriKind.Absolute)); using (var pluginSql = new PluginDatastore(conSql)) { foreach (var tn in pluginSql.GetTableNames()) { if (tn.StartsWith($@"\{dataset}\")) { using (var table = pluginSql.OpenTable(tn)) { if (table is FeatureClass fc) { if (grpLyr != null) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer(fc, grpLyr, lyrIdx); } else { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer(fc, mapToAddTo); } } else { //add as a standalone table StandaloneTableFactory.Instance.CreateStandaloneTable(table, mapToAddTo); } } } } } break; case ProDataSubItem.EnumSubItemType.SqlType: // path is comprised for sql DB path followed by '|' and the table name parts = item.Path.Split('|'); if (parts.Length < 2) { MessageBox.Show($@"Item path can't be parsed: {item.Path}"); break; } sqlPath = parts[0]; sqlConStr = parts[1]; var tableName = string.Empty; if (parts.Length == 3) { tableName = parts[2]; } conSql = new PluginDatasourceConnectionPath("ProSqlExpressPluginDatasource", new Uri(item.Path.Replace(";", "||"), UriKind.Absolute)); using (var pluginSql = new PluginDatastore(conSql)) { var tableNames = new List <string>(); if (string.IsNullOrEmpty(tableName)) { tableNames = new List <string>(pluginSql.GetTableNames()); } else { tableNames.Add(tableName); } foreach (var tn in tableNames) { System.Diagnostics.Debug.Write($"Open table: {tn}\r\n"); //open the table using (var table = pluginSql.OpenTable(tn)) { if (table is FeatureClass fc) { if (grpLyr != null) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer(fc, grpLyr, lyrIdx); } else { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer(fc, mapToAddTo); } } else { //add as a standalone table StandaloneTableFactory.Instance.CreateStandaloneTable(table, mapToAddTo); } } } } break; } }); } catch (Exception ex) { MessageBox.Show($@"Unable to add to map: {ex.Message}"); } } }
protected async override void OnClick() { var catalog = Project.GetCatalogPane(); var items = catalog.SelectedItems; var ProDataSubItems = items.OfType <ProDataSubItem>(); foreach (var item in ProDataSubItems) { try { await QueuedTask.Run(() => { switch (item.SubItemType) { case ProDataSubItem.EnumSubItemType.DirType: break; case ProDataSubItem.EnumSubItemType.GpxType: var conGpx = new PluginDatasourceConnectionPath("ProGpxPluginDatasource", new Uri(item.Path, UriKind.Absolute)); var groupLayer = LayerFactory.Instance.CreateGroupLayer(MapView.Active.Map, 0, Path.GetFileNameWithoutExtension(item.Path)); ArcGIS.Core.Geometry.Envelope zoomToEnv = null; using (var pluginGpx = new PluginDatastore(conGpx)) { System.Diagnostics.Debug.Write($"Table: {item.Path}\r\n"); // because this is a GPX file we have both line and point variations // we add them in a group layer foreach (var tn in pluginGpx.GetTableNames()) { using (var table = pluginGpx.OpenTable(tn)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, groupLayer); zoomToEnv = ((FeatureClass)table).GetExtent().Clone() as ArcGIS.Core.Geometry.Envelope; } } } if (zoomToEnv != null) { MapView.Active.ZoomToAsync(zoomToEnv); } break; case ProDataSubItem.EnumSubItemType.ImgDirType: case ProDataSubItem.EnumSubItemType.ImgType: var conJpg = new PluginDatasourceConnectionPath("ProJpgPluginDatasource", new Uri(item.Path, UriKind.Absolute)); using (var pluginJpg = new PluginDatastore(conJpg)) { System.Diagnostics.Debug.Write($"Table: {item.Path}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder foreach (var tn in pluginJpg.GetTableNames()) { using (var table = pluginJpg.OpenTable(tn)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } } break; } }); } catch (Exception ex) { MessageBox.Show($@"Unable to add to map: {ex.Message}"); } } }
protected async override void OnClick() { var catalog = Project.GetCatalogPane(); var items = catalog.SelectedItems; var ProDataSubItems = items.OfType <ProDataSubItem>(); foreach (var item in ProDataSubItems) { try { await QueuedTask.Run(() => { switch (item.SubItemType) { case ProDataSubItem.EnumSubItemType.DirType: break; case ProDataSubItem.EnumSubItemType.GpxType: var conGpx = new PluginDatasourceConnectionPath("ProGpxPluginDatasource", new Uri(item.Path, UriKind.Absolute)); using (var pluginGpx = new PluginDatastore(conGpx)) { System.Diagnostics.Debug.Write($"Table: {item.Path}\r\n"); foreach (var tn in pluginGpx.GetTableNames()) { using (var table = pluginGpx.OpenTable(tn)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } } break; case ProDataSubItem.EnumSubItemType.ImgDirType: case ProDataSubItem.EnumSubItemType.ImgType: var conJpg = new PluginDatasourceConnectionPath("ProJpgPluginDatasource", new Uri(item.Path, UriKind.Absolute)); using (var pluginJpg = new PluginDatastore(conJpg)) { System.Diagnostics.Debug.Write($"Table: {item.Path}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder foreach (var tn in pluginJpg.GetTableNames()) { using (var table = pluginJpg.OpenTable(tn)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } } break; case ProDataSubItem.EnumSubItemType.MdbType: // path is comprised for access DB path followed by table name var idxLast = item.Path.LastIndexOf(Path.DirectorySeparatorChar); var path = item.Path.Substring(0, idxLast); var tableName = item.Path.Substring(idxLast + 1); var conMdb = new PluginDatasourceConnectionPath("ProMdbPluginDatasource", new Uri(path, UriKind.Absolute)); using (var pluginMdb = new PluginDatastore(conMdb)) { System.Diagnostics.Debug.Write($"Table: {tableName}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder using (var table = pluginMdb.OpenTable(tableName)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } break; } }); } catch (Exception ex) { MessageBox.Show($@"Unable to add to map: {ex.Message}"); } } }
public static List <string> AddProDataSubItemsAsync(List <ProDataSubItem> proDataSubItems, Map mapToAddTo, ILayerContainerEdit grpLyr = null, int lyrIdx = -1) { List <string> result = new(); try { { foreach (var proDataSubItem in proDataSubItems) { switch (proDataSubItem.SubItemType) { case ProDataSubItem.EnumSubItemType.DirType: break; case ProDataSubItem.EnumSubItemType.DataSet: var children = proDataSubItem.GetChildren().OfType <ProDataSubItem>().ToList(); result.AddRange(AddProDataSubItemsAsync(children, mapToAddTo, grpLyr, lyrIdx)); break; case ProDataSubItem.EnumSubItemType.SqlType: // path is comprised for sql DB path followed by '|' and the table name var parts = proDataSubItem.Path.Split('|'); if (parts.Length < 2) { throw new Exception($@"proDataSubproDataSubItem path can't be parsed: {proDataSubItem.Path}"); } var sqlPath = parts[0]; var sqlConStr = parts[1]; var tableName = string.Empty; if (parts.Length == 3) { tableName = parts[2]; } var conSql = new PluginDatasourceConnectionPath("ProSqlExpressPluginDatasource", new Uri(proDataSubItem.Path.Replace(";", "||"), UriKind.Absolute)); using (var pluginSql = new PluginDatastore(conSql)) { var tableNames = new List <string>(); if (string.IsNullOrEmpty(tableName)) { tableNames = new List <string>(pluginSql.GetTableNames()); } else { tableNames.Add(tableName); } foreach (var tn in tableNames) { System.Diagnostics.Debug.Write($"Open table: {tn}\r\n"); //open the table using (var table = pluginSql.OpenTable(tn)) { if (table is FeatureClass fc) { if (grpLyr != null) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateLayer <FeatureLayer>(new FeatureLayerCreationParams(fc) { MapMemberIndex = lyrIdx }, grpLyr); } else { //Add as a layer to the active map or scene LayerFactory.Instance.CreateLayer <FeatureLayer>(new FeatureLayerCreationParams(fc), mapToAddTo); } } else { //add as a standalone table StandaloneTableFactory.Instance.CreateStandaloneTable(new StandaloneTableCreationParams(table), mapToAddTo); } } } } result.Add(proDataSubItem.Path); break; } } } } catch (Exception ex) { throw new Exception($@"Unable to add to map: {ex.Message}"); } return(result); }