コード例 #1
0
ファイル: FrmMain.cs プロジェクト: zhongshuiyuan/TileDownLoad
        private void btnBaiduPoi_Click(object sender, EventArgs e)
        {
            if (this.mapControl.extent == null)
            {
                MessageBox.Show("请选择下载区域");
                return;
            }
            Extent extent    = this.mapControl.extent;
            Extent newExtent = new Extent();

            if (this.mapType == MapType.Gaode || this.mapType == MapType.GaodeImage || this.mapType == MapType.Google ||
                this.mapType == MapType.GoogleImage)
            {
                Coord leftTop = CoordHelper.Mercator2lonLat(extent.minX, extent.minY);
                leftTop = CoordHelper.BdEncrypt(leftTop.lat, leftTop.lon);
                Coord rightBottum = CoordHelper.Mercator2lonLat(extent.maxX, extent.maxY);
                rightBottum    = CoordHelper.BdEncrypt(rightBottum.lat, rightBottum.lon);
                newExtent.minX = leftTop.lon;
                newExtent.minY = leftTop.lat;
                newExtent.maxX = rightBottum.lon;
                newExtent.maxY = rightBottum.lat;
            }
            else if (this.mapType == MapType.Tiandi || this.mapType == MapType.TiandiImage)
            {
                Coord leftTop = CoordHelper.Transform(extent.minX, extent.minY);
                leftTop = CoordHelper.BdEncrypt(leftTop.lat, leftTop.lon);
                Coord rightBottum = CoordHelper.Transform(extent.maxX, extent.maxY);
                rightBottum    = CoordHelper.BdEncrypt(rightBottum.lat, rightBottum.lon);
                newExtent.minX = leftTop.lon;
                newExtent.minY = leftTop.lat;
                newExtent.maxX = rightBottum.lon;
                newExtent.maxY = rightBottum.lat;
            }
            else
            {
                MessageBox.Show("该地图类型不支持兴趣点下载,选择其他类型");
                return;
            }
            FrmPOIDownForBaidu frmPOIDown = new FrmPOIDownForBaidu(newExtent);

            frmPOIDown.Show();
        }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: zhongshuiyuan/TileDownLoad
        /// <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);
        }
コード例 #3
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();
            }
        }