private void OnMapSetOnProvider(object sender, EventArgs e) { _hasTiledLayers = null; _map = _provider.GetMap(); _mapCs = _provider.GetMapCoordinateSystem(); _mapMeasure = _mapCs.GetMeasure(); var bgColor = _map.GetBackgroundColor(); if (bgColor.Length == 8 || bgColor.Length == 6) { _mapBgColor = ColorTranslator.FromHtml("#" + bgColor); //NOXLATE this.BackColor = _mapBgColor; } _provider.SetDisplaySize(this.Width, this.Height); _selection = _provider.CreateSelectionForMap(); var env = _map.GetMapExtent(); var ll = env.LowerLeftCoordinate; var ur = env.UpperRightCoordinate; _extX1 = _orgX1 = ll.X; _extY2 = _orgY2 = ll.Y; _extX2 = _orgX2 = ur.X; _extY1 = _orgY1 = ur.Y; if ((_orgX1 - _orgX2) == 0 || (_orgY1 - _orgY2) == 0) { _extX1 = _orgX1 = -.1; _extY2 = _orgX2 = .1; _extX2 = _orgY1 = -.1; _extY1 = _orgY2 = .1; } if (this.ConvertTiledGroupsToNonTiled) { var groups = _map.GetLayerGroups(); for (int i = 0; i < groups.GetCount(); i++) { var group = groups.GetItem(i); _provider.MakeGroupNormal(group); } } #if VIEWER_DEBUG CreateDebugFeatureSource(); #endif this.Focus(); //Reset history stack _viewHistory.Clear(); OnPropertyChanged("ViewHistory"); //NOXLATE _viewHistoryIndex = -1; OnPropertyChanged("ViewHistoryIndex"); //NOXLATE var handler = this.MapLoaded; if (handler != null) handler(this, EventArgs.Empty); InitialMapView(); }
public override void Execute(IPlatformFactory factory, ITestLogger logger) { //For a map definition that links to a default provider tile set and both have the same coordinate //system, it should be using the map definition's extents and we should not have null extents or view //center MgCoordinateSystemFactory csFactory = new MgCoordinateSystemFactory(); string csWkt = csFactory.ConvertCoordinateSystemCodeToWkt("LL84"); MgResourceService resSvc = (MgResourceService)factory.CreateService(MgServiceType.ResourceService); var root = "../../TestData/TileService/"; LoadResource(resSvc, "Library://UnitTests/Data/RoadCenterLines.FeatureSource", root + "UT_RoadCenterLines.fs"); LoadResourceData(resSvc, "Library://UnitTests/Data/RoadCenterLines.FeatureSource", "UT_RoadCenterLines.sdf", MgResourceDataType.File, root + "UT_RoadCenterLines.sdf"); LoadResource(resSvc, "Library://UnitTests/Layers/RoadCenterLines.LayerDefinition", root + "UT_RoadCenterLines.ldf"); LoadResource(resSvc, "Library://UnitTests/Data/VotingDistricts.FeatureSource", root + "UT_VotingDistricts.fs"); LoadResourceData(resSvc, "Library://UnitTests/Data/VotingDistricts.FeatureSource", "UT_VotingDistricts.sdf", MgResourceDataType.File, root + "UT_VotingDistricts.sdf"); LoadResource(resSvc, "Library://UnitTests/Layers/VotingDistricts.LayerDefinition", root + "UT_VotingDistricts.ldf"); LoadResource(resSvc, "Library://UnitTests/Data/Parcels.FeatureSource", root + "UT_Parcels.fs"); LoadResourceData(resSvc, "Library://UnitTests/Data/Parcels.FeatureSource", "UT_Parcels.sdf", MgResourceDataType.File, root + "UT_Parcels.sdf"); LoadResource(resSvc, "Library://UnitTests/Layers/Parcels.LayerDefinition", root + "UT_Parcels.ldf"); string tsd = Encoding.UTF8.GetString(Properties.Resources.UT_BaseMapTileSet); tsd = string.Format(tsd, csWkt, -87.5, 43.5, -86.5, 44.5); byte[] tsdBytes = Encoding.UTF8.GetBytes(tsd); MgByteSource sourceTSD = new MgByteSource(tsdBytes, tsdBytes.Length); MgByteReader contentTSD = sourceTSD.GetReader(); MgResourceIdentifier resTSD = new MgResourceIdentifier("Library://UnitTests/TileSets/Test.TileSetDefinition"); resSvc.SetResource(resTSD, contentTSD, null); string mdf = Encoding.UTF8.GetString(Properties.Resources.UT_LinkedTileSet); mdf = string.Format(mdf, csWkt, -87.0, 43.0, -86.0, 44.0, resTSD.ToString()); byte[] mdfBytes = Encoding.UTF8.GetBytes(mdf); MgByteSource sourceMDF = new MgByteSource(mdfBytes, mdfBytes.Length); MgByteReader contentMDF = sourceMDF.GetReader(); MgResourceIdentifier resMDF = new MgResourceIdentifier("Library://UnitTests/Maps/LinkedTileSet.MapDefinition"); resSvc.SetResource(resMDF, contentMDF, null); MgMapBase map = factory.CreateMap(resMDF); MgEnvelope extent = map.GetMapExtent(); Assert.IsNotNull(extent); Assert.IsNotNull(map.MapExtent); MgPoint center = map.GetViewCenter(); Assert.IsNotNull(center); Assert.IsNotNull(map.ViewCenter); MgCoordinate ll = extent.GetLowerLeftCoordinate(); MgCoordinate ur = extent.GetUpperRightCoordinate(); Assert.IsNotNull(ll); Assert.IsNotNull(ur); Assert.AreEqual(-87.0, ll.X); Assert.AreEqual(43.0, ll.Y); Assert.AreEqual(-86.0, ur.X); Assert.AreEqual(44.0, ur.Y); }