Ejemplo n.º 1
0
        private IGroupLayer AddReferenceSurfaceGroupLayer(Surface surf)
        {
            IGroupLayer pInputsGrpLyr  = AddInputsGroupLayer();
            IGroupLayer pRefSurfGrpLyr = ArcMapUtilities.GetGroupLayer(RefSurfGroupLayer, pInputsGrpLyr);

            return(ArcMapUtilities.GetGroupLayer(surf.Name, pRefSurfGrpLyr));
        }
Ejemplo n.º 2
0
        private IGroupLayer AddErrorSurfacesGroupLayer(DEMSurvey dem)
        {
            IGroupLayer pSurveyGrpLyr = AddSurveyGroupLayer(dem);
            IGroupLayer pErrGrpLyr    = ArcMapUtilities.GetGroupLayer(ErrorSurfacesGroupLayer, pSurveyGrpLyr);

            return(pErrGrpLyr);
        }
Ejemplo n.º 3
0
        private IGroupLayer AddSurveyGroupLayer(DEMSurvey dem)
        {
            IGroupLayer pInputsGrpLyr  = AddInputsGroupLayer();
            IGroupLayer pSurveysGrpLyr = ArcMapUtilities.GetGroupLayer(SurveysGroupLayer, pInputsGrpLyr);

            return(ArcMapUtilities.GetGroupLayer(dem.Name, pSurveysGrpLyr));
        }
Ejemplo n.º 4
0
        private IGroupLayer AddReferenceErrorSurfacesGroupLayer(Surface surf)
        {
            IGroupLayer pSurveyGrpLyr = AddReferenceSurfaceGroupLayer(surf);
            IGroupLayer pErrGrpLyr    = ArcMapUtilities.GetGroupLayer(ErrorSurfacesGroupLayer, pSurveyGrpLyr);

            return(pErrGrpLyr);
        }
Ejemplo n.º 5
0
        public void AddMask(GCDCore.Project.Masks.AttributeFieldMask mask)
        {
            IGroupLayer pProjLyr      = AddProjectGroupLayer();
            IGroupLayer pGrpLayer     = ArcMapUtilities.GetGroupLayer(MasksGroupLayer, pProjLyr);
            short       dTransparency = GCDCore.Properties.Settings.Default.TransparencyAssociatedLayers ? GCDCore.Properties.Settings.Default.AutoTransparencyValue : (short)-1;

            IFeatureRenderer pRenderer   = null;
            string           queryFilter = string.Empty;
            string           labelField  = string.Empty;

            if (mask is GCDCore.Project.Masks.RegularMask)
            {
                GCDCore.Project.Masks.RegularMask rMask = mask as GCDCore.Project.Masks.RegularMask;

                pRenderer = VectorSymbolization.GetRegularMaskRenderer(rMask) as IFeatureRenderer;

                // Create a definition query if some features are not included

                if (rMask._Items.Any(x => !x.Include))
                {
                    queryFilter = string.Format("\"{0}\" IN ('{1}')", mask._Field, string.Join("','", rMask._Items.Where(x => x.Include).Select(y => y.FieldValue)));
                }
            }
            else if (mask is GCDCore.Project.Masks.DirectionalMask)
            {
                GCDCore.Project.Masks.DirectionalMask dirMask = mask as GCDCore.Project.Masks.DirectionalMask;
                // Directional mask. Black outline with labels
                pRenderer = VectorSymbolization.GetDirectionalMaskRenderer(dirMask) as IFeatureRenderer;

                labelField = string.IsNullOrEmpty(dirMask.LabelField) ? dirMask._Field : dirMask.LabelField;
            }

            VectorSymbolization.AddToMapVector(mask.Vector.GISFileInfo, mask.Name, pGrpLayer, mask._Field, pRenderer, queryFilter, labelField, dTransparency);
        }
Ejemplo n.º 6
0
        private IGroupLayer AddAnalysesGroupLayer()
        {
            IGroupLayer pProjLyr    = AddProjectGroupLayer();
            IGroupLayer pAnalGrpLyr = ArcMapUtilities.GetGroupLayer(AnalysesGroupLayer, pProjLyr);

            return(pAnalGrpLyr);
        }
