public void GetDefaultMapParameterTest_Normal() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); MapParameter mapParameter = map.GetDefaultMapParameter("世界地图"); Assert.IsTrue(mapParameter.Name == "世界地图"); Assert.IsTrue(mapParameter.Layers.Count == 14); }
public SQLForm(string mapUrl, string mapName) { InitializeComponent(); this._mapName = mapName; this._mapUrl = mapUrl; _map = new Map(_mapUrl); defaultMapParameter = _map.GetDefaultMapParameter(mapName); InitializeSQL(); }
public QuerySettingForm(string mapUrl, string mapName) { InitializeComponent(); this._mapName = mapName; this._mapUrl = mapUrl; Map map = new Map(_mapUrl); MapParameter defaultMapParameter = map.GetDefaultMapParameter(mapName); InitLayer(defaultMapParameter); }
public SQLForm(string mapUrl, string mapName, MapControl mapControl) { InitializeComponent(); this._mapName = mapName; this._mapUrl = mapUrl; _map = new Map(_mapUrl); defaultMapParameter = _map.GetDefaultMapParameter(mapName); _mapControl = mapControl; publicResultForm = new PublicResultForm(); publicResultForm.Name = "QueryBySql"; publicResultForm.Text = "SQL查询结果"; publicResultForm.MapControl = mapControl; InitializeSQL(); }
public void GetDefaultMapParameterTest_NoMapName() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); string paramName = string.Empty; try { MapParameter mapParameter = map.GetDefaultMapParameter(""); } catch (ArgumentNullException e) { paramName = e.ParamName; } finally { Assert.IsTrue(string.Equals(paramName, "mapName", StringComparison.CurrentCulture)); } }
public QuerySettingForm(string mapUrl, string mapName) { InitializeComponent(); this._mapName = mapName; this._mapUrl = mapUrl; Map map = new Map(_mapUrl); MapParameter defaultMapParameter = map.GetDefaultMapParameter(mapName); bool isNew = false; if (QuerySetting.MapUrl != mapUrl || QuerySetting.MapName != mapName) { isNew = true; QuerySetting.MapName = mapName; QuerySetting.MapUrl = mapUrl; } InitLayer(defaultMapParameter,isNew); }
private void tsbOpen_Click(object sender, EventArgs e) { if (this._initForm == null) { this._initForm = new InitForm(); } if (this._initForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Map map = new Map(this._initForm.MapUrl); MapParameter defaultMapParameter = map.GetDefaultMapParameter(this._initForm.SelectedMapName); double[] mapScales = new double[21]; mapScales[0] = defaultMapParameter.Scale / 6; mapScales[1] = defaultMapParameter.Scale / 4; mapScales[2] = defaultMapParameter.Scale / 2; mapScales[3] = defaultMapParameter.Scale; for (int i = 0; i < 17; i++) { mapScales[i + 4] = mapScales[i + 3] * 2; } _gMapProvider = new SuperMapProvider(this._initForm.MapUrl, this._initForm.SelectedMapName, mapScales); //_gMapProvider = new SuperMapProvider(this._initForm.MapUrl, this._initForm.SelectedMapName, 256, "png", null); this.mapControl1.Init(); this.mapControl1.MapProvider = _gMapProvider; this._mapUrl = this._initForm.MapUrl; this._mapName = this._initForm.SelectedMapName; this.mapControl1.DragButton = System.Windows.Forms.MouseButtons.Left; this.mapControl1.Position = new PointLatLng(defaultMapParameter.Center.Y, defaultMapParameter.Center.X); this.mapControl1.MinZoom = 0; this.mapControl1.MaxZoom = mapScales.Length - 1; this.mapControl1.Zoom = 3; this.mapControl1.ReloadMap(); //工具条按钮可见。 for (int i = 0; i < this.toolStrip1.Items.Count; i++) { this.toolStrip1.Items[i].Enabled = true; } for (int i = 0; i < this.tsbDropdownbtn.DropDownItems.Count; i++) { if (this.tsbDropdownbtn.DropDownItems[i].Name == "tsbtnQuerySetting") this.tsbDropdownbtn.DropDownItems[i].Enabled = true; else this.tsbDropdownbtn.DropDownItems[i].Enabled = false; this.tsbDropdownbtn.DropDownItems["sQLQuery"].Enabled = true; } } }
public iServerSchema(string serviceUrl, string mapName, uint tileSize, string format, double[] scales) { Name = "iServer"; Format = format; Srs = "EPSG:4326"; Map map = new Map(serviceUrl); SuperMap.Connector.Utility.MapParameter mapParameter = map.GetDefaultMapParameter(mapName); this.Extent = new Extent(mapParameter.Bounds.LeftBottom.X, mapParameter.Bounds.LeftBottom.Y, mapParameter.Bounds.RightTop.X, mapParameter.Bounds.RightTop.Y); this.Width = (int)tileSize; this.Height = (int)tileSize; this.Format = format; this.OriginX = mapParameter.Bounds.LeftBottom.X; this.OriginY = mapParameter.Bounds.RightTop.Y; this.Axis = AxisDirection.InvertedY; for (int i = 0; i < scales.Length; i++) { double referViewBoudnsWidth = mapParameter.ViewBounds.RightTop.X - mapParameter.ViewBounds.LeftBottom.X; double referViewBoundsHeight = mapParameter.ViewBounds.RightTop.Y - mapParameter.ViewBounds.LeftBottom.X; double referViewerWidth = mapParameter.Viewer.RightBottom.X - mapParameter.Viewer.LeftTop.X; double referViewerHeight = mapParameter.Viewer.RightBottom.Y - mapParameter.Viewer.LeftTop.Y; double resolutionX = (mapParameter.Scale * referViewBoudnsWidth) / (scales[i] * referViewerWidth); double resolutionY = (mapParameter.Scale * referViewBoundsHeight) / (scales[i] * referViewerHeight); this.Resolutions.Add(new Resolution() { Id = i.ToString(), UnitsPerPixel = resolutionX }); } }
private void InitLayers() { this.clbLayers.Items.Clear(); Map map = new Map(_mapUrl); MapParameter mapParameter = map.GetDefaultMapParameter(_mapName); if (mapParameter != null) { for (int i = 0; i < mapParameter.Layers.Count; i++) { this.clbLayers.Items.Add(new LayerItem(mapParameter.Layers[i].Name, mapParameter.Layers[i].Caption)); } } }
public void GetTileTest_ByTempLayer() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); TileInfo tileInfo = new TileInfo(); tileInfo.Scale = 0.00000002; tileInfo.Height = 512; tileInfo.Width = 512; TileIndex tileIndex = new TileIndex() { RowIndex = 2, ColIndex = 1 }; tileInfo.TileIndex = tileIndex; MapParameter mapParameter = map.GetDefaultMapParameter("世界地图"); List<Layer> tempLayer = new List<Layer>(); tempLayer.Add(mapParameter.Layers[12]); mapParameter.Layers = tempLayer; ImageOutputOption imageOutputOption = new ImageOutputOption(); imageOutputOption.ImageReturnType = ImageReturnType.BINARY; imageOutputOption.Transparent = false; imageOutputOption.ImageOutputFormat = ImageOutputFormat.PNG; MapImage mapImage = map.GetTile("世界地图", tileInfo, imageOutputOption, mapParameter); using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData)) { Bitmap bmp = new Bitmap(memoryStream); Assert.IsTrue(bmp.Width == 512); Assert.IsTrue(bmp.Height == 512); System.Drawing.Color color = bmp.GetPixel(240, 389); Assert.IsTrue(color.R == 242); Assert.IsTrue(color.G == 239); Assert.IsTrue(color.B == 233); } Assert.IsNull(null); }
public void GetMapImage() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); MapParameter mapParameter = map.GetDefaultMapParameter("世界地图"); List<Layer> tempLayer = new List<Layer>(); tempLayer.Add(mapParameter.Layers[12]); tempLayer.Add(mapParameter.Layers[13]); mapParameter.Layers = tempLayer; SuperMap.Connector.Utility.Rectangle rect = new SuperMap.Connector.Utility.Rectangle(); rect.LeftTop = new SuperMap.Connector.Utility.Point(); rect.RightBottom = new SuperMap.Connector.Utility.Point(); rect.LeftTop.X = 0; rect.LeftTop.Y = 0; rect.RightBottom.X = 600; rect.RightBottom.Y = 480; mapParameter.Viewer = rect; mapParameter.Center = new Point2D(); mapParameter.Center.X = 0; mapParameter.Center.Y = 0; MapImage mapImage = map.GetMapImage("世界地图", mapParameter, null); using (MemoryStream memoryStream = new MemoryStream(mapImage.ImageData)) { Bitmap bmp = new Bitmap(memoryStream); Assert.IsTrue(bmp.Width == 600); Assert.IsTrue(bmp.Height == 480); } }