Beispiel #1
0
        private void converteData()
        {
            DataTable tempDataTable = SVCHelper.ReadCsvFile(this.path);
            int       k             = 0;

            foreach (DataRow row in tempDataTable.Rows)
            {
                if (!this.isStop)
                {
                    k++;
                    string xString = row["X"] != null ? row["X"].ToString() : "";
                    string yString = row["Y"] != null ? row["Y"].ToString() : "";
                    double x = 0.0, y = 0.0;
                    double.TryParse(xString, out x);
                    double.TryParse(yString, out y);
                    Coord coord = new Coord(x, y);
                    coord = CoordHelper.Gcj2Wgs(coord.lon, coord.lat);
                    DataRow newRow = this.dataTable.NewRow();
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        newRow[i] = row[i];
                    }
                    newRow["WGS84_X"] = coord.lon;
                    newRow["WGS84_Y"] = coord.lat;
                    if (this.convertHandler != null)
                    {
                        this.convertHandler(newRow, k, tempDataTable.Rows.Count);
                    }
                }
            }
            if (this.converteEndHandler != null)
            {
                this.converteEndHandler();
            }
        }
Beispiel #2
0
        /// <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);
        }