Ejemplo n.º 7
0
        public void AddProfileRoute(GCDCore.Project.ProfileRoutes.ProfileRoute route)
        {
            IGroupLayer pProjLyr  = AddProjectGroupLayer();
            IGroupLayer pGrpLayer = ArcMapUtilities.GetGroupLayer(ProfileRouteGroupLayer, pProjLyr);

            IFeatureRenderer pRenderer = null;// VectorSymbolization.GetAOIRenderer(mask) as IFeatureRenderer;

            VectorSymbolization.AddToMapVector(route.Vector.GISFileInfo, route.Name, pGrpLayer, string.Empty, pRenderer, string.Empty, string.Empty);
        }
Ejemplo n.º 8
0
        public void AddAOI(GCDCore.Project.Masks.AOIMask mask)
        {
            IGroupLayer pProjLyr  = AddProjectGroupLayer();
            IGroupLayer pGrpLayer = ArcMapUtilities.GetGroupLayer(MasksGroupLayer, pProjLyr);

            IFeatureRenderer pRenderer = VectorSymbolization.GetAOIRenderer(mask) as IFeatureRenderer;

            VectorSymbolization.AddToMapVector(mask.Vector.GISFileInfo, mask.Name, pGrpLayer, string.Empty, pRenderer, string.Empty, string.Empty);
        }
