/// <summary>
        /// 当地图类型选择改变时,出发,切换相应的地图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbMapTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            Coord   coord      = this.mapControl.GetCenter();
            Coord   result     = coord;
            int     oldZoom    = 0;
            MapType oldMapType = MapType.Google;

            if (coord != null)
            {
                result     = coord;
                oldZoom    = this.mapControl.GetZoom();
                oldMapType = this.mapType;
            }
            var selectItem = (ComboxItem)this.cmbMapType.SelectedItem;

            this.mapControl.setMap(selectItem.Tag.ToString());
            this.mapType = (MapType)selectItem.Value;

            if (coord == null)
            {
                return;
            }
            switch (oldMapType)
            {
            case MapType.Baidu:
            case MapType.BaiduImageTile:
                result = CoordHelper.WebMercator2lonLat(coord);
                result = CoordHelper.BdDecrypt(result.lat, result.lon);
                result = CoordHelper.Gcj2Wgs(result.lon, result.lat);
                break;

            case MapType.Google:
            case MapType.GoogleImage:
                result = CoordHelper.WebMercator2lonLat(coord);
                result = CoordHelper.Gcj2Wgs(result.lon, result.lat);
                break;

            case MapType.Gaode:
            case MapType.GaodeImage:
            case MapType.QQMap:
            case MapType.QQImage:
                result = CoordHelper.WebMercator2lonLat(coord);
                result = CoordHelper.Gcj2Wgs(result.lon, result.lat);
                break;

            case MapType.OpenStreetMap:
                result = CoordHelper.WebMercator2lonLat(coord);
                break;

            case MapType.Tiandi:
            case MapType.TiandiImage:
                result = coord;
                break;
            }
            switch (this.mapType)
            {
            case MapType.Baidu:
            case MapType.BaiduImageTile:
                result = CoordHelper.Transform(result.lon, result.lat);
                result = CoordHelper.BdEncrypt(result.lat, result.lon);
                result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat);
                break;

            case MapType.Google:
            case MapType.GoogleImage:
                result = CoordHelper.Transform(result.lon, result.lat);
                result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat);
                break;

            case MapType.Gaode:
            case MapType.GaodeImage:
            case MapType.QQImage:
            case MapType.QQMap:
                result = CoordHelper.Transform(result.lon, result.lat);
                result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat);
                break;

            case MapType.OpenStreetMap:
                result = CoordHelper.WebMoctorJw2Pm(result.lon, result.lat);
                break;

            case MapType.Tiandi:
            case MapType.TiandiImage:
                break;
            }
            this.mapControl.SetZoom(oldZoom);
            this.mapControl.SetCenter(result);
            tsbClearBounds_Click(null, null);
        }
Exemple #2
0
        private void converteData()
        {
            // DataTable tempDataTable = AsposeCellsHelper.ExportToDataTable(this.path,true);
            //SVCHelper.readCSVFile(this.path);
            int k = 0;

            foreach (DataRow row in this.dataTable.Rows)
            {
                if (!this.isStop)
                {
                    k++;
                    DataRow newRow = row;
                    //for (int i = 0; i < row.ItemArray.Length; i++)
                    //{
                    //    newRow[i] = row[i];
                    //}
                    string xString = row["X"] != null ? row["X"].ToString() : "0";
                    string yString = row["Y"] != null ? row["Y"].ToString() : "0";
                    double x = 0.0, y = 0.0;
                    double.TryParse(xString, out x);
                    double.TryParse(yString, out y);
                    if (x == 0 || y == 0)
                    {
                        continue;
                    }
                    Coord coord = new Coord(x, y);
                    switch (this.covertType)
                    {
                    case CovertType.WGS2GCJ02:
                        coord           = CoordHelper.Transform(x, y);
                        newRow["GDJ_X"] = coord.lon;
                        newRow["GDJ_Y"] = coord.lat;
                        break;

                    case CovertType.BAIDU2GCJ02:
                        coord           = CoordHelper.BdDecrypt(y, x);
                        newRow["GDJ_X"] = coord.lon;
                        newRow["GDJ_Y"] = coord.lat;
                        break;

                    case CovertType.LONLAT2MOCTOR:
                        coord          = CoordHelper.WebMoctorJw2Pm(x, y);
                        newRow["PM_X"] = coord.lon;
                        newRow["PM_Y"] = coord.lat;
                        break;

                    case CovertType.GCJ022BAIDU:
                        coord          = CoordHelper.BdEncrypt(y, x);
                        newRow["BD_X"] = coord.lon;
                        newRow["BD_Y"] = coord.lat;
                        break;

                    case CovertType.WGS2BAIDU:
                        coord          = CoordHelper.Transform(x, y);
                        coord          = CoordHelper.BdEncrypt(coord.lat, coord.lon);
                        newRow["BD_X"] = coord.lon;
                        newRow["BD_Y"] = coord.lat;
                        break;

                    case CovertType.MOCTOR2LONLAT:
                        coord          = CoordHelper.Mercator2lonLat(x, y);
                        newRow["JW_X"] = coord.lon;
                        newRow["JW_Y"] = coord.lat;
                        break;

                    case CovertType.WGS2MOCTOR:
                        coord          = CoordHelper.Transform(x, y);
                        coord          = CoordHelper.WebMoctorJw2Pm(coord.lon, coord.lat);
                        newRow["PM_X"] = coord.lon;
                        newRow["PM_Y"] = coord.lat;
                        break;
                    }
                    //if (this.convertHandler != null)
                    //{
                    //    this.convertHandler(newRow, k, tempDataTable.Rows.Count);
                    //}
                }
            }
            AsposeCellsHelper.ExportToExcel(this.dataTable, this.outPutPath + "\\" + this.outputFileName);
            if (this.converteEndHandler != null)
            {
                this.converteEndHandler();
            }
        }