Пример #1
0
		private MyWMSLayer getWMSLayer(capabilities_1_3_0.wms.LayerType layer, capabilities_1_3_0.wms.EX_GeographicBoundingBoxType parentLatLonBoundingBox, string[] imageFormats)
		{
			MyWMSLayer wmsLayer = new MyWMSLayer();

			wmsLayer.ParentWMSList = this;
			wmsLayer.ImageFormats = imageFormats;

			if(layer.HasName())
				wmsLayer.Name = layer.Name.Value;

			if(layer.HasTitle())
				wmsLayer.Title = layer.Title.Value;

			if(layer.HasAbstract2())
				wmsLayer.Description = layer.Abstract2.Value;

			if(layer.HasCRS())
				wmsLayer.CRS = layer.CRS.Value;

			if(layer.HasfixedHeight())
				wmsLayer.Height = (uint)layer.fixedHeight.Value;

			if(layer.HasfixedWidth())
				wmsLayer.Width = (uint)layer.fixedWidth.Value;

			if(layer.HasDimension())
			{
				for(int i = layer.DimensionMinCount; i < layer.DimensionCount; i++)
				{
					capabilities_1_3_0.wms.DimensionType curDimension = layer.GetDimensionAt(i);
					if(curDimension.Hasname())
					{
						if(String.Compare(layer.Dimension.name.Value, "time", true,CultureInfo.InvariantCulture) == 0)	
						{
							wmsLayer.Dates = WMSList.GetDatesFromDateTimeString(curDimension.Value.Value);
							if(curDimension.Hasdefault2())
								wmsLayer.DefaultDate = curDimension.default2.Value;
						}
					}
				}
			}

			if(layer.HasEX_GeographicBoundingBox())
			{
				wmsLayer.North = (decimal)layer.EX_GeographicBoundingBox.northBoundLatitude.Value;
				wmsLayer.South = (decimal)layer.EX_GeographicBoundingBox.southBoundLatitude.Value;
				wmsLayer.East = (decimal)layer.EX_GeographicBoundingBox.eastBoundLongitude.Value;
				wmsLayer.West = (decimal)layer.EX_GeographicBoundingBox.westBoundLongitude.Value;
			}
			else if(parentLatLonBoundingBox != null)
			{
				wmsLayer.North = (decimal)parentLatLonBoundingBox.northBoundLatitude.Value;
				wmsLayer.South = (decimal)parentLatLonBoundingBox.southBoundLatitude.Value;
				wmsLayer.West = (decimal)parentLatLonBoundingBox.westBoundLongitude.Value;
				wmsLayer.East = (decimal)parentLatLonBoundingBox.eastBoundLongitude.Value;
			}

			if(layer.HasStyle())
			{
				wmsLayer.Styles = new WMSLayerStyle[layer.StyleCount];
				for(int i = layer.StyleMinCount; i < layer.StyleCount; i++)
				{
					capabilities_1_3_0.wms.StyleType curStyle = layer.GetStyleAt(i);
					
					wmsLayer.Styles[i] = new WMSLayerStyle();
					if(curStyle.HasAbstract2())
						wmsLayer.Styles[i].description = curStyle.Abstract2.Value;
					
					if(curStyle.HasName())
						wmsLayer.Styles[i].name = curStyle.Name.Value;

					if(curStyle.HasTitle())
						wmsLayer.Styles[i].title = curStyle.Title.Value;
					
					if(curStyle.HasLegendURL())
					{
						wmsLayer.Styles[i].legendURL = new WMSLayerStyleLegendURL[curStyle.LegendURLCount];
						
						for(int j = 0; j < curStyle.LegendURLCount; j++)
						{
							capabilities_1_3_0.wms.LegendURLType curLegend = curStyle.GetLegendURLAt(j);
							wmsLayer.Styles[i].legendURL[j] = new WMSLayerStyleLegendURL();
							if(curLegend.HasFormat())
								wmsLayer.Styles[i].legendURL[j].format = curLegend.Format.Value;

							if(curLegend.Haswidth())
								wmsLayer.Styles[i].legendURL[j].width = (int)curLegend.width.Value;

							if(curLegend.Hasheight())
								wmsLayer.Styles[i].legendURL[j].height = (int)curLegend.height.Value;

							if(curLegend.HasOnlineResource())
							{
								if(curLegend.OnlineResource.Hashref())
									wmsLayer.Styles[i].legendURL[j].href = curLegend.OnlineResource.href.Value;
							}	
						}
					}
				}
			}

			if(layer.HasLayer())
			{
				wmsLayer.ChildLayers = new MyWMSLayer[layer.LayerCount];
				for(int i = 0; i < layer.LayerCount; i++)
				{
					wmsLayer.ChildLayers[i] = this.getWMSLayer((capabilities_1_3_0.wms.LayerType)layer.GetLayerAt(i), parentLatLonBoundingBox, imageFormats);
				}
			}

			return wmsLayer;
		}