Ejemplo n.º 9
0
        public static IRasterRenderer CreateESRIDefinedContinuousRenderer(GCDConsoleLib.Raster gRaster, int iClassCount, string sColorRampName, bool bInvert = false)
        {
            try
            {
                gRaster.ComputeStatistics();
                decimal maxValue        = gRaster.GetStatistics()["max"];
                int     iRound          = GetMagnitude(maxValue);
                double  maxValueRounded = Math.Round((double)maxValue, Math.Abs(iRound));

                RasterStretchColorRampRenderer stretchRenderer = new RasterStretchColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;
                IRasterDataset  rasterDataset  = ArcMapUtilities.GetRasterDataset(gRaster);
                IRaster         raster         = rasterDataset.CreateDefaultRaster();
                rasterRenderer.Raster = raster;
                IColorRamp               pColorRamp       = null;
                IStyleGalleryItem        pStyleItem       = GetESRIStyleColorRamp(out pColorRamp, sColorRampName);
                IRasterRendererColorRamp pRenderColorRamp = (IRasterRendererColorRamp)rasterRenderer;
                pRenderColorRamp.ColorScheme = pStyleItem.Name;
                IRasterStretchMinMax pStretchInfo = (IRasterStretchMinMax)stretchRenderer;
                pStretchInfo.CustomStretchMin       = 0;
                pStretchInfo.CustomStretchMax       = maxValueRounded;
                pStretchInfo.UseCustomStretchMinMax = true;
                stretchRenderer.LabelHigh           = maxValueRounded.ToString();
                stretchRenderer.LabelLow            = "0.0";
                if (bInvert)
                {
                    IRasterStretch2 pStretch = (IRasterStretch2)stretchRenderer;
                    pStretch.Invert = true;
                }

                rasterRenderer.Update();
                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Ejemplo n.º 10
0
        private void LoadArcMapLayers()
        {
            lstLayers.Items.Clear();

            for (int i = 0; i <= ArcMap.Document.FocusMap.LayerCount - 1; i++)
            {
                ILayer pLayer = ArcMap.Document.FocusMap.Layer[i];
                if (!(pLayer is ICompositeLayer))
                {
                    ArcMapBrowse.BrowseGISTypes eBrowseType = GetBrowseType(ref pLayer);
                    if (BrowseType == ArcMapBrowse.BrowseGISTypes.Any || eBrowseType == BrowseType)
                    {
                        lstLayers.Items.Add(new LayerInfo(pLayer.Name, ArcMapUtilities.GetPathFromLayer(pLayer), eBrowseType));
                    }
                }
            }

            if (lstLayers.Items.Count == 1)
            {
                lstLayers.SelectedIndex = 0;
            }
        }
Ejemplo n.º 11
0
        public static IRasterRenderer CreateContinuousRenderer(Raster gRaster, IColorRamp pColorRamp, bool bInvert = false)
        {
            try
            {
                gRaster.ComputeStatistics();
                Dictionary <string, decimal> stats = gRaster.GetStatistics();
                double rMin = (double)stats["min"];
                double rMax = (double)stats["max"];

                RasterStretchColorRampRenderer stretchRenderer = new RasterStretchColorRampRenderer();
                IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;
                IRasterDataset  rasterDataset  = ArcMapUtilities.GetRasterDataset(gRaster);
                IRaster         raster         = rasterDataset.CreateDefaultRaster();
                rasterRenderer.Raster = raster;

                IRasterRendererColorRamp pRenderColorRamp = (IRasterRendererColorRamp)rasterRenderer;
                pRenderColorRamp.ColorRamp = pColorRamp;
                int iRound = GetMagnitude(rMin);
                stretchRenderer.LabelHigh = Math.Round(rMax, Math.Abs(iRound)).ToString();
                stretchRenderer.LabelLow  = Math.Round(rMin, Math.Abs(iRound)).ToString();

                if (bInvert)
                {
                    IRasterStretch2 pStretch = (IRasterStretch2)stretchRenderer;
                    pStretch.Invert = true;
                }

                rasterRenderer.Update();
                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Ejemplo n.º 12
0
        private IGroupLayer AddInputsGroupLayer()
        {
            IGroupLayer pProjectGrpLyr = AddProjectGroupLayer();

            return(ArcMapUtilities.GetGroupLayer(InputsGroupLayer, pProjectGrpLyr));
        }
Ejemplo n.º 13
0
 private IGroupLayer AddProjectGroupLayer()
 {
     return(ArcMapUtilities.GetGroupLayer(ProjectManager.Project.Name));
 }
Ejemplo n.º 14
0
        private static void AddRasterLayer(Raster gRaster, IRasterRenderer rasterRenderer, string sRasterName, IGroupLayer pGrpLyr, string sHeader = null, short fTransparency = -1, bool ExpandLegend = true)
        {
            if (pGrpLyr != null)
            {
                IRasterLayer pResultLayer = ArcMapUtilities.IsRasterLayerInGroupLayer(gRaster.GISFileInfo, pGrpLyr);
                if (pResultLayer is ILayer)
                {
                    return;
                }
            }

            IRasterLayer   rasterLayer = new RasterLayer();
            IRasterDataset pRDS        = ArcMapUtilities.GetRasterDataset(gRaster);

            rasterLayer.CreateFromDataset(pRDS);
            if (rasterRenderer != null)
            {
                rasterLayer.Renderer = rasterRenderer;
            }

            if (rasterLayer != null)
            {
                IMapLayers pMapLayers = (IMapLayers)ArcMap.Document.FocusMap;
                if (!string.IsNullOrEmpty(sRasterName))
                {
                    rasterLayer.Name = sRasterName;
                }

                if (!string.IsNullOrEmpty(sHeader))
                {
                    ESRI.ArcGIS.Carto.ILegendInfo pLegend = (ESRI.ArcGIS.Carto.ILegendInfo)rasterLayer;
                    pLegend.LegendGroup[0].Heading = sHeader;
                }

                if (fTransparency >= 0)
                {
                    ILayerEffects pLayerEffects = (ILayerEffects)rasterLayer;
                    pLayerEffects.Transparency = fTransparency;
                }

                if (pGrpLyr == null)
                {
                    pMapLayers.InsertLayer(rasterLayer, false, 0);
                }
                else
                {
                    pMapLayers.InsertLayerInGroup(pGrpLyr, rasterLayer, false, 0);
                }

                // Collapse or expand the legend in the ToC (e.g. Hillshade should be collapsed)
                ((ILegendGroup)((ILegendInfo)rasterLayer).LegendGroup[0]).Visible = ExpandLegend;
            }

            int refsLeft = 0;

            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pRDS);
            }while (refsLeft > 0);

            refsLeft = 0;
            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterLayer);
            }while (refsLeft > 0);
        }
Ejemplo n.º 15
0
        private IGroupLayer AddAssociatedSurfaceGroupLayer(DEMSurvey dem)
        {
            IGroupLayer pSurveyGrpLyr = AddSurveyGroupLayer(dem);

            return(ArcMapUtilities.GetGroupLayer(AssociatedSurfacesGroupLayer, pSurveyGrpLyr));
        }
