示例#1
0
 /// <summary>
 /// di tu ceng = eyemap
 /// </summary>
 private void InitializeEyeMap()
 {
     MapObjects2.DataConnection mapCon   = new MapObjects2.DataConnectionClass();
     MapObjects2.MapLayer       EyeLayer = null;
     try
     {
         mapCon.Database = Path.GetDirectoryName(Application.ExecutablePath) + "\\shaps\\";
         for (int i = 0; i < mapLayer.m_layers.Length; i++)
         {
             if (mapLayer.m_layers[i].typeName == "地图层")
             {
                 EyeLayer              = new MapObjects2.MapLayerClass();
                 EyeLayer.GeoDataset   = mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                 EyeLayer.Symbol.Color = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 EyeLayer.Symbol.Size  = 1;
                 if (EyeLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                 {
                     EyeLayer.Symbol.OutlineColor = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 }
                 mapEye.Layers.Add(EyeLayer);
                 mapEye.Refresh();
             }
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show("加载图层失败,请重新起动软件!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
         ExceptionHandler.Handle("加载图层失败,请重新起动软件!", ex);
     }
 }
示例#2
0
        public MapStruct LoadProjectByMapInfos(string projectFileName, AxMapObjects2.AxMap mapControl)
        {
            ProjectSerialization oProjectSerialization = new ProjectSerialization();
            MapStruct            oMapStruct            = oProjectSerialization.DeserializeProject(projectFileName);
            List <ILayerStruct>  oLayers = oMapStruct.Layers;

            MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass();

            foreach (ILayerStruct oLayer in oLayers)
            {
                if (oLayer is MapLayerInfoStruct)
                {
                    MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass();
                    oConn.Database = System.IO.Path.GetDirectoryName(oLayer.FileName);

                    if (oConn.Connect())
                    {
                        oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.DataSetName);

                        this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render);
                        this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol);

                        oMapLayer.Name    = oLayer.AliasName;
                        oMapLayer.Visible = oLayer.Visible;
                        oMapLayer.Tag     = string.Format("{0}-{1}", oLayer.MinLevel, oLayer.MaxLevel);
                        mapControl.Layers.Add(oMapLayer);
                        oConn.Disconnect();
                    }
                }
                else if (oLayer is ImageLayerInfoStruct)
                {
                    //not implement
                    //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass();
                    //oImageLayer.Name = oLayer.Name;
                }
            }

            MapObjects2.Rectangle oViewExtent = new MapObjects2.RectangleClass();

            oViewExtent.Left   = oMapStruct.BBox.MinX;
            oViewExtent.Top    = oMapStruct.BBox.MinY;
            oViewExtent.Right  = oMapStruct.BBox.MaxX;
            oViewExtent.Bottom = oMapStruct.BBox.MaxY;
            mapControl.Extent  = oViewExtent;
            //mapControl.CoordinateSystem = oMapStruct.CoordinateSystem;

            return(oMapStruct);
        }
示例#3
0
        public void LoadProjectByMapInfos(MapStruct mapInfos, AxMapObjects2.AxMap mapControl)
        {
            List <ILayerStruct> oLayers = mapInfos.Layers;

            MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass();

            oConn.Database = mapInfos.GeoDataSetPath;

            oConn.Connect();

            foreach (ILayerStruct oLayer in oLayers)
            {
                if (oLayer is MapLayerInfoStruct && oConn.Connected)
                {
                    MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass();
                    oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.Name);

                    this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render);
                    this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol);

                    mapControl.Layers.Add(oMapLayer);
                }
                else if (oLayer is ImageLayerInfoStruct)
                {
                    //not implement
                    //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass();
                    //oImageLayer.Name = oLayer.Name;
                }
            }

            if (oConn.Connected)
            {
                oConn.Disconnect();
            }

            mapControl.Extent.Top       = mapInfos.BBox.MinX;
            mapControl.Extent.Left      = mapInfos.BBox.MinY;
            mapControl.Extent.Bottom    = mapInfos.BBox.MaxX;
            mapControl.Extent.Right     = mapInfos.BBox.MaxY;
            mapControl.CoordinateSystem = mapInfos.CoordinateSystem;
        }
示例#4
0
        /// <summary>
        /// load layer from file, layer ->axMap1 ocx
        /// </summary>
        private void InitializeMainMap()
        {
            axMap1.Layers.Clear();
            axMap1.ScrollBars=false;
            MapObjects2.DataConnection mapCon=new MapObjects2.DataConnectionClass();
            try
            {
                mapCon.Database=Path.GetDirectoryName(Application.ExecutablePath)+"\\shaps\\";
                for(int m=0;m<3;m++)
                {
                    for(int i=0;i<mapLayer.m_layers.Length;i++)
                    {
                        MapObjects2.MapLayer layer;
                        layer = new MapObjects2.MapLayer();
                        layer.GeoDataset=mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                        switch (m)
                        {
                            case 0:
                                if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                                    continue;
                                break;
                            case 1:
                                if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypeLine)
                                    continue;
                                break;
                            case 2:
                                if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePoint)
                                    continue;
                                break;
                            default:
                                continue;
                        }
                        mapLayer.m_layers[i].layer=layer;
                        axMap1.Layers.Add(mapLayer.m_layers[i].layer);
                        mapLayer.m_layers[i].layer.Symbol.Style=(short)mapLayer.m_layers[i].dtSymbol;
                        mapLayer.m_layers[i].layer.Symbol.Color=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        mapLayer.m_layers[i].layer.Symbol.Size=(short)mapLayer.m_layers[i].dtSize;
                        if(mapLayer.m_layers[i].layer.shapeType==MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                            mapLayer.m_layers[i].layer.Symbol.OutlineColor=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                    }
                }

                zoomRect=axMap1.Extent;
                zoomRect.ScaleRectangle(SC);
                                //axMap1.CenterAt(118.6679,39.5009);
                axMap1.Extent=zoomRect;
                axMap1.Refresh();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("����ͼ��ʧ��,�����������!","����",MessageBoxButtons.OK,MessageBoxIcon.Error);
                ExceptionHandler.Handle("����ͼ��ʧ��,�����������!", ex );
            }
        }