Пример #2
0
		private MyWMSLayer getWMSLayer(capabilities_1_1_1.LayerType layer, capabilities_1_1_1.LatLonBoundingBoxType parentLatLonBoundingBox, string[] imageFormats)
		{
			MyWMSLayer wmsLayer = new MyWMSLayer();
			wmsLayer.ParentWMSList = this;
			wmsLayer.ImageFormats = imageFormats;

			if(layer.HasName())
				wmsLayer.Name = layer.Name.Value;

			if(layer.HasTitle())
				wmsLayer.Title = layer.Title.Value;

			if(layer.HasAbstract2())
				wmsLayer.Description = layer.Abstract2.Value;

			if(layer.HasExtent())
			{
				for(int i = layer.ExtentMinCount; i < layer.ExtentCount; i++)
				{
					capabilities_1_1_1.ExtentType curExtent = layer.GetExtentAt(i);
					if(curExtent.Hasname())
					{
						if(String.Compare(curExtent.name.Value, "time", true) == 0)
						{
							wmsLayer.Dates = WMSList.GetDatesFromDateTimeString(curExtent.getDOMNode().InnerText);

							if(curExtent.Hasdefault2())
							{
								wmsLayer.DefaultDate = curExtent.default2.Value;
							}
						}
					}
				}
			}

			if(layer.HasLatLonBoundingBox())
			{
				wmsLayer.North = Decimal.Parse(layer.LatLonBoundingBox.maxy.Value, CultureInfo.InvariantCulture);
				wmsLayer.South = Decimal.Parse(layer.LatLonBoundingBox.miny.Value, CultureInfo.InvariantCulture);
				wmsLayer.West = Decimal.Parse(layer.LatLonBoundingBox.minx.Value, CultureInfo.InvariantCulture);
				wmsLayer.East = Decimal.Parse(layer.LatLonBoundingBox.maxx.Value, CultureInfo.InvariantCulture);
				parentLatLonBoundingBox = layer.LatLonBoundingBox;
			}
			else if(parentLatLonBoundingBox != null)
			{
				wmsLayer.North = Decimal.Parse(parentLatLonBoundingBox.maxy.Value, CultureInfo.InvariantCulture);
				wmsLayer.South = Decimal.Parse(parentLatLonBoundingBox.miny.Value, CultureInfo.InvariantCulture);
				wmsLayer.West = Decimal.Parse(parentLatLonBoundingBox.minx.Value, CultureInfo.InvariantCulture);
				wmsLayer.East = Decimal.Parse(parentLatLonBoundingBox.maxx.Value, CultureInfo.InvariantCulture);
			}

			if(layer.HasStyle())
			{
				wmsLayer.Styles = new WMSLayerStyle[layer.StyleCount];
				for(int i = 0; i < layer.StyleCount; i++)
				{
					capabilities_1_1_1.StyleType curStyle = layer.GetStyleAt(i);

					wmsLayer.Styles[i] = new WMSLayerStyle();
					
					if(curStyle.HasAbstract2())
						wmsLayer.Styles[i].description = curStyle.Abstract2.Value;
					
					if(curStyle.HasName())
						wmsLayer.Styles[i].name = curStyle.Name.Value;

					if(curStyle.HasTitle())
						wmsLayer.Styles[i].title = curStyle.Title.Value;
					
					if(curStyle.HasLegendURL())
					{
						wmsLayer.Styles[i].legendURL = new WMSLayerStyleLegendURL[curStyle.LegendURLCount];
						
						for(int j = 0; j < curStyle.LegendURLCount; j++)
						{
							capabilities_1_1_1.LegendURLType curLegend = curStyle.GetLegendURLAt(j);

							wmsLayer.Styles[i].legendURL[j] = new WMSLayerStyleLegendURL();
							if(curLegend.HasFormat())
								wmsLayer.Styles[i].legendURL[j].format = curLegend.Format.Value;

							if(curLegend.Haswidth())
								wmsLayer.Styles[i].legendURL[j].width = (int)curLegend.width.IntValue();

							if(curLegend.Hasheight())
								wmsLayer.Styles[i].legendURL[j].height = (int)curLegend.height.IntValue();

							if(curLegend.HasOnlineResource())
							{
								System.Xml.XmlNode n = curLegend.OnlineResource.getDOMNode();
								
								foreach(System.Xml.XmlAttribute attr in n.Attributes)
								{
									if(attr.Name.IndexOf("href") >= 0)
									{
										wmsLayer.Styles[i].legendURL[j].href = attr.InnerText;
									}
								}
							}	
						}
					}
				}
			}

			if(layer.HasLayer())
			{
				wmsLayer.ChildLayers = new MyWMSLayer[layer.LayerCount];
				for(int i = 0; i < layer.LayerCount; i++)
				{
					wmsLayer.ChildLayers[i] = this.getWMSLayer((capabilities_1_1_1.LayerType)layer.GetLayerAt(i), parentLatLonBoundingBox, imageFormats);
				}
			}

			return wmsLayer;
		}
