/// <summary> /// Validate function for all ElementLayerService commands /// </summary> /// <param name="validationContext">System.ComponentModel.DataAnnotations.ValidationContext (Describes the context in which a validation check is performed.)</param> /// <param name="actionDBType">[ActionDBTypeEnum] (CSSPEnums.ActionDBTypeEnum.html) action type to validate</param> /// <returns>IEnumerable of ValidationResult (Where ValidationResult is a container for the results of a validation request.)</returns> private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType) { string retStr = ""; Enums enums = new Enums(LanguageRequest); ElementLayer elementLayer = validationContext.ObjectInstance as ElementLayer; elementLayer.HasErrors = false; if (elementLayer.Layer < 1 || elementLayer.Layer > 1000) { elementLayer.HasErrors = true; yield return(new ValidationResult(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Layer", "1", "1000"), new[] { "Layer" })); } //ZMin has no Range Attribute //ZMax has no Range Attribute //CSSPError: Type not implemented [Element] of type [Element] //CSSPError: Type not implemented [Element] of type [Element] retStr = ""; // added to stop compiling CSSPError if (retStr != "") // will never be true { elementLayer.HasErrors = true; yield return(new ValidationResult("AAA", new[] { "AAA" })); } }
public void Add() { GroupLayer gl = AppState.ViewDef.FindOrCreateGroupLayer(@"Environment"); var w = new WebMercator(); ElementLayer wi = new ElementLayer() { ID = "NO2" }; var i = new Image { Source = new BitmapImage(new Uri("http://cool2.mooo.com/urbanfloodwebsite/images/NO2proj2.png")), IsHitTestVisible = false, Stretch = Stretch.Fill }; //<LatLonBox id="khLatLonBox218"><north>90</north><south>-90</south><east>180</east><west>-180</west></LatLonBox> //102100 var mpa = new MapPoint(-14.9515, 41.4389); var mpb = new MapPoint(20.4106, 59.9934); mpa = w.FromGeographic(mpa) as MapPoint; mpb = w.FromGeographic(mpb) as MapPoint; mpa = w.FromGeographic(new MapPoint(-180, -85.0511, new SpatialReference(4326))) as MapPoint; mpb = w.FromGeographic(new MapPoint(180, 85.0511, new SpatialReference(4326))) as MapPoint; var envelope = new Envelope(mpa, mpb); ElementLayer.SetEnvelope(i, envelope); wi.Children.Add(i); wi.Initialize(); wi.Visible = true; gl.ChildLayers.Add(wi); }
//Wait for the element layer to initialize private void ElementLayer_Initialized(object sender, EventArgs e) { //Grab the element layer myElementLayer = MyMap.Layers["ElementLayer"] as ElementLayer; //Create a new bitmap image from the image file BitmapImage bitImage = new BitmapImage(new Uri(pathToFile)); //When the image has successfully been opened bitImage.ImageOpened += (sender1, e1) => { //grab the image height and width imageHeight = bitImage.PixelHeight; imageWidth = bitImage.PixelWidth; //Create a new web client to send the request for the world file WebClient myClient = new WebClient(); //The event handler for when the world file has been loaded myClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WorldFileLoaded); //Replaces the .jpg extension with the .jgw extension String pathToWorldFile = (pathToFile.Remove(pathToFile.Length - 4, 4)) + worldFileExtention; //Download the world file myClient.DownloadStringAsync(new Uri(pathToWorldFile)); }; //Create a new image element image = new Image(); image.Source = bitImage; //Set the envelope for the image. Note the extent is merely a placeholder, we will replace it in a momment. ElementLayer.SetEnvelope(image, new Envelope(100, 100, 100, 100)); //Add the image to element layer myElementLayer.Children.Add(image); }
private void WorldFileLoaded(object sender, DownloadStringCompletedEventArgs e) { //Checks to see if there was an error if (e.Error == null) { //grab the data from the world file string myData = e.Result; //split string into an array based on new line characters string[] lines = myData.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries); //convert the strings into doubles double[] coordValues = new double[6]; for (int i = 0; i < 6; i++) { coordValues[i] = Convert.ToDouble(lines[i]); } //calculate the pixel height and width in real world coordinates double pixelWidth = Math.Sqrt(Math.Pow(coordValues[0], 2) + Math.Pow(coordValues[1], 2)); double pixelHeight = Math.Sqrt(Math.Pow(coordValues[2], 2) + Math.Pow(coordValues[3], 2)); //Create a map point for the top left and bottom right MapPoint topLeft = new MapPoint(coordValues[4], coordValues[5]); MapPoint bottomRight = new MapPoint(coordValues[4] + (pixelWidth * imageWidth), coordValues[5] + (pixelHeight * imageHeight)); //create an envelope for the elmently layer Envelope extent = new Envelope(topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y); ElementLayer.SetEnvelope(image, extent); //Zoom to the extent of the image MyMap.Extent = extent; } }
/// <summary> /// Create element chart and add it into an Elememt Layer in the Map /// </summary> private void CreateElementChart(Graphic graphic, string displayValue) { ChartQueryLayer chartLayer = queryTool.QueryLayer as ChartQueryLayer; string[] outFields = chartLayer.OutputFields.Split(','); string[] outLabels = chartLayer.OutputLabels.Split(','); string title = string.Format("{0} - {1}", displayValue, chartLayer.Title); bool isPercentDependent = chartLayer.ChartOutput.DependentIsPercentage; string dependentAxisTitle = chartLayer.ChartOutput.DependentAxisTitle; Chart chart = null; switch (chartLayer.ChartOutput.ChartType) { case "Bar": case "Column": chart = CreateSingleBarChart(graphic, chartLayer.ChartOutput.ChartType, outFields, outLabels, title, dependentAxisTitle); break; case "Pie": chart = CreateSinglePieChart(graphic, outFields, outLabels, title, dependentAxisTitle, isPercentDependent); chart.Background = new SolidColorBrush(Color.FromArgb(204, 240, 240, 255)); break; } Envelope ext = GeometryTool.ExpandGeometryExtent(graphic.Geometry, 0.10); ElementLayer.SetEnvelope(chart, ext); elementLayer.Children.Clear(); elementLayer.Children.Add(chart); this.MapControl.ZoomTo(ext); }
public void Add() { GroupLayer gl = AppState.ViewDef.FindOrCreateGroupLayer(@"Weather/Rain"); var w = new WebMercator(); //Buienradar var wi = new ElementLayer() { ID = "Rain Radar" }; var i = new Image { Source = new BitmapImage(new Uri("http://www2.buienradar.nl/euradar/latlon_0.gif")), IsHitTestVisible = false, Stretch = Stretch.Fill }; //<LatLonBox><north>59.9934</north><south>41.4389</south><east>20.4106</east><west>-14.9515</west></LatLonBox> var mpa = new MapPoint(-14.9515, 41.4389); var mpb = new MapPoint(20.4106, 59.9934); mpa = w.FromGeographic(mpa) as MapPoint; mpb = w.FromGeographic(mpb) as MapPoint; var envelope = new Envelope(mpa, mpb); ElementLayer.SetEnvelope(i, envelope); wi.Children.Add(i); wi.Initialize(); wi.Visible = true; gl.ChildLayers.Add(wi); }
// 移除但不清空 public Element RemoveElement(ElementLayer layer) { var el = GetElement(layer); this.elements[(int)layer] = null; return(el); }
//Wait for the element layer to initialize private void ElementLayer_Initialized(object sender, EventArgs e) { //Grab the element layer myElementLayer = MyMap.Layers["ElementLayer"] as ElementLayer; //Create a new bitmap image from the image file BitmapImage bitImage = new BitmapImage(new Uri(pathToFile)); //When the image has successfully been opened bitImage.ImageOpened += (sender1, e1) => { //grab the image height and width imageHeight = bitImage.PixelHeight; imageWidth = bitImage.PixelWidth; //Create a new web client to send the request for the world file WebClient myClient = new WebClient(); //The event handler for when the world file has been loaded myClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WorldFileLoaded); //Replaces the .jpg extension with the .jgw extension String pathToWorldFile = (pathToFile.Remove(pathToFile.Length - 4, 4)) + worldFileExtention; //Download the world file myClient.DownloadStringAsync(new Uri(pathToWorldFile)); }; //Create a new image element image = new Image(); image.Source = bitImage; //Set the envelope for the image. Note the extent is merely a placeholder, we will replace it in a momment. ElementLayer.SetEnvelope(image, new Envelope(100, 100, 100, 100)); //Add the image to element layer myElementLayer.Children.Add(image); }
public void Location(string Jsondata) { //string str= @"[{/""MapPointList/"":[{/""X/"":120.199997984195,/""Y/"":33.2838481078603},{/""X/"":120.20085629108,/""Y/"":33.2838481078603},{/""X/"":120.201714597965,/""Y/"":33.2831305928853},{/""X/"":120.201371275211,/""Y/"":33.2823413195999},{/""X/"":120.199997984195,/""Y/"":33.2823413195999},{/""X/"":120.199997984195,/""Y/"":33.2838481078603}],/""colour/"":/""248,10,97/"",/""name/"":/""住宅用户/""}]"; //List<MapPoint> points = JsonConvert.DeserializeObject<List<MapPoint>>(str); // MessageBox.Show("123"); //ContainerManager.ToastTip.Text = "正在加载.."; //ContainerManager.ToastTip.IsOpened = true; List <MapElementPoint> objList = JsonConvert.DeserializeObject <List <MapElementPoint> >(Jsondata); // new List<MapElementPoint>();//new List<MapElementPoint>();//= //MapElementPoint p = new MapElementPoint() //{ // ID = 2, // Type = 1, // X = 119.905900224839, // Y = 33.4571349076769, // Icon = "/JXXZ.ZHCG.Front;component/Images/leftImg_14.png" //}; //MapElementPoint p1 = new MapElementPoint() //{ // ID = 1, // Type = 1, // X = 369739.4480747870000000, // Y = 3307466.1026192900000000, // Icon = "/JXXZ.ZHCG.Front;component/Images/leftImg_14.png" //}; // objList.Add(p); // objList.Add(p1); ElementLayer ElementLayer1 = map.Layers["ElementLayer"] as ElementLayer; // ElementLayer1.Children.Clear(); foreach (MapElementPoint obj in objList) { //MarkerMapPoint element = new MarkerMapPoint(obj, 0, ContainerManager.Map, LayerManager.ElementLayer); //element.AddToMap(); //_currentMapElementList.Add(element); Image img = new Image() { Width = 32, Height = 37, Margin = new Thickness(0, 0, 0, 37), Source = new BitmapImage(new Uri(obj.Icon, UriKind.RelativeOrAbsolute)), Cursor = Cursors.Hand, DataContext = obj }; img.MouseLeftButtonUp += Img_MouseLeftButtonUp; MapPoint c = new MapPoint { X = obj.X, Y = obj.Y }; ElementLayer.SetEnvelope(img, new Envelope(c, c)); ElementLayer1.Children.Add(img); } // ContainerManager.Map.PanTo(new ESRI.ArcGIS.Client.Geometry.Geometry(objList[0].X, objList[0].Y)); ContainerManager.Map.PanTo(new ESRI.ArcGIS.Client.Geometry.Envelope((double)objList[0].X, (double)objList[0].Y, (double)objList[0].X, (double)objList[0].Y)); }
public void SetElement(ElementLayer layer, Element element) { if (this.elements == null) { this.elements = new Element[(int)ElementLayer.COUNT]; } this.elements[(int)layer] = element; }
public Element GetElement(ElementLayer layer) { if (this.elements == null) { return(null); } return(this.elements[(int)layer]); }
public MarkerMapPoint(int iD, string reservedField1, Point point, int v, Map map, ElementLayer elementLayer) { ID = iD; this.reservedField1 = reservedField1; Point = point; this.v = v; Map = map; ElementLayer = elementLayer; }
public TVEElementDrawerData(ElementType elementType, ElementLayer elementLayer, RendererType rendererType, GameObject gameobject, Mesh mesh, Renderer renderer) { this.elementType = elementType; this.elementLayer = elementLayer; this.rendererType = rendererType; this.gameobject = gameobject; this.mesh = mesh; this.renderer = renderer; }
protected override void OnWidgetLoaded() { base.OnWidgetLoaded(); queryTool = new QueryTool(); queryTool.ResultReady += new QueryTool.QueryResultReady(Query_ResultReady); elementLayer = new ElementLayer(); this.MapControl.Layers.Add(elementLayer); }
public void ResetElement(ElementLayer layer) { var el = GetElement(layer); if (el != null) { el.Clear(); this.elements[(int)layer] = null; } }
public string[] GetLayer(ElementLayer layer) { for (int i = 0; i < layers.Count; i++) { if (layers[i].layer.Equals(layer.ToString())) { return(layers[i].elements); } } return(null); }
public MapControl() { InitializeComponent(); ArcGISLib.GoogleMap map1 = new ArcGISLib.GoogleMap() { ID = "BaseMap" }; map1.SetValue(Map.NameProperty, "BaseMap"); ElementLayer lyr = new ElementLayer() { ID = "ElementLyr" }; this.map1.Layers.Add(map1); this.map1.Layers.Add(lyr); overviewMap1.Layer = new ArcGISLib.GoogleMap() ; }
private ElementLayer GetFilledRandomElementLayer(string OmitPropName) { ElementLayer elementLayer = new ElementLayer(); if (OmitPropName != "Layer") { elementLayer.Layer = GetRandomInt(1, 1000); } // should implement a Range for the property ZMin and type ElementLayer // should implement a Range for the property ZMax and type ElementLayer //CSSPError: property [Element] and type [ElementLayer] is not implemented return(elementLayer); }
public void Clean() { GraphicsLayer GraphicsLayerRL = map.Layers["GraphicsLayerRL"] as GraphicsLayer; GraphicsLayerRL.Graphics.Clear(); GraphicsLayer GraphicsLayerCq = map.Layers["GraphicsLayerCq"] as GraphicsLayer; GraphicsLayerCq.Graphics.Clear(); ElementLayer ElementLayer1 = map.Layers["ElementLayer"] as ElementLayer; ElementLayer1.Children.Clear(); GraphicsLayer GraphicsLayer = map.Layers["GraphicsLayer"] as GraphicsLayer; GraphicsLayer.Graphics.Clear(); }
public Element CreateElement(ElementLayer layer, ElementType type, Transform parent, bool active = true) { var go = Pool.Instance.Get(type, parent); if (go == null) { return(null); } go.name = "elem_" + this.coord.x + "_" + this.coord.y; go.transform.localPosition = new Vector3(this.pos.x, this.pos.y, 0); go.SetActive(active); var el = new Element(type, go); SetElement(layer, el); return(el); }
public MarkerMapPoint(MapElementPoint element, int direction, Map map, ElementLayer mapMarkerLayer) { Image img = new Image() { Width = 32, Height = 37, Margin = new Thickness(0, 0, 0, 37), Source = new BitmapImage(new Uri(element.Icon, UriKind.RelativeOrAbsolute)), Cursor = Cursors.Hand }; this._mapElement = element; this.ID = element.ID; this.Point = new Point((double)element.X, (double)element.Y); this.Direction = direction; this.MapMarker = img; //ToolTipService.SetToolTip(this.MapMarker, this.Name); this.Map = map; this.ElementLayer = mapMarkerLayer; }
/// <summary> /// Adds a UIElement to the layer at the indicated location. /// </summary> /// <param name="ue"> /// The UIElement to add to the layer. /// </param> /// <param name="geo"> /// The map location at which to add the UIElement. /// </param> public void AddSymbol(UIElement ue, ILocation geo) { if (geo == null) { return; } // ESRI apparently doesn't use lat-lon with Bing maps var web = (geo as MapPoint).GeographicToWebMercator(); var webEnvelope = new Envelope(web.X - LonM, web.Y - LatM, web.X + LonP, web.Y + LatP); // ReSharper disable RedundantNameQualifier ElementLayer.SetEnvelope(ue, webEnvelope); // ReSharper restore RedundantNameQualifier this.layerExtent.Expand(geo); // Extra work for special symbol types if (ue is MapMilSymbol) { ((MapMilSymbol)ue).Layer = this; // Similar computation in lat-lon space var geoEnvelope = new EsriLocationRect( geo.Longitude - LonM, geo.Latitude - LatM, geo.Longitude + LonP, geo.Latitude + LatP); ((MapMilSymbol)ue).SymbolExtent = geoEnvelope; } else if (ue is MilGraphic) { ((MilGraphic)ue).Layer = this; } if (!base.Children.Contains(ue)) { base.Children.Add(ue); } }
public MarkerMapElement(MapElement element, int direction, Map map, ElementLayer mapMarkerLayer, Dictionary <int, Image> imglist) { this._mapElement = element; this.ID = element.ID; this.MapElementCategoryID = (int)element.MapElementCategoryID; this.Name = element.ReservedField1; this.Point = new Point((double)element.X, (double)element.Y); this.Direction = direction; if (element.MapElementCategoryID != 4) { this.MapMarker = new Image() { Width = 32, Height = 37, Margin = new Thickness(0, 0, 0, 37), Source = imglist[_mapElement.MapElementBizTypeID.Value].Source, Cursor = Cursors.Hand }; } else { this.MapMarker = new Image() { Width = 32, Height = 37, Margin = new Thickness(0, 0, 0, 37), Source = imglist[_mapElement.ReservedField8.Value].Source, Cursor = Cursors.Hand }; } ToolTipService.SetToolTip(this.MapMarker, this.Name); this.Map = map; this.ElementLayer = mapMarkerLayer; }
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { this.InitializationFailure = new ArgumentException(Properties.Resources.KmlLayer_DocumentParsingFailed); } else { // Create graphic features from definitions -- this code requires the UI thread FeatureDefinition fd = (FeatureDefinition)e.Result; // Initialize the layer name with the name info coming from the KML document Name = fd.name; _hasRootContainer = _isRoot && fd.hasRootContainer; // the root container has been collapsed (info needed to generate internal folderIDs) if (_visibleLayerIds != null && !IsInitialized) { // VisibleLayerIds is set --> layer created from a web map --> check that the layer must stay visible (_hasRootContainer is set only after the file has been parsed) if (_hasRootContainer && !_visibleLayerIds.Contains(1)) // FolderIds 1 is the top level folder that may not be visible in SL { Visible = false; _isLoading = false; base.Initialize(); return; } } // Store the parsed styles to be able to pass them to children _context.Styles = fd.styles; // Create ground overlays and add to element layer if (fd.groundOverlays.Any()) { ElementLayer elementLayer = new ElementLayer { ID = Properties.Resources.KmlLayer_GroundOverlaysSublayer }; fd.CreateGroundOverlays(elementLayer, _context.Images, Map); ChildLayers.Add(elementLayer); if (IsInitialized) elementLayer.Initialize(); // should be done by the group layer (to remove when Bug#2718 is fixed) } // Create graphics and add to graphics layer if (fd.placemarks.Any()) { KmlGraphicsLayer kmlGraphicsLayer = new KmlGraphicsLayer { ID = Properties.Resources.KmlLayer_PlacemarksSublayer, ProjectionService = ProjectionService, IsHidden = _hideChildren }; fd.CreateGraphics(kmlGraphicsLayer, _context.Images); #if !WINDOWS_PHONE kmlGraphicsLayer.MapTip = MapTip; #endif ChildLayers.Add(kmlGraphicsLayer); if (IsInitialized) kmlGraphicsLayer.Initialize(); // should be done by the group layer (to remove when Bug#2718 is fixed) // Setting the Spatial Reference of the KML layer to 4326: if (this.SpatialReference == null) { this.SpatialReference = new Geometry.SpatialReference(4326); } } // Create a sub KML layer for each container foreach (ContainerInfo container in fd.containers) { string fullPath = _fullPath == null ? (container.Name ?? string.Empty) : string.Concat(_fullPath, "/", container.Name); // Note : use internal constructor, so properties such as MapTip, ProxyUrl, VisibleLayers.. are reported to the children var kmlLayer = new KmlLayer(this) { ID = container.Name, Name = container.Name, _fullPath = fullPath, RefreshInterval = TimeSpan.FromSeconds(container.RefreshInterval), VisibleTimeExtent = container.TimeExtent, RegionInfo = container.RegionInfo, _folderId = container.FolderId, _hideChildren = container.HideChildren, IsHidden = _hideChildren }; bool isOk = true; if (string.IsNullOrEmpty(container.Url)) { // Set the visibility of the layer // There are 3 ways to define the visibility of a folder or document, by priority order: // - by the internal VisibleLayerIds property (for the layers inside a web map) // - by the public VisibleLayers property // - by the visibility defined in the KML document kmlLayer.Visible = _visibleLayerIds != null ? _visibleLayerIds.Contains(kmlLayer._folderId) : IsContainerVisible(fullPath, container.Visible); kmlLayer._visibleLayerIds = _visibleLayerIds; // Subfolder : Create a context object and initialize a KmlLayer with it kmlLayer._context = new KmlLayerContext { Element = container.Element, // The XElement that the KML layer has to process Styles = _context.Styles, Images = _context.Images, AtomAuthor = container.AtomAuthor, AtomHref = container.AtomHref }; } else { // NetworkLink : initialize the Url Uri containerUri = GetUri(container.Url, GetBaseUri()); if (containerUri != null) { kmlLayer.Url = containerUri; kmlLayer.ViewRefreshMode = container.ViewRefreshMode; } else isOk = false; // bad url, don't create the child layer // Set the visibility of the layer // For a network link, the internal VisibleLayerIds property is not used. kmlLayer.Visible = IsContainerVisible(fullPath, container.Visible); } if (isOk) { ChildLayers.Add(kmlLayer); if (IsInitialized) kmlLayer.Initialize(); // should be done by the group layer --> to remove later (after or with CR2718) } } // Check that the layer refresh interval is compatible with infos coming from NetworkLinkControl if (fd.networkLinkControl != null) { if (RefreshInterval != TimeSpan.Zero && fd.networkLinkControl.MinRefreshPeriod > 0.0) RefreshInterval = TimeSpan.FromSeconds(Math.Max(RefreshInterval.Seconds, fd.networkLinkControl.MinRefreshPeriod)); } // Set resolution range from the Region/Lods info of the parent SetResolutionRange(); } if (!IsInitialized) base.Initialize(); _isLoading = false; _isLoaded = true; }
private static void ProjectGroundOverlays(ElementLayer layer, SpatialReference sref) { var proj = new Projection.WebMercator(); var webMercatorSR = new SpatialReference(102100); var wgs84SR = new SpatialReference(4326); foreach (UIElement elt in layer.Children) { var envelope = elt.GetValue(ElementLayer.EnvelopeProperty) as Envelope; if (envelope != null) { if (webMercatorSR.Equals(envelope.SpatialReference) && wgs84SR.Equals(sref)) { var env = proj.ToGeographic(envelope) as Envelope; elt.SetValue(ElementLayer.EnvelopeProperty, env); } else if (wgs84SR.Equals(envelope.SpatialReference) && webMercatorSR.Equals(sref)) { var env = proj.FromGeographic(envelope) as Envelope; elt.SetValue(ElementLayer.EnvelopeProperty, env); } } } }
/// <summary> /// Createsground overlays and adds them to the element layer. /// </summary> /// <param name="layer">Element layer that will have overlays added to it.</param> /// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param> public void CreateGroundOverlays(ElementLayer layer, IDictionary<string, ImageBrush> images) { if (layer == null) return; // Process each metadata feature in the list foreach (GroundOverlayDescriptor feature in groundOverlays) { UIElement uiElement; if (!String.IsNullOrEmpty(feature.IconHref)) { ImageSource imageSource; // If the image is provided in kmz content, use it if (images.ContainsKey(feature.IconHref.ToLower())) { imageSource = images[feature.IconHref.ToLower()].ImageSource; } else { // Get the image using the HREF imageSource = new BitmapImage(new Uri(feature.IconHref, UriKind.RelativeOrAbsolute)); } double opacity = (double)feature.Color.A/byte.MaxValue; uiElement = new Image { Source = imageSource, Stretch = Stretch.Fill, Opacity = opacity }; } else { // Just add a rectangle uiElement = new Rectangle { Fill = new SolidColorBrush(feature.Color)}; } // Set the rotation if (feature.Rotation != 0.0) { uiElement.RenderTransformOrigin = new Point(0.5, 0.5); uiElement.RenderTransform = new RotateTransform {Angle = -feature.Rotation}; // KML rotations are specified in a counterclockwise direction } // Set the envelope var elementLayerEnvelopeProperty = ElementLayer.EnvelopeProperty; uiElement.SetValue(elementLayerEnvelopeProperty, feature.Envelope); // Add element to element layer layer.Children.Add(uiElement); } }
public MarkerMapPoint(int id, int mapElementCategoryID, string name, Point point, int direction, Map map, ElementLayer mapMarkerLayer) { Image img = new Image() { Width = 32, Height = 37, Margin = new Thickness(0, 0, 0, 37), Source = new BitmapImage(new Uri(@"/Techzen.ICS.CS;component/Images/location_event_icon.png", UriKind.RelativeOrAbsolute)), Cursor = Cursors.Hand }; switch (mapElementCategoryID) { case 1: img.Source = new BitmapImage(new Uri(@"/Techzen.ICS.CS;component/Images/location_person_icon.png", UriKind.RelativeOrAbsolute)); break; case 2: img.Source = new BitmapImage(new Uri(@"/Techzen.ICS.CS;component/Images/location_car_icon.png", UriKind.RelativeOrAbsolute)); break; case 3: img.Source = new BitmapImage(new Uri(@"/Techzen.ICS.CS;component/Images/location_monitor_icon.png", UriKind.RelativeOrAbsolute)); break; case 4: img.Source = new BitmapImage(new Uri(@"/Techzen.ICS.CS;component/Images/location_event_icon.png", UriKind.RelativeOrAbsolute)); break; case 5: img.Source = new BitmapImage(new Uri(@"/Techzen.ICS.CS;component/Images/location_shop_icon.png", UriKind.RelativeOrAbsolute)); break; default: break; } this.ID = id; this.Point = point; this.Direction = direction; this.MapMarker = img; ToolTipService.SetToolTip(this.MapMarker, name); this.Map = map; this.ElementLayer = mapMarkerLayer; }
public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd) { remoteClient.ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewCompleted; localClient .ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewCompleted; StartPoint = new csPoint { Mp = start }; FinishPoint = new csPoint { Mp = finish }; MLayer = new GraphicsLayer { ID = Guid.NewGuid().ToString() }; ImageLayer = new ElementLayer(); Image = new System.Windows.Controls.Image { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Stretch = Stretch.Fill, StretchDirection = StretchDirection.Both }; ElementLayer.SetEnvelope(Image, AppState.ViewDef.MapControl.Extent); ImageLayer.Children.Add(Image); Start = new Graphic(); Finish = new Graphic(); Line = new Graphic(); var ls = new LineSymbol { Color = Brushes.Black, Width = 4 }; Line.Symbol = ls; UpdateLine(); MLayer.Graphics.Add(Line); Start.Geometry = start; Start.Symbol = rd["Start"] as Symbol; Start.Attributes["position"] = start; Start.Attributes["finish"] = Finish; Start.Attributes["start"] = Start; Start.Attributes["line"] = Line; Start.Attributes["state"] = "start"; Start.Attributes["measure"] = this; Start.Attributes["menuenabled"] = true; MLayer.Graphics.Add(Start); Finish.Geometry = finish; Finish.Attributes["position"] = finish; Finish.Symbol = rd["Finish"] as Symbol; Finish.Attributes["finish"] = Finish; Finish.Attributes["start"] = Start; Finish.Attributes["line"] = Line; Finish.Attributes["measure"] = this; Finish.Attributes["state"] = "finish"; Finish.Attributes["menuenabled"] = true; MLayer.Graphics.Add(Finish); Layer.ChildLayers.Add(ImageLayer); Layer.ChildLayers.Add(MLayer); MLayer.Initialize(); AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta; if (AppState.Imb != null && AppState.Imb.Imb != null) { _3D = AppState.Imb.Imb.Publish(AppState.Imb.Imb.ClientHandle + ".3d"); //AppState.Imb.Imb.Publish(_channel); } updateTimer.Interval = 50; updateTimer.Elapsed += UpdateTimerElapsed; updateTimer.Start(); }
/// <summary> /// Createsground overlays and adds them to the element layer. /// </summary> /// <param name="layer">Element layer that will have overlays added to it.</param> /// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param> /// <param name="map">The map the KML layer belongs to (useful to know the SR) </param> public void CreateGroundOverlays(ElementLayer layer, IDictionary <string, ImageBrush> images, Map map) { if (layer == null) { return; } // Process each metadata feature in the list foreach (GroundOverlayDescriptor feature in groundOverlays) { UIElement uiElement; if (!String.IsNullOrEmpty(feature.IconHref)) { ImageSource imageSource; // If the image is provided in kmz content, use it if (images.ContainsKey(feature.IconHref.ToLower())) { imageSource = images[feature.IconHref.ToLower()].ImageSource; } else { // Get the image using the HREF imageSource = new BitmapImage(KmlLayer.GetUri(feature.IconHref, _baseUri)); } // If feature color is White with an alpha channel, this can be managed with Opacity, else we need the to blend the color with the icon double opacity; bool needBlendEffect; if (feature.Color.R == byte.MaxValue && feature.Color.G == byte.MaxValue && feature.Color.B == byte.MaxValue) { opacity = (double)feature.Color.A / byte.MaxValue; needBlendEffect = false; } else { opacity = 1.0; needBlendEffect = true; } uiElement = new Image { Source = imageSource, Stretch = Stretch.Fill, Opacity = opacity }; if (needBlendEffect) { uiElement.Effect = new MultiplyBlendEffect { BlendColor = feature.Color }; } } else { // Just add a rectangle uiElement = new Rectangle { Fill = new SolidColorBrush(feature.Color) }; } // Set the time extent if (feature.TimeExtent != null) { ElementLayer.SetTimeExtent(uiElement, feature.TimeExtent); } // Set the rotation if (feature.Rotation != 0.0) { uiElement.RenderTransformOrigin = new Point(0.5, 0.5); uiElement.RenderTransform = new RotateTransform { Angle = -feature.Rotation }; // KML rotations are specified in a counterclockwise direction } // Set the envelope var elementLayerEnvelopeProperty = ElementLayer.EnvelopeProperty; var envelope = feature.Envelope; // If the map is based on WebMercatore coordinates, project the envelope (weird at small scale but acceptable at large scale) if (map != null && map.SpatialReference != null && IsWebMercator(map.SpatialReference) && envelope.SpatialReference != null && envelope.SpatialReference.WKID == 4326) // should always be the case { envelope = (new Projection.WebMercator()).FromGeographic(envelope) as Envelope; } uiElement.SetValue(elementLayerEnvelopeProperty, envelope); // Add element to element layer layer.Children.Add(uiElement); } }
/// <summary> /// Createsground overlays and adds them to the element layer. /// </summary> /// <param name="layer">Element layer that will have overlays added to it.</param> /// <param name="images">Dictionary of images coming from kmz content or from previous parsing</param> /// <param name="map">The map the KML layer belongs to (useful to know the SR) </param> public void CreateGroundOverlays(ElementLayer layer, IDictionary<string, ImageBrush> images, Map map) { if (layer == null) return; // Process each metadata feature in the list foreach (GroundOverlayDescriptor feature in groundOverlays) { UIElement uiElement; if (!String.IsNullOrEmpty(feature.IconHref)) { ImageSource imageSource; // If the image is provided in kmz content, use it if (images.ContainsKey(feature.IconHref.ToLower())) { imageSource = images[feature.IconHref.ToLower()].ImageSource; } else { // Get the image using the HREF imageSource = new BitmapImage(KmlLayer.GetUri(feature.IconHref, _baseUri)); } // If feature color is White with an alpha channel, this can be managed with Opacity, else we need the to blend the color with the icon double opacity; bool needBlendEffect; if (feature.Color.R == byte.MaxValue && feature.Color.G == byte.MaxValue && feature.Color.B == byte.MaxValue) { opacity = (double)feature.Color.A / byte.MaxValue; needBlendEffect = false; } else { opacity = 1.0; needBlendEffect = true; } uiElement = new Image { Source = imageSource, Stretch = Stretch.Fill, Opacity = opacity }; if (needBlendEffect) { uiElement.Effect = new MultiplyBlendEffect{BlendColor = feature.Color}; } } else { // Just add a rectangle uiElement = new Rectangle { Fill = new SolidColorBrush(feature.Color)}; } // Set the time extent if (feature.TimeExtent != null) ElementLayer.SetTimeExtent(uiElement, feature.TimeExtent); // Set the rotation if (feature.Rotation != 0.0) { uiElement.RenderTransformOrigin = new Point(0.5, 0.5); uiElement.RenderTransform = new RotateTransform {Angle = -feature.Rotation}; // KML rotations are specified in a counterclockwise direction } // Set the envelope var elementLayerEnvelopeProperty = ElementLayer.EnvelopeProperty; var envelope = feature.Envelope; // If the map is based on WebMercatore coordinates, project the envelope (weird at small scale but acceptable at large scale) if (map != null && map.SpatialReference != null && IsWebMercator(map.SpatialReference) && envelope.SpatialReference != null && envelope.SpatialReference.WKID == 4326) // should always be the case { envelope = (new Projection.WebMercator()).FromGeographic(envelope) as Envelope; } uiElement.SetValue(elementLayerEnvelopeProperty, envelope); // Add element to element layer layer.Children.Add(uiElement); } }
public ElementLayerTest() { elementLayer = new ElementLayer(); }
private bool WriteHTMLParameterContent(StringBuilder sbHTML, DfsuFile dfsuFileHydrodynamic, DfsuFile dfsuFileTransport, List <ElementLayer> elementLayerList, List <NodeLayer> topNodeLayerList, List <NodeLayer> bottomNodeLayerList, List <ElementLayer> SelectedElementLayerList, Node node) { MapInfoService mapInfoService = new MapInfoService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User); string NotUsed = ""; int ItemUVelocity = 0; int ItemVVelocity = 0; int ItemSalinity = 0; int ItemTemperature = 0; int ItemWaterDepth = 0; if (SelectedElementLayerList.Count == 0) { NotUsed = string.Format(TaskRunnerServiceRes.Error_WhileCreating_Document_, "FillRequiredList", "XLSX", fi.FullName); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat3List("Error_WhileCreating_Document_", "FillRequiredList", "XLSX", fi.FullName); return(false); } sb.AppendLine($@"<h2>Parameters output at Latitude: {node.Y} Longitude: {node.X}</h2>"); // getting the ItemNumber foreach (IDfsSimpleDynamicItemInfo dfsDyInfo in dfsuFileTransport.ItemInfo) { if (dfsDyInfo.Quantity.Item == eumItem.eumIuVelocity) { ItemUVelocity = dfsDyInfo.ItemNumber; } if (dfsDyInfo.Quantity.Item == eumItem.eumIvVelocity) { ItemVVelocity = dfsDyInfo.ItemNumber; } } if (ItemUVelocity == 0 || ItemVVelocity == 0) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind_, TaskRunnerServiceRes.Parameters); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFind_", TaskRunnerServiceRes.Parameters); return(false); } foreach (IDfsSimpleDynamicItemInfo dfsDyInfo in dfsuFileHydrodynamic.ItemInfo) { if (dfsDyInfo.Quantity.Item == eumItem.eumISalinity) { ItemSalinity = dfsDyInfo.ItemNumber; } if (dfsDyInfo.Quantity.Item == eumItem.eumITemperature) { ItemTemperature = dfsDyInfo.ItemNumber; } if (dfsDyInfo.Quantity.Item == eumItem.eumIWaterDepth) { ItemWaterDepth = dfsDyInfo.ItemNumber; } } if (ItemUVelocity == 0 || ItemVVelocity == 0) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind_, TaskRunnerServiceRes.Parameters); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFind_", TaskRunnerServiceRes.Parameters); return(false); } int CountLayer = (dfsuFileTransport.NumberOfSigmaLayers == 0 ? 1 : dfsuFileTransport.NumberOfSigmaLayers); for (int Layer = 1; Layer <= CountLayer; Layer++) { sb.AppendLine($@"<h2>Layer: {Layer}</h2>"); sbHTML.AppendLine(@"<table>"); sbHTML.AppendLine(@"<thead>"); sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine(@"<th>StartTime</th>"); sbHTML.AppendLine(@"<th>EndTime</th>"); sbHTML.AppendLine(@"<th>UVelocity</th>"); sbHTML.AppendLine(@"<th>VVelocity</th>"); sbHTML.AppendLine(@"<th>CurrentVelocity</th>"); sbHTML.AppendLine(@"<th>CurrentDirection</th>"); //sbHTML.AppendLine(@"<th>Salinity</th>"); //sbHTML.AppendLine(@"<th>Temperature</th>"); sbHTML.AppendLine(@"<th>WaterDepth</th>"); sbHTML.AppendLine(@"</tr>"); sbHTML.AppendLine(@"</thead>"); sbHTML.AppendLine(@"<tbody>"); int vCount = 0; for (int timeStep = 0; timeStep < dfsuFileTransport.NumberOfTimeSteps; timeStep++) { if (vCount % 10 == 0) { _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, (int)((float)(vCount / dfsuFileTransport.NumberOfTimeSteps) * 100.0f)); } sbHTML.AppendLine(@"<tr>"); sbHTML.AppendLine($@"<td>{dfsuFileTransport.StartDateTime.AddSeconds(vCount * dfsuFileTransport.TimeStepInSeconds).ToString("yyyy-MM-dd HH:mm:ss")}</td>"); sbHTML.AppendLine($@"<td>{dfsuFileTransport.StartDateTime.AddSeconds((vCount + 1) * dfsuFileTransport.TimeStepInSeconds).ToString("yyyy-MM-dd HH:mm:ss")}</td>"); float[] UvelocityList = (float[])dfsuFileTransport.ReadItemTimeStep(ItemUVelocity, timeStep).Data; float[] VvelocityList = (float[])dfsuFileTransport.ReadItemTimeStep(ItemVVelocity, timeStep).Data; ElementLayer el = SelectedElementLayerList.Where(c => c.Layer == Layer).Take(1).FirstOrDefault(); float UV = UvelocityList[el.Element.ID - 1]; float VV = VvelocityList[el.Element.ID - 1]; double VectorVal = Math.Sqrt((UV * UV) + (VV * VV)); double VectorDir = 0.0D; double VectorDirCartesian = Math.Acos(Math.Abs(UV / VectorVal)) * mapInfoService.r2d; if (VectorDirCartesian <= 360 && VectorDirCartesian >= 0) { // everything is ok } else { VectorDirCartesian = 0.0D; } if (UV >= 0 && VV >= 0) { VectorDir = 90 - VectorDirCartesian; } else if (UV < 0 && VV >= 0) { VectorDir = 270 + VectorDirCartesian; VectorDirCartesian = 180 - VectorDirCartesian; } else if (UV >= 0 && VV < 0) { VectorDir = 90 + VectorDirCartesian; VectorDirCartesian = 360 - VectorDirCartesian; } else if (UV < 0 && VV < 0) { VectorDir = 270 - VectorDirCartesian; VectorDirCartesian = 180 + VectorDirCartesian; } //string SalinityText = "Salinity"; //if (ItemSalinity != 0) //{ // float[] SalinityList = (float[])dfsuFileHydrodynamic.ReadItemTimeStep(ItemSalinity, timeStep).Data; // SalinityText = SalinityList[el.Element.ID - 1].ToString(); //} //string TemperatureText = "Temperature"; //if (ItemTemperature != 0) //{ // float[] TemperatureList = (float[])dfsuFileHydrodynamic.ReadItemTimeStep(ItemTemperature, timeStep).Data; // TemperatureText = TemperatureList[el.Element.ID - 1].ToString(); //} string WaterDepthText = "WaterDepth"; if (ItemWaterDepth != 0) { float[] TotalWaterDepthList = (float[])dfsuFileHydrodynamic.ReadItemTimeStep(ItemWaterDepth, timeStep).Data; WaterDepthText = TotalWaterDepthList[el.Element.ID - 1].ToString(); } sbHTML.AppendLine($@"<td>{UV}</td>"); sbHTML.AppendLine($@"<td>{VV}</td>"); sbHTML.AppendLine($@"<td>{VectorVal}</td>"); sbHTML.AppendLine($@"<td>{VectorDirCartesian}</td>"); //sbHTML.AppendLine($@"<td>{SalinityText}</td>"); //sbHTML.AppendLine($@"<td>{TemperatureText}</td>"); sbHTML.AppendLine($@"<td>{WaterDepthText}</td>"); sbHTML.AppendLine(@"</tr>"); vCount += 1; } sbHTML.AppendLine(@"</tbody>"); sbHTML.AppendLine(@"</table>"); } return(true); }
public override void Start() { base.Start(); var baseLayer = ((dsBaseLayer)Model.Layer); if (OperatingMode == FieldOfViewOperatingMode.Image) { if (ImageLayer != null) return; var displayName = Model.Id + " FoV img"; ImageLayer = baseLayer.ChildLayers.OfType<ElementLayer>().FirstOrDefault(c => string.Equals(c.DisplayName, displayName, StringComparison.InvariantCultureIgnoreCase)); if (ImageLayer == null) { ImageLayer = new ElementLayer { ID = displayName, DisplayName = displayName }; ImageLayer.Initialize(); baseLayer.ChildLayers.Insert(0, ImageLayer); AppState.ViewDef.UpdateLayers(); } } else { if (GraphicsLayer != null) return; var displayName = Model.Id + " FoV"; GraphicsLayer = baseLayer.ChildLayers.OfType<GraphicsLayer>().FirstOrDefault(c => string.Equals(c.DisplayName, displayName, StringComparison.InvariantCultureIgnoreCase)); if (GraphicsLayer == null) { GraphicsLayer = new GraphicsLayer { ID = displayName, DisplayName = displayName }; GraphicsLayer.Initialize(); baseLayer.ChildLayers.Insert(0, GraphicsLayer); AppState.ViewDef.UpdateLayers(); } } color = Model.Model.GetColor("Color", Colors.Blue); strokeWidth = Model.Model.GetInt("StrokeWidth", 2); precision = Model.Model.GetInt("Precision", 2); ManagePoiVisibility(); //this.operatingMode = FieldOfViewOperatingMode.Polygon; switch (OperatingMode) { case FieldOfViewOperatingMode.Polygon: if (GraphicsLayer == null) return; remoteClient.ComputeFieldOfViewAsVectorCompleted += ClientOnComputeFieldOfViewAsVectorCompleted; localClient.ComputeFieldOfViewAsVectorCompleted += ClientOnComputeFieldOfViewAsVectorCompleted; break; default: if (ImageLayer == null) return; remoteClient.ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewAsImageCompleted; localClient.ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewAsImageCompleted; image = new Image { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Stretch = Stretch.Fill, StretchDirection = StretchDirection.Both }; ElementLayer.SetEnvelope(image, AppStateSettings.Instance.ViewDef.MapControl.Extent); ImageLayer.Children.Add(image); break; } var posChanged = Observable.FromEventPattern<PositionEventArgs>(ev => Poi.PositionChanged += ev, ev => Poi.PositionChanged -= ev); posChanged.Throttle(TimeSpan.FromMilliseconds(150)).Subscribe(k => Calculate()); var labelChanged = Observable.FromEventPattern<LabelChangedEventArgs>(ev => Poi.LabelChanged += ev, ev => Poi.LabelChanged -= ev); labelChanged.Throttle(TimeSpan.FromMilliseconds(150)).Subscribe(k => Calculate()); Calculate(); }