示例#5
0
 /// <summary>
 /// di tu ceng = eyemap
 /// </summary>
 private void InitializeEyeMap()
 {
     MapObjects2.DataConnection mapCon=new MapObjects2.DataConnectionClass();
     MapObjects2.MapLayer EyeLayer=null;
     try
     {
         mapCon.Database=Path.GetDirectoryName(Application.ExecutablePath)+"\\shaps\\";
         for(int i=0;i<mapLayer.m_layers.Length;i++)
         {
             if(mapLayer.m_layers[i].typeName=="��ͼ��" || mapLayer.m_layers[i].typeName=="ȫ�Բ�")
             {
                 EyeLayer=new MapObjects2.MapLayerClass();
                 EyeLayer.GeoDataset=mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                 EyeLayer.Symbol.Color=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 EyeLayer.Symbol.Size=1;
                 if(EyeLayer.shapeType==MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                     EyeLayer.Symbol.OutlineColor=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 axMap2.Layers.Add(EyeLayer);
                 axMap2.Refresh();
             }
         }
     }
     catch( Exception ex )
     {
         //MessageBox.Show("����ͼ��ʧ��,�����������!","����",MessageBoxButtons.OK,MessageBoxIcon.Error);
         ExceptionHandler.Handle("����ͼ��ʧ��,�����������!", ex );
     }
 }
示例#6
0
        /// <summary>
        /// load layer from file, layer -> mapMain ocx
        /// </summary>
        private void InitializeMainMap()
        {
            mapMain.Layers.Clear();
            mapMain.ScrollBars = false;
            MapObjects2.DataConnection mapCon = new MapObjects2.DataConnectionClass();
            try
            {
                mapCon.Database = Path.GetDirectoryName(Application.ExecutablePath) + "\\shaps\\";
                for (int m = 0; m < 3; m++)
                {
                    for (int i = 0; i < mapLayer.m_layers.Length; i++)
                    {
                        MapObjects2.MapLayer layer;
                        layer            = new MapObjects2.MapLayer();
                        layer.GeoDataset = mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                        switch (m)
                        {
                        case 0:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                            {
                                continue;
                            }
                            break;

                        case 1:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypeLine)
                            {
                                continue;
                            }
                            break;

                        case 2:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePoint)
                            {
                                continue;
                            }
                            break;

                        default:
                            continue;
                        }
                        mapLayer.m_layers[i].layer = layer;
                        mapMain.Layers.Add(mapLayer.m_layers[i].layer);
                        mapLayer.m_layers[i].layer.Symbol.Style = (short)mapLayer.m_layers[i].dtSymbol;
                        mapLayer.m_layers[i].layer.Symbol.Color = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        mapLayer.m_layers[i].layer.Symbol.Size  = (short)mapLayer.m_layers[i].dtSize;
                        if (mapLayer.m_layers[i].layer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                        {
                            mapLayer.m_layers[i].layer.Symbol.OutlineColor = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        }
                    }
                }

                zoomRect = mapMain.Extent;
                zoomRect.ScaleRectangle(SC);
                //				mapMain.CenterAt(STAT.X,STAT.Y);
                mapMain.Extent = zoomRect;
                mapMain.Refresh();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("加载图层失败,请重新起动软件!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                ExceptionHandler.Handle("加载图层失败,请重新起动软件!", ex);
            }
        }
示例#7
0
        public void LoadProjectByMapInfos(MapStruct mapInfos,AxMapObjects2.AxMap mapControl)
        {
            List<ILayerStruct> oLayers = mapInfos.Layers;
            MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass();

            oConn.Database = mapInfos.GeoDataSetPath;

            oConn.Connect();

            foreach (ILayerStruct oLayer in oLayers)
            {
                if (oLayer is MapLayerInfoStruct && oConn.Connected)
                {
                    MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass();
                    oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.Name);

                    this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render);
                    this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol);

                    mapControl.Layers.Add(oMapLayer);
                }
                else if (oLayer is ImageLayerInfoStruct)
                {
                    //not implement
                    //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass();
                    //oImageLayer.Name = oLayer.Name;
                }
            }

            if(oConn.Connected) oConn.Disconnect();

            mapControl.Extent.Top = mapInfos.BBox.MinX;
            mapControl.Extent.Left = mapInfos.BBox.MinY;
            mapControl.Extent.Bottom = mapInfos.BBox.MaxX;
            mapControl.Extent.Right = mapInfos.BBox.MaxY;
            mapControl.CoordinateSystem = mapInfos.CoordinateSystem;
        }