Пример #3
0
		private void buttonPlay_Click(object sender, System.EventArgs e)
		{
			if(this.animationState == AnimationState.Play)
			{
				animationState = AnimationState.Pause;
				buttonPlay.ImageIndex = 4;
				return;
			}

			if(this.animationState == AnimationState.Pause)
			{
				animationState = AnimationState.Play;
				buttonPlay.ImageIndex = 2;
				animationTimer.Start();
				return;
			}

			if(this.animationState == AnimationState.Stop)
			{
				MyWMSLayer curLayer = this.getCurrentlySelectedWMSLayer();
				if(curLayer == null)
					return;

				WMSLayerStyle curStyle = this.getCurrentlySelectedWMSLayerStyle();
				if(curLayer.Dates == null)
					return;

				this.curLoadedLayer = curLayer;
				this.curLoadedStyle = curStyle;
				
				buttonLegend.Enabled = curLayer.HasLegend;

				if(this.comboBoxAnimationStartTime.SelectedIndex == -1 ||
					this.comboBoxAnimationEndTime.SelectedIndex == -1)
					return;

				if(this.comboBoxAnimationStartTime.SelectedIndex > this.comboBoxAnimationEndTime.SelectedIndex)
				{
					// Swap start and end
					int start = comboBoxAnimationEndTime.SelectedIndex;
					comboBoxAnimationEndTime.SelectedIndex = comboBoxAnimationStartTime.SelectedIndex;
					comboBoxAnimationStartTime.SelectedIndex = start;
				}

				if(this.treeViewTableOfContents.SelectedNode.Tag == null) 
					//wms layer not properly selected
					return;

				this.Reset();

				this.groupBoxAnimationTimeFrame.Enabled = false;
				this.groupBoxExtents.Enabled = false;
		
				for(int i = this.comboBoxAnimationStartTime.SelectedIndex; i <= this.comboBoxAnimationEndTime.SelectedIndex; i++)
				{
					WMSDownload wmsDownload = curLayer.GetWmsRequest(
						curLayer.Dates[i],
						curStyle,
						this.numericUpDownNorth.Value,
						this.numericUpDownSouth.Value,
						this.numericUpDownWest.Value,
						this.numericUpDownEast.Value,
						CacheDirectory);

					EnqueueDownload(wmsDownload);
				}

				buttonPlay.ImageIndex = 2;
				animationState = AnimationState.Play;
				animationTimer.Start();
			}
		}