Ejemplo n.º 16
0
        public static void AddToMapVector(FileInfo sSource, string sDisplayName, IGroupLayer pGrpLyr, string displayField, IFeatureRenderer pRenderer, string queryFilter, string labelField, short fTransparency = -1)
        {
            if (string.IsNullOrEmpty(sDisplayName))
            {
                throw new ArgumentNullException("Display Name", "Null or empty display Name");
            }

            IFeatureLayer pResultLayer = IsFeatureLayerInGroupLayer(sSource.FullName, pGrpLyr);


            IFeatureWorkspace pWS = (IFeatureWorkspace)ArcMapUtilities.GetWorkspace(sSource);
            IFeatureClass     pFC = pWS.OpenFeatureClass(Path.GetFileNameWithoutExtension(sSource.FullName));

            pResultLayer = new FeatureLayer();
            pResultLayer.FeatureClass = pFC;
            if (fTransparency >= 0)
            {
                ILayerEffects pLayerEffects = (ILayerEffects)pResultLayer;
                pLayerEffects.Transparency = fTransparency;
            }

            if (!string.IsNullOrEmpty(sDisplayName))
            {
                pResultLayer.Name = sDisplayName;
            }

            IMapLayers pMapLayers = (IMapLayers)ArcMap.Document.FocusMap;

            if (pGrpLyr == null)
            {
                pMapLayers.InsertLayer(pResultLayer, true, 0);
            }
            else
            {
                pMapLayers.InsertLayerInGroup(pGrpLyr, pResultLayer, true, 0);
            }

            if (pRenderer != null)
            {
                ((IGeoFeatureLayer)pResultLayer).Renderer = pRenderer;
            }

            if (!string.IsNullOrEmpty(labelField))
            {
                IGeoFeatureLayer pGFL = pResultLayer as IGeoFeatureLayer;

                // This first attempt seems to set the label field, but doesn't
                // cause the labeling to refresh and take effect
                //IDisplayString displayString = pGFL as IDisplayString;
                //IDisplayExpressionProperties properties = displayString.ExpressionProperties;
                //properties.Expression = string.Format("[{0}]", labelField);

                // This second attempt takes more effort but actually works
                // https://community.esri.com/thread/19005
                IAnnotateLayerPropertiesCollection labelPropsCollection = pGFL.AnnotationProperties;
                labelPropsCollection.Clear();

                //IBasicOverposterLayerProperties pBOLayerProps = new BasicOverposterLayerProperties();
                //pBOLayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon
                //pBOLayerProps.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape
                //pBOLayerProps.FeatureWeight = esriBasicOverposterWeight.esriNoWeight
                //pBOLayerProps.LabelWeight = esriBasicOverposterWeight.esriLowWeight

                //Dim tSym As ITextSymbol
                //Set tSym = New TextSymbol
                //Dim font As IFontDisp
                //Set font = tSym.font
                //font.Bold = False
                //font.size = 6
                //tSym.font = font

                ILabelEngineLayerProperties aLELayerProps = (ILabelEngineLayerProperties) new LabelEngineLayerProperties();
                aLELayerProps.Expression = string.Format("[{0}]", labelField);

                //Set aLELayerProps.Symbol = tSym
                //Set aLELayerProps.BasicOverposterLayerProperties = pBOLayerProps
                IAnnotateLayerProperties lProps = aLELayerProps as IAnnotateLayerProperties;
                lProps.Class = "Any Name";
                labelPropsCollection.Add(lProps);

                pGFL.DisplayAnnotation = true;
            }

            if (pRenderer is IUniqueValueRenderer)
            {
                // If you didn't use a color ramp that was predefined in a style,
                // you need to use "Custom" here, otherwise use the name of the color ramp you chose.
                ((IGeoFeatureLayer)pResultLayer).DisplayField = displayField;

                // This makes the layer properties symbology tab show the correct interface
                IUID pUID = new UIDClass();
                pUID.Value = "{683C994E-A17B-11D1-8816-080009EC732A}";
                ((IGeoFeatureLayer)pResultLayer).RendererPropertyPageClassID = pUID as UIDClass;
            }

            if (!string.IsNullOrEmpty(queryFilter))
            {
                ((IFeatureLayerDefinition)pResultLayer).DefinitionExpression = queryFilter;
            }

            int refsLeft = 0;

            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pFC);
            }while (refsLeft > 0);

            do
            {
                refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pResultLayer);
            }while (refsLeft > 0);

            ArcMap.Document.UpdateContents();
            ArcMap.Document.ActiveView.Refresh();
            ArcMap.Document.CurrentContentsView.Refresh(null);
        }