Exemple #1
0
        public MapObjects2.ClassBreaksRenderer GetClassBreaksRender(MapObjects2.MapLayer layer, string renderFieldName, int breaksCount, Color startColor, Color endColor)
        {
            MapObjects2.ClassBreaksRenderer oClassBreakRender = new MapObjects2.ClassBreaksRendererClass();

            if (layer.shapeType == ShapeTypeConstants.moShapeTypePoint)
            {
                oClassBreakRender.SymbolType = SymbolTypeConstants.moPointSymbol;
            }
            else if (layer.shapeType == ShapeTypeConstants.moShapeTypeLine)
            {
                oClassBreakRender.SymbolType = SymbolTypeConstants.moLineSymbol;
            }
            else if (layer.shapeType == ShapeTypeConstants.moShapeTypePolygon)
            {
                oClassBreakRender.SymbolType = SymbolTypeConstants.moFillSymbol;
            }

            oClassBreakRender.Field      = renderFieldName;
            oClassBreakRender.BreakCount = (short)breaksCount;

            MapObjects2.Statistics oStatistic = layer.Records.CalculateStatistics(renderFieldName);
            double dInterval = (oStatistic.Max - oStatistic.Min) / breaksCount;

            for (short i = 0; i < breaksCount; i++)
            {
                oClassBreakRender.set_Break(i, oStatistic.Min + dInterval * i);
            }

            oClassBreakRender.RampColors((uint)Utilities.Converter.ConvertSystemtoIntegerColor(startColor), (uint)Utilities.Converter.ConvertSystemtoIntegerColor(endColor));

            return(oClassBreakRender);
        }
Exemple #2
0
        /// <summary>
        /// 将已设置好的样式添加到唯一值渲染中去
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="symbols"></param>
        public void SetSymbolsToValueRenderedLayer(MapObjects2.MapLayer layer, Dictionary <string, MapObjects2.Symbol> symbols)
        {
            if (layer.Renderer == null)
            {
                throw new Exception("the layer has not set a render.");
            }

            if (layer.Renderer is MapObjects2.ValueMapRenderer)
            {
                throw new Exception("the layer has a render,but not a valuerender.");
            }

            Dictionary <string, MapObjects2.Symbol> .KeyCollection oKeys = symbols.Keys;
            MapObjects2.ValueMapRenderer oValueRender = layer.Renderer as MapObjects2.ValueMapRenderer;
            int iValueIndex = -1;

            MapObjects2.Symbol oSymbol = null;

            foreach (string sKey in oKeys)
            {
                iValueIndex = this.GetValueIndexByRenderValue(oValueRender, sKey);

                if (iValueIndex != -1 && symbols.TryGetValue(sKey, out oSymbol))
                {
                    this.CopySymbolToAnother(oSymbol, oValueRender.get_Symbol((short)iValueIndex));
                }
            }
        }
Exemple #3
0
        public FeatureInformations GetIdentifyFeatureInfos(MapObjects2.Point mousePosition, AxMapObjects2.AxMap mapControl, MapProject.MapStruct mapInfosCollection)
        {
            FeatureInformations oFeatureInfos = null;

            foreach (ILayerStruct oLayerInfos in mapInfosCollection.Layers)
            {
                if (oLayerInfos.LayerType != (short)LayerTypeConstants.moMapLayer)
                {
                    continue;
                }

                MapUtil.MapOperation oMapOper  = new MapOperation();
                MapObjects2.MapLayer oMapLayer = oMapOper.GetLayerByName(mapControl, oLayerInfos.AliasName) as MapObjects2.MapLayer;

                if (oMapLayer.Visible == false)
                {
                    continue;
                }

                Recordset oSelectedRecords = oMapLayer.SearchShape(mousePosition, SearchMethodConstants.moAreaIntersect, "");

                if (oSelectedRecords.EOF)
                {
                    continue;
                }

                oSelectedRecords.MoveFirst();

                oFeatureInfos = new FeatureInformations();
                oFeatureInfos.CurrentLayerInfos = oLayerInfos;
                oFeatureInfos.Geometry          = oSelectedRecords.Fields.Item("shape").Value;

                TableDesc oTableDesc = oSelectedRecords.TableDesc;
                oFeatureInfos.FieldsAndValuesCollection = new Dictionary <string, string>();
                int    iFieldsCount = oTableDesc.FieldCount;
                string sFieldName   = "";
                string sValue       = "";

                for (short i = 0; i < iFieldsCount; i++)
                {
                    sFieldName = oTableDesc.get_FieldName(i);
                    sValue     = oSelectedRecords.Fields.Item(sFieldName).ValueAsString;
                    oFeatureInfos.FieldsAndValuesCollection.Add(sFieldName, sValue);
                }

                break;
            }

            return(oFeatureInfos);
        }
Exemple #4
0
        /// <summary>
        /// 给图层设置唯一值渲染
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="renderFieldName"></param>
        public MapObjects2.ValueMapRenderer GetUniqueValueRender(MapObjects2.MapLayer layer, string renderFieldName)
        {
            MapObjects2.ValueMapRenderer oValueMapRender = new MapObjects2.ValueMapRendererClass();
            MapObjects2.Recordset        oRecords        = layer.Records;
            MapObjects2.Strings          oStrings        = new StringsClass();

            if (layer.shapeType == ShapeTypeConstants.moShapeTypePoint)
            {
                oValueMapRender.SymbolType = SymbolTypeConstants.moPointSymbol;
            }
            else if (layer.shapeType == ShapeTypeConstants.moShapeTypeLine)
            {
                oValueMapRender.SymbolType = SymbolTypeConstants.moLineSymbol;
            }
            else if (layer.shapeType == ShapeTypeConstants.moShapeTypePolygon)
            {
                oValueMapRender.SymbolType = SymbolTypeConstants.moFillSymbol;
            }

            oValueMapRender.Field = renderFieldName;
            oStrings.Unique       = true;
            oRecords.MoveFirst();

            while (!oRecords.EOF)
            {
                oStrings.Add(oRecords.Fields.Item(renderFieldName).ValueAsString);

                oRecords.MoveNext();
            }

            oValueMapRender.ValueCount = oStrings.Count;
            for (short i = 0; i < oStrings.Count; i++)
            {
                oValueMapRender.set_Value(i, oStrings.Item(i));
            }

            return(oValueMapRender);
        }