Пример #4
0
		private string GetCurrentCacheFilePath(MyWMSLayer curLayer, WMSLayerStyle curStyle )
		{
			string parentWmsPath = Path.Combine( this.CacheDirectory, curLayer.ParentWMSList.Name );
			string layerPath = parentWmsPath;
			if(curLayer.Name!=null)
				layerPath = Path.Combine( parentWmsPath, curLayer.Name );
			if(curStyle != null)
				layerPath = Path.Combine( layerPath, curStyle.name );

			string dateString = "Default";
			if (this.comboBoxTime.SelectedIndex > -1)
				dateString = (string) this.comboBoxTime.Items[this.comboBoxTime.SelectedIndex]; 

			string fileName = dateString.Replace(":","");

			string cacheFilePath = Path.Combine( layerPath, fileName+ ".wwi" );
			return cacheFilePath;
		}
Пример #5
0
		private void buttonLoad_Click(object sender, System.EventArgs e)
		{
			MyWMSLayer curLayer = this.getCurrentlySelectedWMSLayer();
			if (curLayer==null || curLayer.Name == null)
				return;

			this.Reset();

			this.buttonLegend.Enabled = curLayer.HasLegend;
			string dateString = "";
			if(this.comboBoxTime.SelectedItem != null)
				dateString = (string)this.comboBoxTime.SelectedItem;

			WMSLayerStyle curStyle = this.getCurrentlySelectedWMSLayerStyle();

			WMSDownload wmsDownload = curLayer.GetWmsRequest( 
				dateString,
				curStyle,
				this.numericUpDownNorth.Value,
				this.numericUpDownSouth.Value,
				this.numericUpDownWest.Value,
				this.numericUpDownEast.Value,
				this.CacheDirectory);

			if(this.checkBoxLoadCache.Enabled && 
				this.checkBoxLoadCache.Checked &&
				File.Exists(wmsDownload.SavedFilePath + ".wwi") && 
				File.Exists(wmsDownload.SavedFilePath + ".dds"))
			{
				ImageLayerInfo imageLayerInfo = ImageLayerInfo.FromFile(wmsDownload.SavedFilePath + ".wwi");
				lock(this.animationFrames.SyncRoot)
				{
					this.animationFrames.Add(imageLayerInfo);
				}
			}
			else
			{
				EnqueueDownload(wmsDownload);
			}

			this.curLoadedLayer = curLayer;
			this.curLoadedStyle = curStyle;

			this.animationState = AnimationState.Single;
			this.animationTimer.Start();
		}
Пример #6
0
		private TreeNode getTreeNodeFromWMSLayer(MyWMSLayer layer)
		{
			TreeNode tn = new TreeNode(layer.Title);
			tn.Tag = layer;
			if(layer.ChildLayers != null)
			{
				foreach(MyWMSLayer childLayer in layer.ChildLayers)
				{
					tn.Nodes.Add(this.getTreeNodeFromWMSLayer(childLayer));
				}
			}
			else if(layer.Styles != null)
			{
				foreach(WMSLayerStyle curStyle in layer.Styles)
				{
					TreeNode styleNode = new TreeNode(curStyle.title);
					styleNode.Tag = curStyle;
					tn.Nodes.Add(styleNode);
				}
			}

			return tn;
		}