How ArcEngine loads raster data in SDE

Source: Internet
Author: User

When loading vector data, you can directly go to the IFeatureWorkspace interface, but you must go to the IRasterWorkspaceEx interface when loading the raster data. As shown in the following figure. You can double-click it to add it to Globe.


The Code is as follows:

Public partial class SDEDataViewer: DevComponents. dotNetBar. office2007Form {# region private variable private IWorkspace sdeWorkSpace; // sde work control private IGlobeControl globecontrol; private string selectedVectorName; // vector private string selectedRasterName to be added; # endregion # region constructor public SDEDataViewer (IGlobeControl m_globecontrol, IWorkspace workspace) {this. sdeWorkSpace = workspace; this. globecontrol = m_g Lobecontrol; InitializeComponent () ;}# endregion # region load private void SDEDataViewer_Load (object sender, EventArgs e) {IAoInitialize initAO = new AoInitializeClass (); initAO. initialize (esriLicenseProductCode. esriLicenseProductCodeEngineGeoDB); loadData () ;}// obtain all data private void loadData () {listView_vector.GridLines = true; // whether the table displays the gridline listView_vector.FullRowSelect = true; // select whether the entire row of listView is selected _ Vector. view = View. details; // set the display mode to true; // whether to automatically display the scroll bar listView_vector.MultiSelect = false; // whether to select multiple rows listView_raster.GridLines = true; rows = true; listView_raster.View = View. details; listView_raster.Scrollable = true; listView_raster.MultiSelect = false; // Add the header (column) listView_vector.Columns.Add ("element name", 150, HorizontalAlignment. center); listVie W_vector.Columns.Add ("element type", 100, HorizontalAlignment. center); listView_raster.Columns.Add ("Data name", 150, HorizontalAlignment. center); listView_raster.Columns.Add ("Data Type", 100, HorizontalAlignment. center); try {IEnumDataset enumDataset = sdeWorkSpace. get_Datasets (esriDatasetType. esriDTAny); IDataset dataset = null; while (dataset = enumDataset. next ())! = Null) {if (dataset. type = esriDatasetType. esriDTFeatureClass) {ListViewItem item = new ListViewItem (); item. subItems. clear (); item. subItems [0]. text = dataset. name; string strFeatureType = GetFeatureType (dataset. name); item. subItems. add (strFeatureType); listView_vector.Items.Add (item);} else if (dataset. type = esriDatasetType. esriDTRasterDataset) {ListViewItem item = new ListViewItem (); item. subItems. clear (); item. subItems [0]. text = dataset. name; item. subItems. add ("Grid dataset"); listView_raster.Items.Add (item) ;}} catch (System. exception ex) {MessageBox. show (ex. message) ;}}// obtain the element type private string GetFeatureType (string pDataSetName) {string featureType = ""; IFeatureWorkspace pFeatureWS = sdeWorkSpace as IFeatureWorkspace; IFeatureClass featureClass = feature. openFeatureClass (pDataSetName); switch (featureClass. shapeType) {case esriGeometryType. esriGeometryPoint: featureType = "point element"; break; case esriGeometryType. esriGeometryPolyline: featureType = "line element"; break; case esriGeometryType. esriGeometryPolygon: featureType = "surface element"; break; default: break;} // System. runtime. interopServices. marshal. releaseComObject (pFeatureWS); System. runtime. interopServices. marshal. releaseComObject (featureClass); return featureType;} # endregion # region add data // Add vector private void encode (object sender, MouseEventArgs e) {IFeatureClass featureClass = (sdeWorkSpace as IFeatureWorkspace ). openFeatureClass (selectedVectorName); IFeatureLayer featureLayer = new FeatureLayerClass () {FeatureClass = featureClass, Name = featureClass. aliasName}; VectorHelper_FeatureOpt VectorAdderHelper = new VectorHelper_FeatureOpt (globecontrol, featureLayer); VectorAdderHelper. showDialog (); this. close (); // System. runtime. interopServices. marshal. releaseComObject (featureClass); // System. runtime. interopServices. marshal. releaseComObject (featureLayer);} // Add the object sender, MouseEventArgs e) {IRasterWorkspaceEx rasterWSEx = sdeWorkSpace as parameters; IRasterDataset rasterDataset = rasterWSEx. openRasterDataset (selectedRasterName); IRasterLayer rasterLayer = new RasterLayerClass (); rasterLayer. createFromDataset (rasterDataset); RasterHelper_LayerType rasterAdderHelper = new RasterHelper_LayerType (globecontrol, rasterLayer); rasterAdderHelper. showDialog (); this. close (); // System. runtime. interopServices. marshal. releaseComObject (rasterLayer);} // obtain selected vector private void evaluate (object sender, EventArgs e) {ListViewItem item = new ListViewItem (); item = listView_vector.SelectedItems [0]; string featureClassName_temp = item. subItems [0]. toString (); int lastIndex_left = equals ("{"); int lastIndex_right = equals ("}"); selectedVectorName = equals (lastIndex_left + 1, lastIndex_right-lastIndex_left-1 );} // obtain selected raster private void listView_raster_SelectedIndexChanged (object sender, EventArgs e) {ListViewItem item = new ListViewItem (); item = listView_raster.SelectedItems [0]; string rasterName_temp = item. subItems [0]. toString (); int lastIndex_left = equals ("{"); int lastIndex_right = equals ("}"); selectedRasterName = equals (lastIndex_left + 1, lastIndex_right-lastIndex_left-1 );} # endregion}
You are welcome to leave a message.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.