private void btnSort_Click(object sender, EventArgs e) { if (_vl == null) { return; } if (!_vl.HasVectorScaleRanges()) { return; } List <IVectorScaleRange> ranges = new List <IVectorScaleRange>(); foreach (IVectorScaleRange sc in _vl.VectorScaleRange) { ranges.Add(sc); } ranges.Sort(new ScaleRangeSorter()); _vl.RemoveAllScaleRanges(); foreach (IVectorScaleRange sc in ranges) { _vl.AddVectorScaleRange(sc); } //Refresh display BindScaleList(_vl.VectorScaleRange); _edsvc.HasChanged(); }
private void ProfileLayerDefinition(ILayerDefinition ldef) { //TODO: This was a line-by-line port from 2.x to match the 3.x APIs //we should find time to clean this up and ensure the profiling numbers are //truly reflective of actual performance metrics if (backgroundWorker.CancellationPending) { return; } string resourceId = ldef == m_item ? m_resourceId : ldef.ResourceID; MakeTempMap(); backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LogMessageLayerDefinition, resourceId))); using (new Timer(Strings.Prof_LogMessageRuntimeLayer, backgroundWorker)) { try { IMapDefinition mdef = Utility.CreateMapDefinition(m_connection, string.Empty); //We cannot flub this anymore. AIMS 2012 demands the Map Definition id specified checks out mdef.ResourceID = "Session:" + m_connection.SessionID + "//ProfileTest.MapDefinition"; //NOXLATE m_connection.ResourceService.SaveResource(mdef); IMapLayer layer = mdef.AddLayer(null, "Test Layer", ldef.ResourceID); //NOXLATE layer.Visible = false; layer.Selectable = false; if (backgroundWorker.CancellationPending) { return; } var mpsvc = (IMappingService)m_connection.GetService((int)ServiceType.Mapping); var map = mpsvc.CreateMap(mdef); using (new Timer(Strings.Prof_LogMessageIdentifyFetching, backgroundWorker)) { var rtl = map.Layers["Test Layer"]; //NOXLATE rtl.Visible = true; rtl.Selectable = true; } map.Save(); } catch (Exception ex) { //string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LayerDefinitionProfilingError, resourceId, ex.ToString(), Environment.NewLine))); } } if (backgroundWorker.CancellationPending) { return; } ILayerDefinition lx = (ILayerDefinition)ldef.Clone(); if (lx.SubLayer.LayerType == LayerType.Vector || lx.SubLayer.LayerType == LayerType.Raster) { using (new Timer(Strings.Prof_LogMessageRenderingScales, backgroundWorker)) { if (lx.SubLayer.LayerType == LayerType.Vector) { IVectorLayerDefinition vlx = lx.SubLayer as IVectorLayerDefinition; //VectorScaleRangeTypeCollection ranges = vlx.VectorScaleRange; List <IVectorScaleRange> ranges = new List <IVectorScaleRange>(vlx.VectorScaleRange); foreach (var vsr in ranges) { if (backgroundWorker.CancellationPending) { return; } string tmp1 = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.LayerDefinition, m_connection.SessionID); try { double minscale = vsr.MinScale.HasValue ? vsr.MinScale.Value : 0; double maxscale = vsr.MaxScale.HasValue ? vsr.MaxScale.Value : 10000000; vlx.RemoveAllScaleRanges(); vsr.MinScale = null; vsr.MaxScale = null; vlx.AddVectorScaleRange(vsr); m_connection.ResourceService.SaveResourceAs(lx, tmp1); if (backgroundWorker.CancellationPending) { return; } var lst = m_connection.FeatureService.GetSpatialContextInfo(vlx.ResourceId, false); //Create a runtime map just containing this particular layer at this particular scale range //We are profiling the stylization settings for this layer var mdf = Utility.CreateMapDefinition(m_connection, ""); if (lst.SpatialContext != null && lst.SpatialContext.Count >= 1) { mdf.CoordinateSystem = lst.SpatialContext[0].CoordinateSystemWkt; if (string.IsNullOrEmpty(m_tempmap.CoordinateSystem)) { mdf.CoordinateSystem = @"LOCAL_CS[""*XY-M*"", LOCAL_DATUM[""*X-Y*"", 10000], UNIT[""Meter"", 1], AXIS[""X"", EAST], AXIS[""Y"", NORTH]]"; //NOXLATE } double llx = double.Parse(lst.SpatialContext[0].Extent.LowerLeftCoordinate.X, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); double lly = double.Parse(lst.SpatialContext[0].Extent.LowerLeftCoordinate.Y, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); double urx = double.Parse(lst.SpatialContext[0].Extent.UpperRightCoordinate.X, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); double ury = double.Parse(lst.SpatialContext[0].Extent.UpperRightCoordinate.Y, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); m_tempmap.DataExtent = ObjectFactory.CreateEnvelope(llx, lly, urx, ury); } SetTempLayer(mdf, tmp1); var mpsvc = (IMappingService)m_connection.GetService((int)ServiceType.Mapping); //We cannot flub this anymore. AIMS 2012 demands the Map Definition id specified checks out mdf.ResourceID = "Session:" + m_connection.SessionID + "//ProfileTest.MapDefinition"; //NOXLATE m_connection.ResourceService.SaveResource(mdf); var rtmap = mpsvc.CreateMap(mdf); if (m_connection.ResourceService.ResourceExists(rtmap.ResourceID)) { m_connection.ResourceService.DeleteResource(rtmap.ResourceID); } rtmap.Save(); if (backgroundWorker.CancellationPending) { return; } using (new Timer(string.Format(Strings.Prof_LogMessageScaleRange, minscale, maxscale), backgroundWorker)) { //TODO: Use extents rather than scale //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, m.Extents, 1024, 800, 96)) using (System.IO.Stream s = mpsvc.RenderRuntimeMap(rtmap, ((rtmap.DataExtent.MaxX - rtmap.DataExtent.MinX) / 2) + rtmap.DataExtent.MinX, ((rtmap.DataExtent.MaxY - rtmap.DataExtent.MinY) / 2) + rtmap.DataExtent.MinY, 50000, 1024, 800, 96)) { backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_MapRenderingImageSize, s.Length))); } } } finally { try { m_connection.ResourceService.DeleteResource(tmp1); } catch { } } } } } } if (backgroundWorker.CancellationPending) { return; } backgroundWorker.ReportProgress(0, ("\r\n")); //NOXLATE }