private static void SetVisibilitySessionRaster3DProperties(IRasterLayer rasterLayer, IObjectFactory objFactory, IFunctionalSurface surface, bool isDrapperyLayer = false) { var properties3D = (I3DProperties3)objFactory.Create("esrianalyst3d.Raster3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; if (!isDrapperyLayer) { properties3D.OffsetExpressionString = "2"; properties3D.DepthPriorityValue = 1; } else { properties3D.DepthPriorityValue = 9; } properties3D.ZFactor = _zFactor; properties3D.RenderVisibility = esriRenderVisibility.esriRenderAlways; properties3D.RenderMode = esriRenderMode.esriRenderCache; properties3D.TextureDownsamplingFactor = 0.7; properties3D.AlphaThreshold = 0.1; properties3D.RenderRefreshRate = 0.75; properties3D.Illuminate = true; ILayerExtensions layerExtensions = (ILayerExtensions)rasterLayer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(rasterLayer); }
public static void DisableLighting(IGraphicsContainer3D graphicsContainer3D) { I3DProperties properties3D = new Basic3DPropertiesClass(); properties3D.Illuminate = false; ILayerExtensions layerExtensions = graphicsContainer3D as ILayerExtensions; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(graphicsContainer3D); }
private static void SetFeatures3DProperties(IFeatureLayer layer, IObjectFactory objFactory) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Feature3DProperties"); properties3D.ZFactor = 7; properties3D.OffsetExpressionString = "200"; ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
private static void SetSurface3DProperties(ILayer layer, IObjectFactory objFactory, IFunctionalSurface surface) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Raster3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; properties3D.ZFactor = 7; ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
private static void SetHightFeatures3DProperties(IFeatureLayer layer, IObjectFactory objFactory) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Feature3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseShape; properties3D.ZFactor = _zFactor; properties3D.OffsetExpressionString = "3"; ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
private static void SetLine3DProperties(IFeatureLayer layer, IObjectFactory objFactory, IFunctionalSurface surface) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Feature3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; properties3D.ZFactor = 7; properties3D.OffsetExpressionString = "200"; ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
private static void SetFeatures3DProperties(IFeatureLayer layer, IObjectFactory objFactory, IFunctionalSurface surface, double height = double.NaN) { var properties3D = (I3DProperties)objFactory.Create("esrianalyst3d.Feature3DProperties"); properties3D.BaseOption = esriBaseOption.esriBaseSurface; properties3D.BaseSurface = surface; properties3D.ZFactor = _zFactor; properties3D.OffsetExpressionString = (height == double.NaN) ? "3" : height.ToString(); ILayerExtensions layerExtensions = (ILayerExtensions)layer; layerExtensions.AddExtension(properties3D); properties3D.Apply3DProperties(layer); }
public void AddDrapeLayerToGlobeElevationSurface(IGlobeDisplay globeDisplay, ILayer layer, System.String elevationRasterFilePath) { ChangeProp(layer); IGlobeDisplayLayers globeDisplayLayers = (IGlobeDisplayLayers)globeDisplay; // Explicit cast IFeatureLayer pFeatureLayer = (IFeatureLayer)layer; pFeatureLayer.Cached = true; // Create elevation raster layer IRasterLayer elevationRasterLayer = new RasterLayer(); elevationRasterLayer.CreateFromFilePath(elevationRasterFilePath); // Create and add the GlobeLayerProperties extension with the Type set to ElevationData IGlobeLayerProperties globeLayerProperties = new GlobeLayerProperties(); globeLayerProperties.Type = esriGlobeDataType.esriGlobeDataElevation; ILayerExtensions layerExtension = (ILayerExtensions)elevationRasterLayer; // Explicit cast layerExtension.AddExtension(globeLayerProperties); // Set the base option for layer to be esriGlobeLayerBaseLayer and its base layer to be ElevationLayer IGlobeLayerProperties drapeLayerGlobeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer); IGlobeHeightProperties drapeLayerGlobeHeightProperties = drapeLayerGlobeLayerProperties.HeightProperties; // drapeLayerGlobeHeightProperties.BaseLayer = elevationRasterLayer; drapeLayerGlobeHeightProperties.BaseOption = esriGlobeLayerBaseOption.esriGlobeLayerBaseLayer; drapeLayerGlobeHeightProperties.ElevationExpressionString = "[Elevation] * 1000"; // drapeLayerGlobeHeightProperties.ExtrusionType = ESRI.ArcGIS.Analyst3D.esriExtrusionType.esriExtrusionBase; //drapeLayerGlobeHeightProperties.ExtrusionExpressionString = "Elevation * 1000"; // Apply the height properties of the layer globeDisplayLayers.ApplyHeightProperties(layer); drapeLayerGlobeHeightProperties.Apply(m_Globe, layer); // globeDisplay.RefreshViewers(); globeDisplayLayers.RefreshLayer(layer); IActiveView pacv = (IActiveView)m_Globe; pacv.PartialRefresh(esriViewDrawPhase.esriViewGeography, pFeatureLayer, null); }
public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message) { try { IGPUtilities3 gpUtilities3 = new GPUtilitiesClass(); if (TrackCancel == null) { TrackCancel = new CancelTrackerClass(); } IGPParameter inputSourceLayerParameter = paramvalues.get_Element(in_sourcelayerNumber) as IGPParameter; IGPValue inputSourceLayerGPValue = gpUtilities3.UnpackGPValue(inputSourceLayerParameter) as IGPValue; IGPParameter inputTargetLayerParameter = paramvalues.get_Element(in_targetlayerNumber) as IGPParameter; IGPValue inputTargetLayerGPValue = gpUtilities3.UnpackGPValue(inputTargetLayerParameter) as IGPValue; ILayer sourceLayer = gpUtilities3.DecodeLayer(inputSourceLayerGPValue); ILayer targetLayer = gpUtilities3.DecodeLayer(inputTargetLayerGPValue); ILayerExtensions sourceLayerExtensions = sourceLayer as ILayerExtensions; if (sourceLayerExtensions == null) { message.AddWarning(resourceManager.GetString("GPTools_GPCopyLayerExtension_source_noext_support")); return; } ILayerExtensions targetLayerExtensions = targetLayer as ILayerExtensions; if (targetLayerExtensions == null) { message.AddWarning(resourceManager.GetString("GPTools_GPCopyLayerExtension_target_noext_support")); return; } // test if the feature classes already exists, // if they do and the environments settings are such that an overwrite is not allowed we need to abort at this point IGeoProcessorSettings gpSettings = (IGeoProcessorSettings)envMgr; if (gpSettings.OverwriteOutput == true) { } else { if (gpUtilities3.Exists(inputTargetLayerGPValue) == true) { message.AddError(120003, String.Format(resourceManager.GetString("GPTools_GPCopyLayerExtension_targetlayeralreadyexists"), inputTargetLayerGPValue.GetAsText())); return; } } for (int targetExtensionIndex = 0; targetExtensionIndex < targetLayerExtensions.ExtensionCount; targetExtensionIndex++) { targetLayerExtensions.RemoveExtension(targetExtensionIndex); } for (int sourceExtensionIndex = 0; sourceExtensionIndex < sourceLayerExtensions.ExtensionCount; sourceExtensionIndex++) { targetLayerExtensions.AddExtension(sourceLayerExtensions.get_Extension(sourceExtensionIndex)); } } catch (Exception ex) { message.AddError(120004, ex.Message); } }
/// <summary> /// this function takes a table and creates a shapefile (XY events) layer /// that is then added to the map /// </summary> /// <param name="pMxDoc">the map doc</param> /// <param name="sWorkspacePath">where to put the shapefile that is generated from the xy events / and where the dbf lives</param> /// <param name="sTableName">the name of the dbf to open</param> /// <param name="pSpatRef">the spatial ref for the prj file for the shapefile</param>\ /// <changelog> /// /// comments created. /// /// </changelog> public void addXYEvents(IMxDocument pMxDoc, string sWorkspacePath, string sTableName, ISpatialReference pSpatRef, string xField, string yField, string zField) { IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWSF.OpenFromFile(sWorkspacePath, 0); ITable pTable = (ITable)pFeatureWorkspace.OpenTable(sTableName); if (pTable == null) { MessageBox.Show("The table was not found"); return; } // Create a new standalone table and add it // to the collection of the focus map IStandaloneTable pStTab = new StandaloneTableClass(); pStTab.Table = (ITable)pTable; //sortTable(ref pTable); // Get the table name object IDataset pDataSet = (IDataset)pStTab; IName pTableName = pDataSet.FullName; // Specify the X and Y fields IXYEvent2FieldsProperties pXYEvent2FieldsProperties = new XYEvent2FieldsPropertiesClass(); pXYEvent2FieldsProperties.XFieldName = xField; pXYEvent2FieldsProperties.YFieldName = yField; pXYEvent2FieldsProperties.ZFieldName = zField; // Create the XY name object and set it's properties IXYEventSourceName pXYEventSourceName = new XYEventSourceNameClass(); pXYEventSourceName.EventProperties = pXYEvent2FieldsProperties; if (pSpatRef != null) { pXYEventSourceName.SpatialReference = pSpatRef; } pXYEventSourceName.EventTableName = pTableName; IName pXYName = (IName)pXYEventSourceName; IXYEventSource pXYEventSource = (IXYEventSource)pXYName.Open(); // Create a new Map Layer IFeatureLayer pFLayer = new FeatureLayerClass(); pFLayer.FeatureClass = (IFeatureClass)pXYEventSource; pFLayer.Name = sTableName; //Add the layer extension (this is done so that when you edit //the layer's Source properties and click the Set Data Source //button, the Add XY Events Dialog appears) XYDataSourcePageExtension pRESPageExt = new XYDataSourcePageExtension(); ILayerExtensions pLayerExt = (ILayerExtensions)pFLayer; pLayerExt.AddExtension(pRESPageExt); //Get the FcName from the featureclass IFeatureClass pFc = pFLayer.FeatureClass; pDataSet = (IDataset)pFc; IFeatureClassName pINFeatureClassName = (IFeatureClassName)pDataSet.FullName; IDatasetName pInDsName = (IDatasetName)pINFeatureClassName; //Get the selection set IFeatureSelection pFSel = (IFeatureSelection)pFLayer; ISelectionSet pSelSet = (ISelectionSet)pFSel.SelectionSet; //Define the output feature class name IFeatureClassName pFeatureClassName = new FeatureClassNameClass(); IDatasetName pOutDatasetName = (IDatasetName)pFeatureClassName; //string sDSName = ensureDataName(pDataSet.Name, sWorkspacePath); string sDSName = pDataSet.Name; // +DateTime.UtcNow.DayOfYear + DateTime.UtcNow.Hour + DateTime.UtcNow.Minute + DateTime.UtcNow.Second; pOutDatasetName.Name = sDSName; IWorkspaceName pWorkspaceName = new WorkspaceNameClass(); pWorkspaceName.PathName = sWorkspacePath; pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapeFileWorkspaceFactory"; pOutDatasetName.WorkspaceName = pWorkspaceName; pFeatureClassName.FeatureType = esriFeatureType.esriFTSimple; pFeatureClassName.ShapeType = esriGeometryType.esriGeometryPoint; pFeatureClassName.ShapeFieldName = "Shape"; //Export IExportOperation pExportOp = new ExportOperationClass(); pExportOp.ExportFeatureClass(pInDsName, null, null, null, pOutDatasetName as IFeatureClassName, 0); IFeatureClass pClass = (IFeatureClass)pFeatureWorkspace.OpenFeatureClass(sDSName); IFeatureLayer pLayer = new FeatureLayerClass(); pLayer.FeatureClass = pClass; pLayer.Name = sDSName;//pClass.AliasName; pMxDoc.AddLayer(pLayer); pMxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null); }
/// <summary> /// The add XY event layer. /// </summary> /// <param name="table"> /// The table. /// </param> /// <param name="query"> /// The query. /// </param> /// <param name="tweetShow"> /// The tweet show. /// </param> public static void AddXyEventLayer(ITable table, string query, bool tweetShow = true) { var mxdoc = ArcMap.Application.Document as IMxDocument; if (mxdoc != null) { var map = mxdoc.FocusMap; // Get the table named XYSample.txt var stTableCollection = map as IStandaloneTableCollection; // Get the table name object var dataset = table as IDataset; var tableName = dataset.FullName; // Specify the X and Y fields var xyEvent2FieldsProperties = new XYEvent2FieldsProperties() as IXYEvent2FieldsProperties; if (xyEvent2FieldsProperties != null) { xyEvent2FieldsProperties.XFieldName = "x"; xyEvent2FieldsProperties.YFieldName = "y"; xyEvent2FieldsProperties.ZFieldName = string.Empty; // Specify the projection var spatialReferenceFactory = new SpatialReferenceEnvironment() as ISpatialReferenceFactory; var projectedCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem( (int)esriSRGeoCSType.esriSRGeoCS_WGS1984); // Create the XY name object as set it's properties var xyEventSourceName = new XYEventSourceName() as IXYEventSourceName; xyEventSourceName.EventProperties = xyEvent2FieldsProperties; xyEventSourceName.SpatialReference = projectedCoordinateSystem; xyEventSourceName.EventTableName = tableName; IName xyName = xyEventSourceName as IName; IXYEventSource xyEventSource = xyName.Open() as IXYEventSource; // Create a new Map Layer IFeatureLayer featureLayer = new FeatureLayer() as IFeatureLayer; featureLayer.FeatureClass = xyEventSource as IFeatureClass; featureLayer.Name = query; // Add the layer extension (this is done so that when you edit // the layer's Source properties and click the Set Data Source // button, the Add XY Events Dialog appears) ILayerExtensions layerExtensions = featureLayer as ILayerExtensions; XYDataSourcePageExtension resPageExtension = new XYDataSourcePageExtension(); layerExtensions.AddExtension(resPageExtension); IGeoFeatureLayer geoLayer = (IGeoFeatureLayer)featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer)geoLayer.Renderer; var randomNumber = NumberRandom.Next(0, Colors.Count - 1); var color = Colors[randomNumber]; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Blue = color.B; rgbColor.Red = color.R; rgbColor.Green = color.G; IMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass(); markerSymbol.Color = rgbColor; markerSymbol.Size = 5; simpleRenderer.Symbol = (ISymbol)markerSymbol; try { map.AddLayer(featureLayer); } catch (Exception error) { Console.WriteLine(error.Message); } } } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { if (m_hookHelper != null) { try { IApplication appArcMap = (IApplication)m_hookHelper.Hook; IMxDocument doc = (IMxDocument)appArcMap.Document; if (doc.SelectedLayer != null) { ILayer layer = doc.SelectedLayer; IPropertySet propertySet = null; bool newPropertySet = false; ILayerExtensions layerExtensions = (ILayerExtensions)layer; Trace.WriteLine(layerExtensions.ExtensionCount.ToString()); List <IPropertySet> psets = layer.FindExtensionPropertySet("layerextension", "umbriel"); if (!LayerExtHelper.UmbrielPropertySetExists(layerExtensions)) { propertySet = LayerExtHelper.CreateUmbrielPropertySet(); newPropertySet = true; } else { propertySet = LayerExtHelper.GetUmbrielPropertySet(layerExtensions); } if (propertySet != null) { if (this.propertySetForm == null) { this.propertySetForm = new CustomLayerPropertiesForm(propertySet); } DialogResult res = this.propertySetForm.ShowDialog(); if (res == DialogResult.OK) { if (this.propertySetForm.PropertySet != null) { LayerExtHelper.RemovePropertySet(layerExtensions); layerExtensions.AddExtension(this.propertySetForm.PropertySet); } } this.propertySetForm.Dispose(); this.propertySetForm = null; } } else { MessageBox.Show("No layer highlighted in the table of contents.", "Ooops.", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Umbriel Custom Layer Properties Error", System.Windows.Forms.MessageBoxButtons.OK); } } else if (m_sceneHookHelper != null) { throw new NotImplementedException(); } else if (m_globeHookHelper != null) { throw new NotImplementedException(); } }