示例#1
0
		public void Init()
		{
			TestComponent sourceComponent = new TestComponent();
			ElementSet sourceElementSet = new ElementSet("SourceElementSet",
				"SourceElementSetID",ElementType.XYPoint,new SpatialReference("SourceRef"));
			
			TestComponent targetComponent = new TestComponent2();
			ElementSet targetElementSet = new ElementSet("TargetElementSet",
				"TargetElementSetID",ElementType.XYPoint,new SpatialReference("TargetRef"));

			ArrayList dataOperations = new ArrayList();
			dataOperations.Add(new DataOperation("dataOperation"));

			link1 = new Link(sourceComponent,sourceElementSet,new Quantity("SourceQuantity"),
				targetComponent,targetElementSet,new Quantity("TargetQuantity"),"Link description","Link1",
				dataOperations);
			link2 = new Link();
			link2.SourceComponent = sourceComponent;
			link2.SourceElementSet = sourceElementSet;
			link2.SourceQuantity = new Quantity("SourceQuantity");
			link2.TargetComponent = targetComponent;
			link2.TargetElementSet = targetElementSet;
			link2.TargetQuantity = new Quantity("TargetQuantity");
			link2.Description = "Link description";
			link2.ID = "Link2";
			link2.AddDataOperation(new DataOperation("dataOperation"));
		}
        public override void Initialize(IArgument[] properties)
        {
            SendEvent(new Event(EventType.Informative, this, "Started initialization.."));
            Dictionary<string, string> arguments = new Dictionary<string, string>();
            for (int i = 0; i < properties.Length; i++)
            {
                arguments.Add(properties[i].Key, properties[i].Value);
            }
            filename = arguments["Filename"];
            outputFilename = arguments["OutputFilename"];

            tsGroup = TimeSeriesGroupFactory.Create(filename);

            foreach (BaseTimeSeries baseTimeSeries in tsGroup.Items)
            {
                HydroNumerics.OpenMI.Sdk.Backbone.Dimension dimention = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                dimention.AmountOfSubstance = baseTimeSeries.Unit.Dimension.AmountOfSubstance;
                dimention.Currency = baseTimeSeries.Unit.Dimension.Currency;
                dimention.ElectricCurrent = baseTimeSeries.Unit.Dimension.ElectricCurrent;
                dimention.Length = baseTimeSeries.Unit.Dimension.Length;
                dimention.LuminousIntensity = baseTimeSeries.Unit.Dimension.LuminousIntensity;
                dimention.Mass = baseTimeSeries.Unit.Dimension.Mass;
                dimention.Time = baseTimeSeries.Unit.Dimension.Time;

                HydroNumerics.OpenMI.Sdk.Backbone.Unit unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit();
                unit.ID = baseTimeSeries.Unit.ID;
                unit.Description = baseTimeSeries.Unit.Description;
                unit.ConversionFactorToSI = baseTimeSeries.Unit.ConversionFactorToSI;
                unit.OffSetToSI = baseTimeSeries.Unit.OffSetToSI;

                TsQuantity quantity = new TsQuantity();
                quantity.ID = baseTimeSeries.Name;
                quantity.Description = baseTimeSeries.Description;
                quantity.Dimension = dimention;
                quantity.Unit = unit;
                quantity.BaseTimeSeries = baseTimeSeries;

                ElementSet elementSet = new ElementSet();
                elementSet.ID = "IDBased";
                elementSet.Description = "IDBased";
                elementSet.ElementType = global::OpenMI.Standard.ElementType.IDBased;
                elementSet.SpatialReference = new SpatialReference("Undefined");
                Element element = new Element();
                element.ID = "IDBased";
                elementSet.AddElement(element);

                OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
                outputExchangeItem.Quantity = quantity;
                outputExchangeItem.ElementSet = elementSet;
                this.AddOutputExchangeItem(outputExchangeItem);

                InputExchangeItem inputExchangeItem = new InputExchangeItem();
                inputExchangeItem.Quantity = quantity;
                inputExchangeItem.ElementSet = elementSet;
                this.AddInputExchangeItem(inputExchangeItem);
            }

            initializeWasInvoked = true;
            SendEvent(new Event(EventType.Informative, this, "Completed initialization"));
        }
		public void Init()
		{
			exchangeItem = new ExchangeItem();
			exchangeItem.Quantity = new Quantity("Q");
			ElementSet elementSet = new ElementSet();
			elementSet.ID = "ES";
			exchangeItem.ElementSet = elementSet;
		}
		public void Constructor()
		{
			Assert.AreEqual("ElementSet",elementSet.Description);
			Assert.AreEqual("ElementSetID",elementSet.ID);
			Assert.AreEqual(ElementType.XYPolygon,elementSet.ElementType);
			Assert.AreEqual(new SpatialReference("ReferenceID"),elementSet.SpatialReference);

			ElementSet elementSet2 = new ElementSet(elementSet);
			Assert.AreEqual(elementSet,elementSet2);
		}
		public override IOutputExchangeItem GetOutputExchangeItem(int outputExchangeItemIndex)
		{
			Quantity quantity = new Quantity(new Unit("literprSecond",0.001,0,"lprsec"),"flow","flow", global::OpenMI.Standard.ValueType.Scalar,new Dimension());
			ElementSet elementSet = new ElementSet("oo","ID",ElementType.IDBased,new SpatialReference("no"));
			Element element = new Element("ElementID");
			elementSet.AddElement(element);
			OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
			outputExchangeItem.ElementSet = elementSet;
			outputExchangeItem.Quantity   = quantity;

			return outputExchangeItem;
		}
    public void ExpectedException_1_Vertex_in_PolylineElement()
    {
        try
        {
            //One Vertex in polyline element error
            ElementSet elementSet = new ElementSet("test", "test", ElementType.XYPolyLine, new SpatialReference("DummyID"));
            HydroNumerics.OpenMI.Sdk.Backbone.Element e1 = new HydroNumerics.OpenMI.Sdk.Backbone.Element("e1");
            e1.AddVertex(new Vertex(1, 1, 1));

            elementSet.AddElement(e1);

            ElementSetChecker.CheckElementSet(elementSet);
        }
        catch (Exception ex)
        {
            Assert.IsTrue(ex.GetType() == typeof(Exception));
        }
    }
		public void Init()
		{
			eventSent = false;
			testComponent1 = new TestComponent();

			testComponent2 = new TestComponent2();

			Link link1 = new Link();
			link1.ID ="Link1";
			link1.SourceComponent = testComponent1;
			link1.TargetComponent = testComponent2;
			Link link2 = new Link();
			link2.ID ="Link2";
			link2.SourceComponent = testComponent2;
			link2.TargetComponent = testComponent1;
			Link link3 = new Link();
			link3.ID = "Link3";
			link3.SourceComponent = link3.TargetComponent = testComponent1;

			testComponent1.AddLink(link1);
			testComponent1.AddLink(link2);
			testComponent1.AddLink(link3);
			testComponent2.AddLink(link1);
			testComponent2.AddLink(link2);
			testComponent1.RemoveLink("Link3");

			testComponent1.Subscribe(this,EventType.Informative);

			Quantity q = new Quantity("Q");
			ElementSet elementSet = new ElementSet();
			elementSet.ID = "ES";

			InputExchangeItem inputExchangeItem = new InputExchangeItem();
			inputExchangeItem.Quantity = q;
			inputExchangeItem.ElementSet = elementSet;
			testComponent1.AddInputExchangeItem(inputExchangeItem);

			OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
			outputExchangeItem.Quantity = new Quantity("Q2");
			ElementSet elementSet2 = new ElementSet();
			elementSet2.ID = "ES2";
			outputExchangeItem.ElementSet = elementSet;
			testComponent1.AddOutputExchangeItem(outputExchangeItem);
		}
		public void Init() 
		{
			elementSet = new ElementSet("ElementSet","ElementSetID",
				ElementType.XYPolygon,new SpatialReference("ReferenceID"));
			element1 = new Element("element1");
			element1.AddVertex(new Vertex(1.0,2.0,3.0));
			element1.AddVertex(new Vertex(2.0,3.0,4.0));
			element1.AddVertex(new Vertex(4.0,5.0,6.0));
			int[] index = {1,2,3,4,5};
			element1.AddFace(index);
			elementSet.AddElement(element1);
			element2 = new Element("element2");
			element2.AddVertex(new Vertex(6.0,7.0,8.0));
			element2.AddVertex(new Vertex(9.0,10.0,11.0));
			element2.AddVertex(new Vertex(12.0,13.0,14.0));
			int[] index2 = {6,7,8,9};
			element2.AddFace(index2);
			elementSet.AddElement(element2);	
		}
		public void Equals()
		{
			ExchangeItem exchangeItem = new ExchangeItem();
			exchangeItem.Quantity = new Quantity("Q");
			ElementSet elementSet = new ElementSet();
			elementSet.ID = "ES";
			exchangeItem.ElementSet = elementSet;

			Assert.IsTrue(exchangeItem.Equals(this.exchangeItem));

			exchangeItem.Quantity = new Quantity("Q1");
			Assert.IsFalse(exchangeItem.Equals(this.exchangeItem));
			exchangeItem.Quantity = new Quantity("Q");
			elementSet.ID = "ES2";

			Assert.IsFalse(exchangeItem.Equals(this.exchangeItem));
			Assert.IsFalse(exchangeItem.Equals(null));
			Assert.IsFalse(exchangeItem.Equals("string"));
		}
		public void ExpectedException_2_Vertices_in_PointElement()
		{
            try
            {
                //Two Vertices in point element error
                ElementSet elementSet = new ElementSet("test", "test", ElementType.XYPoint, new SpatialReference("DummyID"));
                HydroNumerics.OpenMI.Sdk.Backbone.Element e1 = new HydroNumerics.OpenMI.Sdk.Backbone.Element("e1");
                e1.AddVertex(new Vertex(1, 1, 1));
                e1.AddVertex(new Vertex(2, 2, 2)); //here the error is introduced on purpose

                elementSet.AddElement(e1);

                ElementSetChecker.CheckElementSet(elementSet);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.GetType() == typeof(Exception));
            }
		
		}
示例#11
0
        public void MyTestInitialize()
        {
            elementSet = new ElementSet("ElementSet", "ElementSetID", ElementType.Polygon);

            element1 = new Element("element1");
            element1.AddVertex(new Coordinate(1.0, 2.0, 3.0));
            element1.AddVertex(new Coordinate(2.0, 3.0, 4.0));
            element1.AddVertex(new Coordinate(4.0, 5.0, 6.0));
            int[] index = { 1, 2, 3, 4, 5 };
            element1.AddFace(index);
            elementSet.AddElement(element1);

            element2 = new Element("element2");
            element2.AddVertex(new Coordinate(6.0, 7.0, 8.0));
            element2.AddVertex(new Coordinate(9.0, 10.0, 11.0));
            element2.AddVertex(new Coordinate(12.0, 13.0, 14.0));
            int[] index2 = { 6, 7, 8, 9 };
            element2.AddFace(index2);
            elementSet.AddElement(element2);
        }
        [TestMethod()] // testing the Initialise method
		public void MapValues()
		{
			ElementSet gridElementSet = new ElementSet("RegularGrid","RegularGrid",ElementType.XYPolygon, new SpatialReference("ref"));
			ElementSet fourPointsElementSet = new ElementSet("4 points","4P",ElementType.XYPoint,new SpatialReference("DummyID")); 

			Vertex v_0_20  = new Vertex(0,20,0);
			Vertex v_0_10  = new Vertex(0,10,0);
			Vertex v_0_0   = new Vertex(0, 0,0);
			Vertex v_0_15  = new Vertex(0,15,0);
			Vertex v_5_15  = new Vertex(5,15,0);
			Vertex v_10_20 = new Vertex(10,20,0);
			Vertex v_10_15 = new Vertex(10,15,0);
			Vertex v_10_10 = new Vertex(10,10,0);
			Vertex v_10_0  = new Vertex(10, 0,0);
			Vertex v_15_15 = new Vertex(15,15,0);
			Vertex v_15_5  = new Vertex(15,5,0);
			Vertex v_20_20 = new Vertex(20,20,0);
			Vertex v_20_10 = new Vertex(20,10,0);

			Element square1 = new Element("square1");
			Element square2 = new Element("square2");
			Element square3 = new Element("square3");

			square1.AddVertex(v_0_20);
			square1.AddVertex(v_0_10);
			square1.AddVertex(v_10_10);
			square1.AddVertex(v_10_20);

			square2.AddVertex(v_10_20);
			square2.AddVertex(v_10_10);
			square2.AddVertex(v_20_10);
			square2.AddVertex(v_20_20);

			square3.AddVertex(v_0_10);
			square3.AddVertex(v_0_0);
			square3.AddVertex(v_10_0);
			square3.AddVertex(v_10_10);

			gridElementSet.AddElement(square1);
			gridElementSet.AddElement(square2);
			gridElementSet.AddElement(square3);

			Element point_5_15  = new Element("point 5, 15");
			Element point_10_15 = new Element("point 10, 15");
			Element point_15_15 = new Element("point 15, 15");
			Element point_15_5  = new Element("point 15, 5");

			point_5_15.AddVertex(v_5_15);
			point_10_15.AddVertex(v_10_15);
			point_15_15.AddVertex(v_15_15);
			point_15_5.AddVertex(v_15_5);

			fourPointsElementSet.AddElement(point_5_15);
			fourPointsElementSet.AddElement(point_10_15);
			fourPointsElementSet.AddElement(point_15_15);
			fourPointsElementSet.AddElement(point_15_5);
			ScalarSet fourPointsScalarSet = new ScalarSet();
			ScalarSet gridScalarSet = new ScalarSet();      
      
			ElementMapper elementMapper = new ElementMapper();
      
			// point to polygon  
      
			ArrayList methodDescriptions = elementMapper.GetAvailableMethods(fourPointsElementSet.ElementType, gridElementSet.ElementType);
			elementMapper.Initialise(methodDescriptions[0].ToString(), fourPointsElementSet, gridElementSet);
			fourPointsScalarSet.data = new double[4] { 0, 10, 20, 30 };
			gridScalarSet = (ScalarSet)elementMapper.MapValues(fourPointsScalarSet);
			Assert.AreEqual(5, gridScalarSet.data[0]);
			Assert.AreEqual(20, gridScalarSet.data[1]);
			Assert.AreEqual(0, gridScalarSet.data[2]);
			// polygon to point
			methodDescriptions = elementMapper.GetAvailableMethods(gridElementSet.ElementType, fourPointsElementSet.ElementType);
			elementMapper.Initialise(methodDescriptions[0].ToString(), gridElementSet, fourPointsElementSet);
			fourPointsScalarSet = (ScalarSet)elementMapper.MapValues(gridScalarSet);
			Assert.AreEqual(5, fourPointsScalarSet.data[0]);
			Assert.AreEqual(5, fourPointsScalarSet.data[1]);
			Assert.AreEqual(20, fourPointsScalarSet.data[2]);
			Assert.AreEqual(0, fourPointsScalarSet.data[3]);
		}
        [TestMethod()] // testing the Initialise method
		public void UpdateMappingMatrix_PolygonPolygon()
		{
			Vertex v1_0_10  = new Vertex(0,10,0);
			Vertex v1_0_0   = new Vertex(0,0,0);
			Vertex v1_10_0  = new Vertex(10,0,0);
			Vertex v1_10_10 = new Vertex(10,10,0);
			Vertex v1_20_0  = new Vertex(20,0,0);
			Vertex v1_20_10 = new Vertex(20,10,0);
			Vertex v1_5_9   = new Vertex(5,9,0);
			Vertex v1_5_1   = new Vertex(5,1,0);
			Vertex v1_15_5  = new Vertex(15,5,0);

			Element LeftSquare  = new Element("LeftSquare");
			LeftSquare.AddVertex(v1_0_10);
			LeftSquare.AddVertex(v1_0_0);
			LeftSquare.AddVertex(v1_10_0);
			LeftSquare.AddVertex(v1_10_10);
      
			Element RightSquare = new Element("RightSquare");
			RightSquare.AddVertex(v1_10_10);
			RightSquare.AddVertex(v1_10_0);
			RightSquare.AddVertex(v1_20_0);
			RightSquare.AddVertex(v1_20_10);

			Element Triangle    = new Element("Triangle");
			Triangle.AddVertex(v1_5_9);
			Triangle.AddVertex(v1_5_1);
			Triangle.AddVertex(v1_15_5);

			ElementSet TwoSquareElementSet      = new ElementSet("TwoSquareElementSet","TwoSquareElementSet",ElementType.XYPolygon,new SpatialReference("ref"));
			ElementSet TriangleElementSet       = new ElementSet("TriangleElementSet","TriangleElementSet",ElementType.XYPolygon,new SpatialReference("ref"));
			TwoSquareElementSet.AddElement(LeftSquare);
			TwoSquareElementSet.AddElement(RightSquare);
			TriangleElementSet.AddElement(Triangle);
      
			ElementMapper elementMapper = new ElementMapper();
			ArrayList methodDescriptions = elementMapper.GetAvailableMethods(TwoSquareElementSet.ElementType, TriangleElementSet.ElementType);
			elementMapper.Initialise(methodDescriptions[0].ToString(), TriangleElementSet,  TwoSquareElementSet);
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(0, 0),"Test1");
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(1, 0),"Test2");
      
			elementMapper.Initialise(methodDescriptions[0].ToString(), TwoSquareElementSet, TriangleElementSet);
			Assert.AreEqual(0.75, elementMapper.GetValueFromMappingMatrix(0, 0),0.000000001,"Test3");
			Assert.AreEqual(0.25, elementMapper.GetValueFromMappingMatrix(0, 1),"Test4");
	      
			elementMapper.Initialise(methodDescriptions[1].ToString(), TriangleElementSet,  TwoSquareElementSet);
			Assert.AreEqual(0.3, elementMapper.GetValueFromMappingMatrix(0, 0),"Test5");
			Assert.AreEqual(0.1, elementMapper.GetValueFromMappingMatrix(1, 0),"Test6");
	    
			elementMapper.Initialise(methodDescriptions[1].ToString(), TwoSquareElementSet, TriangleElementSet);
			Assert.AreEqual(0.75, elementMapper.GetValueFromMappingMatrix(0, 0),0.0000000001,"Test7");
			Assert.AreEqual(0.25, elementMapper.GetValueFromMappingMatrix(0, 1),"Test8");
      
			Vertex v2_0_2 = new Vertex(0,2,0);
			Vertex v2_0_0 = new Vertex(0,0,0);
			Vertex v2_2_0 = new Vertex(2,0,0);
			Vertex v2_1_2 = new Vertex(1,2,0);
			Vertex v2_1_0 = new Vertex(1,0,0);
			Vertex v2_3_0 = new Vertex(3,0,0);

			Element LeftTriangle2  = new Element("LeftTriangle");
			LeftTriangle2.AddVertex(v2_0_2);
			LeftTriangle2.AddVertex(v2_0_0);
			LeftTriangle2.AddVertex(v2_2_0);

			Element RightTriangle2  = new Element("RightTriangle");
			RightTriangle2.AddVertex(v2_1_2);
			RightTriangle2.AddVertex(v2_1_0);
			RightTriangle2.AddVertex(v2_3_0);
      
			ElementSet LeftTriangleElementSet2      = new ElementSet("TwoSquareElementSet","TwoSquareElementSet",ElementType.XYPolygon,new SpatialReference("ref"));
			ElementSet RightTriangleElementSet2       = new ElementSet("TriangleElementSet","TriangleElementSet",ElementType.XYPolygon,new SpatialReference("ref"));
			LeftTriangleElementSet2.AddElement(LeftTriangle2);
			RightTriangleElementSet2.AddElement(RightTriangle2);

      
			elementMapper.Initialise(methodDescriptions[0].ToString(), LeftTriangleElementSet2, RightTriangleElementSet2);
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(0, 0),"Test9");

			elementMapper.Initialise(methodDescriptions[0].ToString(), RightTriangleElementSet2, LeftTriangleElementSet2);
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(0, 0),"Test10");
      
			elementMapper.Initialise(methodDescriptions[1].ToString(), LeftTriangleElementSet2, RightTriangleElementSet2);
			Assert.AreEqual(0.25, elementMapper.GetValueFromMappingMatrix(0, 0),"Test11");

			elementMapper.Initialise(methodDescriptions[1].ToString(), RightTriangleElementSet2, LeftTriangleElementSet2);
			Assert.AreEqual(0.25, elementMapper.GetValueFromMappingMatrix(0, 0),"Test12");
      
			Vertex v3_0_2 = new Vertex(0,2,0);
			Vertex v3_0_0 = new Vertex(0,0,0);
			Vertex v3_2_0 = new Vertex(2,0,0);
			Vertex v3_1_2 = new Vertex(1,2,0);
			Vertex v3_1_0 = new Vertex(1,0,0);
			Vertex v3_3_2 = new Vertex(3,2,0);
    
			Element LeftTriangle3  = new Element("LeftTriangle");
			LeftTriangle3.AddVertex(v3_0_2);
			LeftTriangle3.AddVertex(v3_0_0);
			LeftTriangle3.AddVertex(v3_2_0);

			Element RightTriangle3  = new Element("RightTriangle");
			RightTriangle3.AddVertex(v3_1_2);
			RightTriangle3.AddVertex(v3_1_0);
			RightTriangle3.AddVertex(v3_3_2);
      
			ElementSet LeftTriangleElementSet3      = new ElementSet("TwoSquareElementSet","TwoSquareElementSet",ElementType.XYPolygon,new SpatialReference("ref"));
			ElementSet RightTriangleElementSet3       = new ElementSet("TriangleElementSet","TriangleElementSet",ElementType.XYPolygon,new SpatialReference("ref"));
			LeftTriangleElementSet3.AddElement(LeftTriangle3);
			RightTriangleElementSet3.AddElement(RightTriangle3);

			elementMapper.Initialise(methodDescriptions[0].ToString(), LeftTriangleElementSet3, RightTriangleElementSet3);
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(0, 0),"Test13");

			elementMapper.Initialise(methodDescriptions[0].ToString(), RightTriangleElementSet3, LeftTriangleElementSet3);
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(0, 0),"Test14");
      
			elementMapper.Initialise(methodDescriptions[1].ToString(), LeftTriangleElementSet3, RightTriangleElementSet3);
			Assert.AreEqual(0.125, elementMapper.GetValueFromMappingMatrix(0, 0),"Test15");

			elementMapper.Initialise(methodDescriptions[1].ToString(), RightTriangleElementSet3, LeftTriangleElementSet3);
			Assert.AreEqual(0.125, elementMapper.GetValueFromMappingMatrix(0, 0),"Test16");
		}
        [TestMethod()] // testing the Initialise method
    public void UpdateMappingMatrix_LinePolygon()
    {
      ElementSet twoSquaresGrid = new ElementSet("TwoSquaresGrid", "TwoSquaresGrid", ElementType.XYPolygon, new SpatialReference("ref"));

      Element e1 = new Element("e1");
      Element e2 = new Element("e2");

      e1.AddVertex(new Vertex(1, 1, 0));
      e1.AddVertex(new Vertex(3, 1, 0));
      e1.AddVertex(new Vertex(3, 3, 0));
      e1.AddVertex(new Vertex(1, 3, 0));

      e2.AddVertex(new Vertex(3, 1, 0));
      e2.AddVertex(new Vertex(5, 1, 0));
      e2.AddVertex(new Vertex(5, 3, 0));
      e2.AddVertex(new Vertex(3, 3, 0));

      twoSquaresGrid.AddElement(e1);
      twoSquaresGrid.AddElement(e2);

      ElementSet twoLines = new ElementSet("TwoLines", "TwoLines", ElementType.XYLine, new SpatialReference("ref"));

      Element l1 = new Element("l1");
      Element l2 = new Element("l2");

      l1.AddVertex(new Vertex(0, 2.5, 0));
      l1.AddVertex(new Vertex(2, 2.5, 0));
      l2.AddVertex(new Vertex(2, 2.5, 0));
      l2.AddVertex(new Vertex(4, 1.5, 0));

      twoLines.AddElement(l1);
      twoLines.AddElement(l2);

      // Line to Polygon
      ElementMapper elementMapper = new ElementMapper();
      ArrayList methodDescriptions = elementMapper.GetAvailableMethods(twoLines.ElementType, twoSquaresGrid.ElementType);
      elementMapper.Initialise(methodDescriptions[0].ToString(), twoLines, twoSquaresGrid);
      Assert.AreEqual(1 / (1 + Math.Sqrt(1 + Math.Pow(0.5, 2))), elementMapper.GetValueFromMappingMatrix(0, 0), "Test1");
      Assert.AreEqual(1 - 1 / (1 + Math.Sqrt(1 + Math.Pow(0.5, 2))), elementMapper.GetValueFromMappingMatrix(0, 1), "Test2");
      Assert.AreEqual(0.0, elementMapper.GetValueFromMappingMatrix(1, 0), "Test3");
      Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(1, 1), "Test4");

      elementMapper.Initialise(methodDescriptions[1].ToString(), twoLines, twoSquaresGrid);
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(0, 0), "Test5");
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(0, 1), "Test6");
      Assert.AreEqual(0.0, elementMapper.GetValueFromMappingMatrix(1, 0), "Test7");
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(1, 1), "Test8");

      // Polygon To PolyLine
      methodDescriptions = elementMapper.GetAvailableMethods(twoSquaresGrid.ElementType, twoLines.ElementType);
      elementMapper.Initialise(methodDescriptions[0].ToString(), twoSquaresGrid, twoLines);
      Assert.AreEqual(1.0, elementMapper.GetValueFromMappingMatrix(0, 0), "Test9");
      Assert.AreEqual(0.0, elementMapper.GetValueFromMappingMatrix(0, 1), "Test10");
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(1, 0), "Test11");
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(1, 1), "Test12");

      elementMapper.Initialise(methodDescriptions[1].ToString(), twoSquaresGrid, twoLines);
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(0, 0), "Test13");
      Assert.AreEqual(0.0, elementMapper.GetValueFromMappingMatrix(0, 1), "Test14");
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(1, 0), "Test15");
      Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(1, 1), "Test16");
    }
		private ElementSet CreateElementSet(string ElementSetID)
		{
			if (ElementSetID == "4 Points")
			{
				ElementSet fourPointsElementSet = new ElementSet("4 points","4 Points",ElementType.XYPoint,new SpatialReference("DummyID")); 
		
				Element e0 = new Element("e0"); 
				Element e1 = new Element("e1"); 
				Element e2 = new Element("e2");
				Element e3 = new Element("e3"); 
		
				e0.AddVertex(new Vertex( 0,100,0));
				e1.AddVertex(new Vertex( 0,0,0));
				e2.AddVertex(new Vertex( 100,0,0));
				e3.AddVertex(new Vertex(100,100,0));

				fourPointsElementSet.AddElement(e0);
				fourPointsElementSet.AddElement(e1);
				fourPointsElementSet.AddElement(e2);
				fourPointsElementSet.AddElement(e3);

				return fourPointsElementSet;
			}
			else if (ElementSetID == "2 Points")
			{
				ElementSet twoPointsElementSet = new ElementSet("2 points","2 Points",ElementType.XYPoint,new SpatialReference("dumID")); 

				Element k0 = new Element("k0"); 
				Element k1 = new Element("k1"); 

				k0.AddVertex(new Vertex( 0,75,0));
				k1.AddVertex(new Vertex( 200, 50, 0));

				twoPointsElementSet.AddElement(k0);
				twoPointsElementSet.AddElement(k1);

				return twoPointsElementSet;

			}
			else if (ElementSetID == "4 Other Points")
			{
				ElementSet fourPointsElementSet = new ElementSet("4 Other points","4 Other Points",ElementType.XYPoint,new SpatialReference("DummyID")); 
		
				Element e0 = new Element("e0"); 
				Element e1 = new Element("e1"); 
				Element e2 = new Element("e2");
				Element e3 = new Element("e3"); 
		
				e0.AddVertex(new Vertex( 0,15,0));
				e1.AddVertex(new Vertex( 5,15,0));
				e2.AddVertex(new Vertex( 0,10,0));
				e3.AddVertex(new Vertex(10,10,0));

				fourPointsElementSet.AddElement(e0);
				fourPointsElementSet.AddElement(e1);
				fourPointsElementSet.AddElement(e2);
				fourPointsElementSet.AddElement(e3);

				return fourPointsElementSet;
			}
			else if(ElementSetID == "3 points polyline")
			{
				ElementSet lineElementSet = new ElementSet("3 points polyline","3 points polyline",ElementType.XYPolyLine,new SpatialReference("dumID")); 

				Element l0 = new Element("k0"); 
				Element l1 = new Element("k1");
 
				Vertex v0 = new Vertex(0 ,20, 0);
				Vertex v1 = new Vertex(0 ,10, 0);
				Vertex v2 = new Vertex(0 , 0, 0);

				l0.AddVertex(v0);
				l0.AddVertex(v2);

				l1.AddVertex(v1);
				l1.AddVertex(v2);

				lineElementSet.AddElement(l0);
				lineElementSet.AddElement(l1);
				return lineElementSet;
			}
      else if (ElementSetID == "2 element XYline ElementSet")
      {
        ElementSet lineElementSet = new ElementSet("2 element XYline ElementSet", "2 element XYline ElementSet", ElementType.XYLine, new SpatialReference("dumID"));

        Element l0 = new Element("k0");
        Element l1 = new Element("k1");

        Vertex v0 = new Vertex(0, 20, 0);
        Vertex v1 = new Vertex(0, 10, 0);
        Vertex v2 = new Vertex(0, 0, 0);

        l0.AddVertex(v0);
        l0.AddVertex(v2);

        l1.AddVertex(v1);
        l1.AddVertex(v2);

        lineElementSet.AddElement(l0);
        lineElementSet.AddElement(l1);
        return lineElementSet;
      }
			else
			{
				throw new Exception("Cound not find specified elementset");
			
			}
		}
        [TestMethod()] // testing the Initialise method
		public void UpdateMappingMatrix_PointPolygon()
		{
			ElementSet gridElementSet = new ElementSet("gridElm","G1",ElementType.XYPolygon, new SpatialReference("ref"));
			ElementSet fourPointsElementSet = new ElementSet("4 points","4P",ElementType.XYPoint,new SpatialReference("DummyID")); 

			Vertex v_0_20  = new Vertex(0,20,0);
			Vertex v_0_10  = new Vertex(0,10,0);
			Vertex v_0_0   = new Vertex(0, 0,0);
			Vertex v_0_15  = new Vertex(0,15,0);
			Vertex v_5_15  = new Vertex(5,15,0);
			Vertex v_10_20 = new Vertex(10,20,0);
			Vertex v_10_15 = new Vertex(10,15,0);
			Vertex v_10_10 = new Vertex(10,10,0);
			Vertex v_10_0  = new Vertex(10, 0,0);
			Vertex v_15_15 = new Vertex(15,15,0);
			Vertex v_15_5  = new Vertex(15,5,0);
			Vertex v_20_20 = new Vertex(20,20,0);
			Vertex v_20_10 = new Vertex(20,10,0);

			Element square1 = new Element("square1");
			Element square2 = new Element("square2");
			Element square3 = new Element("square3");

			square1.AddVertex(v_0_20);
			square1.AddVertex(v_0_10);
			square1.AddVertex(v_10_10);
			square1.AddVertex(v_10_20);

			square2.AddVertex(v_10_20);
			square2.AddVertex(v_10_10);
			square2.AddVertex(v_20_10);
			square2.AddVertex(v_20_20);

			square3.AddVertex(v_0_10);
			square3.AddVertex(v_0_0);
			square3.AddVertex(v_10_0);
			square3.AddVertex(v_10_10);

			gridElementSet.AddElement(square1);
			gridElementSet.AddElement(square2);
			gridElementSet.AddElement(square3);

			Element point_5_15  = new Element("point 5, 15");
			Element point_10_15 = new Element("point 10, 15");
			Element point_15_15 = new Element("point 15, 15");
			Element point_15_5  = new Element("point 15, 5");

			point_5_15.AddVertex(v_5_15);
			point_10_15.AddVertex(v_10_15);
			point_15_15.AddVertex(v_15_15);
			point_15_5.AddVertex(v_15_5);

			fourPointsElementSet.AddElement(point_5_15);
			fourPointsElementSet.AddElement(point_10_15);
			fourPointsElementSet.AddElement(point_15_15);
			fourPointsElementSet.AddElement(point_15_5);
        
			ElementMapper elementMapper = new ElementMapper();
      
			// point to polygon
      
			ArrayList methodDescriptions = elementMapper.GetAvailableMethods(fourPointsElementSet.ElementType, gridElementSet.ElementType);
			elementMapper.Initialise(methodDescriptions[0].ToString(), fourPointsElementSet, gridElementSet);
			Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(0, 0));
			Assert.AreEqual(0.5, elementMapper.GetValueFromMappingMatrix(0, 1));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(0, 2));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(0, 3));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(1, 0));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(1, 1));
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(1, 2));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(1, 3));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(2, 0));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(2, 1));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(2, 2));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(2, 3));

			// polygon to point
			methodDescriptions = elementMapper.GetAvailableMethods(gridElementSet.ElementType, fourPointsElementSet.ElementType);
			elementMapper.Initialise(methodDescriptions[0].ToString(), gridElementSet, fourPointsElementSet);
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(0, 0));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(0, 1));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(0, 2));
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(1, 0));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(1, 1));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(1, 2));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(2, 0));
			Assert.AreEqual(1, elementMapper.GetValueFromMappingMatrix(2, 1));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(2, 2));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(3, 0));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(3, 1));
			Assert.AreEqual(0, elementMapper.GetValueFromMappingMatrix(3, 2));
		}
示例#17
0
        public void EqualsVertices()
        {
            ElementSet elementSet1 = new ElementSet("ElementSet", "ElementSetID", ElementType.Polygon);
            element1 = new Element("element1");
            element1.AddVertex(new Coordinate(1.1, 2.0, 3.0));
            element1.AddVertex(new Coordinate(2.0, 3.0, 4.0));
            element1.AddVertex(new Coordinate(4.0, 5.0, 6.0));
            elementSet1.AddElement(element1);
            element2 = new Element("element2");
            element2.AddVertex(new Coordinate(6.0, 7.0, 8.0));
            element2.AddVertex(new Coordinate(9.0, 10.0, 11.0));
            element2.AddVertex(new Coordinate(12.0, 13.0, 14.0));
            elementSet1.AddElement(element2);

            Assert.IsFalse(elementSet.Equals(elementSet1));
        }
		public void ExpectexException_UpdateMappingMatrix_ElementChecker()
		{
            try
            {
                //Two Vertices in point element error
                ElementSet elementSet = new ElementSet("test", "test", ElementType.XYPoint, new SpatialReference("DummyID"));
                Element e1 = new Element("e1");
                e1.AddVertex(new Vertex(1, 1, 1));
                e1.AddVertex(new Vertex(2, 2, 2)); //here the error is introduced on purpose

                elementSet.AddElement(e1);

                ElementMapper elementMapper = new ElementMapper();
                string method = (string)elementMapper.GetAvailableMethods(ElementType.XYPolyLine, ElementType.XYPolygon)[0];
                elementMapper.UpdateMappingMatrix(method, elementSet, elementSet);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.GetType() == typeof(Exception));
            }

		}
示例#19
0
		public void EqualsVertices()
		{
			ElementSet elementSet1 = new ElementSet("ElementSet","ElementSetID",
				ElementType.XYPolygon,new SpatialReference("ReferenceID"));
			element1 = new Element("element1");
			element1.AddVertex(new Vertex(1.1,2.0,3.0));
			element1.AddVertex(new Vertex(2.0,3.0,4.0));
			element1.AddVertex(new Vertex(4.0,5.0,6.0));
			elementSet1.AddElement(element1);
			element2 = new Element("element2");
			element2.AddVertex(new Vertex(6.0,7.0,8.0));
			element2.AddVertex(new Vertex(9.0,10.0,11.0));
			element2.AddVertex(new Vertex(12.0,13.0,14.0));
			elementSet1.AddElement(element2);


			Assert.IsFalse(elementSet.Equals(elementSet1));
		}
		public void Initialize(System.Collections.Hashtable properties)
		{

			if (properties.ContainsKey("ModelID"))
			{
				_modelID = (string) properties["ModelID"];
			}

			if (properties.ContainsKey("TimeStepLength"))
			{
				_timeStepLength = Convert.ToDouble((string) properties["TimeStepLength"]);
			}

			// -- create a flow quanitity --
			Dimension flowDimension = new Dimension();
			flowDimension.SetPower(DimensionBase.Length,3);
			flowDimension.SetPower(DimensionBase.Time,-1);
			Unit literPrSecUnit = new Unit("LiterPrSecond",0.001,0,"Liters pr Second");
			Quantity flowQuantity = new Quantity(literPrSecUnit,"Flow","Flow",global::OpenMI.Standard.ValueType.Scalar,flowDimension);

			// -- create leakage quantity --
			Quantity leakageQuantity = new Quantity(literPrSecUnit,"Leakage","Leakage",global::OpenMI.Standard.ValueType.Scalar,flowDimension);

			// -- create and populate elementset to represente the whole river network --
			ElementSet fullRiverElementSet = new ElementSet("WholeRiver","WholeRiver",ElementType.XYPolyLine,new SpatialReference("no reference"));
			for (int i = 0; i < _numberOfNodes -1; i++)
			{
				Element element = new Element();
				element.ID = "Branch:" + i.ToString();
				element.AddVertex(new Vertex(_xCoordinate[i],_yCoordinate[i],-999));
				element.AddVertex(new Vertex(_xCoordinate[i+1],_yCoordinate[i+1],-999));
				fullRiverElementSet.AddElement(element);
			}

			// --- populate input exchange items for flow to individual nodes ---
			for ( int i = 0; i < _numberOfNodes; i++)
			{
				Element element = new Element();
				element.ID = "Node:" + i.ToString();
				ElementSet elementSet = new ElementSet("Individual nodes","Node:" + i.ToString(), ElementType.IDBased,new SpatialReference("no reference"));
				elementSet.AddElement(element);
				InputExchangeItem inputExchangeItem = new InputExchangeItem();
				inputExchangeItem.ElementSet = elementSet;
				inputExchangeItem.Quantity = flowQuantity;
				
				_inputExchangeItems.Add(inputExchangeItem);
			}

			// --- Populate input exchange item for flow to the whole georeferenced river ---
			InputExchangeItem wholeRiverInputExchangeItem = new InputExchangeItem();
			wholeRiverInputExchangeItem.ElementSet = fullRiverElementSet;
			wholeRiverInputExchangeItem.Quantity   = flowQuantity;
			_inputExchangeItems.Add(wholeRiverInputExchangeItem);

			// --- Populate output exchange items for flow in river branches ---
			for (int i = 0; i < _numberOfNodes - 1; i++)
			{
				Element element = new Element();
				element.ID = "Branch:" + i.ToString();
				ElementSet elementSet = new ElementSet("Individual nodes","Branch:" + i.ToString(),ElementType.IDBased,new SpatialReference("no reference"));
				elementSet.AddElement(element);
			    OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
				outputExchangeItem.ElementSet = elementSet;
				outputExchangeItem.Quantity = flowQuantity;
				
				_outputExchangeItems.Add(outputExchangeItem);
			}

			// --- polulate output exchange items for leakage for individual branches --
			for (int i = 0; i < _numberOfNodes - 1; i++)
			{
				Element element = new Element();
				element.ID = "Branch:" + i.ToString();
				ElementSet elementSet = new ElementSet("Individual nodes","Branch:" + i.ToString(),ElementType.IDBased,new SpatialReference("no reference"));
				elementSet.AddElement(element);
				OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
				outputExchangeItem.ElementSet = elementSet;
				outputExchangeItem.Quantity = leakageQuantity;
				_outputExchangeItems.Add(outputExchangeItem);
			}

			// --- Populate output exchange item for leakage from the whole georeferenced river ---
			OutputExchangeItem wholeRiverOutputExchangeItem = new OutputExchangeItem();
			wholeRiverOutputExchangeItem.ElementSet = fullRiverElementSet;
			wholeRiverOutputExchangeItem.Quantity   = leakageQuantity;
			_outputExchangeItems.Add(wholeRiverOutputExchangeItem);

			// --- populate with initial state variables ---
			for (int i = 0; i < _numberOfNodes -1; i++)
			{
				_flow[i] = 7;
			}

			_currentTimeStepNumber = 1;
			_initializeMethodWasInvoked = true;
		}
示例#21
0
		public void TargetElementSet()
		{
			ElementSet targetElementSet = new ElementSet("TargetElementSet",
				"TargetElementSetID",ElementType.XYPoint,new SpatialReference("TargetRef"));

			Assert.AreEqual(targetElementSet,link1.TargetElementSet);
			Assert.AreEqual(targetElementSet,link2.TargetElementSet);
		}
示例#22
0
		public void SourceElementSet()
		{
			ElementSet sourceElementSet = new ElementSet("SourceElementSet",
				"SourceElementSetID",ElementType.XYPoint,new SpatialReference("SourceRef"));

			Assert.AreEqual(sourceElementSet,link1.SourceElementSet);
			Assert.AreEqual(sourceElementSet,link2.SourceElementSet);
		}
示例#23
0
		public   IInputExchangeItem GetInputExchangeItem(int index)
		{
			
			// -- create a flow quanitity --
			Dimension flowDimension = new Dimension();
			flowDimension.SetPower(DimensionBase.Length,3);
			flowDimension.SetPower(DimensionBase.Time,-1);
			Unit literPrSecUnit = new Unit("LiterPrSecond",0.001,0,"Liters pr Second");
			Quantity flowQuantity = new Quantity(literPrSecUnit,"Flow","Flow",global::OpenMI.Standard.ValueType.Scalar,flowDimension);

			Element element = new Element();
			element.ID = "DummyElement";
			ElementSet elementSet = new ElementSet("Dummy ElementSet","DummyElementSet",ElementType.IDBased,new SpatialReference("no reference"));
			elementSet.AddElement(element);

			InputExchangeItem inputExchangeItem = new InputExchangeItem();
			inputExchangeItem.ElementSet = elementSet;
			inputExchangeItem.Quantity   = flowQuantity;

			return inputExchangeItem;
		}
 public void ElementSet()
 {
     Output output = new Output("ES.Q", new Quantity("Q"), new ElementSet("ES"));
     ElementSet elementSet = new ElementSet("ES");
     Assert.IsTrue(elementSet.Equals(output.SpatialDefinition));
 }
		public void ElementSet()
		{
			ElementSet elementSet = new ElementSet();
			elementSet.ID = "ES";
			Assert.IsTrue(elementSet.Equals(exchangeItem.ElementSet));
		}
示例#26
0
        public void EqualsSpatialReference()
        {
            ElementSet elementSet1 = new ElementSet("ElementSet", "ElementSetID", ElementType.Polygon);
            element1 = new Element("element1");
            element1.AddVertex(new Coordinate(1.0, 2.0, 3.0));
            element1.AddVertex(new Coordinate(2.0, 3.0, 4.0));
            element1.AddVertex(new Coordinate(4.0, 5.0, 6.0));
            elementSet1.AddElement(element1);

            element2 = new Element("element2");
            element2.AddVertex(new Coordinate(6.0, 7.0, 8.0));
            element2.AddVertex(new Coordinate(9.0, 10.0, 11.0));
            element2.AddVertex(new Coordinate(12.0, 13.0, 14.0));
            elementSet1.AddElement(element2);

            elementSet1.SpatialReferenceSystemWkt = "PROJCS[\"Mercator Spheric\", GEOGCS[\"WGS84based_GCS\", DATUM[\"WGS84based_Datum\", SPHEROID[\"WGS84based_Sphere\", 6378137, 0], TOWGS84[0, 0, 0, 0, 0, 0, 0]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH]]";

            Assert.IsFalse(elementSet.Equals(elementSet1));
        }
示例#27
0
		public void Initialize(System.Collections.Hashtable properties)
		{
			double ox = 2.0;
			double oy = 2.0;
			double dx = 4.0;
			double dy = 4.0;

			// -- Populate Input Exchange Items ---
			Element element0 = new Element("element:0");
			element0.AddVertex(new Vertex(ox      ,oy        ,0));
			element0.AddVertex(new Vertex(ox+dx   ,oy        ,0));
			element0.AddVertex(new Vertex(ox+dx   ,oy+dy     ,0));
			element0.AddVertex(new Vertex(ox      ,oy+dy     ,0));

			Element element1 = new Element("element:1");
			element1.AddVertex(new Vertex(ox + dx ,oy        ,0));
			element1.AddVertex(new Vertex(ox+2*dx ,oy        ,0));
			element1.AddVertex(new Vertex(ox+2*dx ,oy+dy     ,0));
			element1.AddVertex(new Vertex(ox+dx   ,oy+dy     ,0));

			Element element2 = new Element("element:2");
			element2.AddVertex(new Vertex(ox      ,oy+dy       ,0));
			element2.AddVertex(new Vertex(ox+dx   ,oy+dy       ,0));
			element2.AddVertex(new Vertex(ox+dx   ,oy+2*dy     ,0));
			element2.AddVertex(new Vertex(ox      ,oy+2*dy     ,0));

			Element element3 = new Element("element:3");
			element3.AddVertex(new Vertex(ox + dx ,oy+dy       ,0));
			element3.AddVertex(new Vertex(ox+2*dx ,oy+dy       ,0));
			element3.AddVertex(new Vertex(ox+2*dx ,oy+2*dy     ,0));
			element3.AddVertex(new Vertex(ox+dx   ,oy+2*dy     ,0));

			ElementSet elementSet = new ElementSet("RegularGrid","RegularGrid",ElementType.XYPolygon,new SpatialReference(" "));
			elementSet.AddElement(element0);
			elementSet.AddElement(element1);
			elementSet.AddElement(element2);
			elementSet.AddElement(element3);

			Quantity storageQuantity = new Quantity(new Unit("Storage",1.0,0.0,"Storage"),"Storage","Storage",global::OpenMI.Standard.ValueType.Scalar,new Dimension());
			InputExchangeItem inputExchangeItem = new InputExchangeItem();
			inputExchangeItem.ElementSet = elementSet;
			inputExchangeItem.Quantity   = storageQuantity;
			_inputExchangeItems.Add(inputExchangeItem);

			OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
			outputExchangeItem.ElementSet = elementSet;
			outputExchangeItem.Quantity   = storageQuantity;
			_outputExchangeItems.Add(outputExchangeItem);

		}
    public void ExpectedException_Crossing_lines_in_PolygonElement()
    {
        try
        {
            //Crossing lines in polygon element error
            ElementSet elementSet = new ElementSet("test", "test", ElementType.XYPolygon, new SpatialReference("DummyID"));
            HydroNumerics.OpenMI.Sdk.Backbone.Element e1 = new HydroNumerics.OpenMI.Sdk.Backbone.Element("e1");
            e1.AddVertex(new Vertex(0, 1, 0));
            e1.AddVertex(new Vertex(0, 0, 0));
            e1.AddVertex(new Vertex(1, 0, 0));
            e1.AddVertex(new Vertex(0.9, 1.1, 0));
            e1.AddVertex(new Vertex(1.1, 0.9, 0));

            elementSet.AddElement(e1);

            ElementSetChecker.CheckElementSet(elementSet);
        }
        catch (Exception ex)
        {
            Assert.IsTrue(ex.GetType() == typeof(Exception));
        }
    }
        public void Equals()
        {
            Output output = new Output("ES.Q", new Quantity("Q"), new ElementSet("ES"));
            
            ElementSet elementSet = new ElementSet("ES");
            Output exchangeItem2 = new Output("ES.Q", new Quantity("Q"), elementSet);

            Assert.IsTrue(exchangeItem2.Equals(output));

            exchangeItem2.ValueDefinition = new Quantity("Q1");
            Assert.IsFalse(exchangeItem2.Equals(output));
            exchangeItem2.ValueDefinition = new Quantity("Q");
            elementSet.Caption = "ES2";

            Assert.IsFalse(exchangeItem2.Equals(output));
            Assert.IsFalse(exchangeItem2.Equals(null));
            Assert.IsFalse(exchangeItem2.Equals("string"));
        }
    public override void Initialize()
    {

      Dictionary<string, string> argumentsDictionary = new Dictionary<string, string>();

      //TODO: Check that you can assume that e.g. a configuration editor will populate the Argumenst, based on data from the OMI file
      foreach (IArgument argument in this.Arguments)
      {
        argumentsDictionary.Add(argument.Id, argument.ValueAsString);
      }
      filename = argumentsDictionary["Filename"];
      //outputFilename = argumentsDictionary["OutputFilename"];

      timeSeriesGroup = TimeSeriesGroupFactory.Create(filename);

      Outputs = new List<IBaseOutput>();


      foreach (var ts in timeSeriesGroup.Items)
      {
        Dimension dimention = new Dimension();
        dimention.SetPower(DimensionBase.AmountOfSubstance, ts.Unit.Dimension.AmountOfSubstance);
        dimention.SetPower(DimensionBase.Currency, ts.Unit.Dimension.Currency);
        dimention.SetPower(DimensionBase.ElectricCurrent, ts.Unit.Dimension.ElectricCurrent);
        dimention.SetPower(DimensionBase.Length, ts.Unit.Dimension.Length);
        dimention.SetPower(DimensionBase.LuminousIntensity, ts.Unit.Dimension.LuminousIntensity);
        dimention.SetPower(DimensionBase.Mass, ts.Unit.Dimension.Mass);
        dimention.SetPower(DimensionBase.Time, ts.Unit.Dimension.Time);

        Unit unit = new Unit(ts.Unit.ID);
        unit.Description = ts.Unit.Description;
        unit.ConversionFactorToSI = ts.Unit.ConversionFactorToSI;
        unit.OffSetToSI = ts.Unit.OffSetToSI;
        unit.Dimension = dimention;

        Quantity quantity = new Quantity();
        quantity.Caption = ts.Name;
        quantity.Description = ts.Description;
        quantity.Unit = unit;

        ElementSet elementSet = new ElementSet("IDBased");
        elementSet.Description = "IDBased";
        elementSet.ElementType = global::OpenMI.Standard2.TimeSpace.ElementType.IdBased;
        Element element = new Element();
        element.Caption = "IDBased";
        elementSet.AddElement(element);



        Output o = new Output(ts.Name, quantity, elementSet);

        o.TimeSet = new TimeSet();
        o.Values = new HydroNumerics.OpenMI.Sdk.Backbone.Generic.TimeSpaceValueSet<double>();

        if (ts is TimespanSeries)
        {
          foreach (var tsi in ((TimespanSeries)ts).Items)
          {
            o.TimeSet.Times.Add(new HydroNumerics.OpenMI.Sdk.Backbone.Time(ts.StartTime, ts.EndTime));
            o.Values.Values2D.Add(new List<double> { tsi.Value });
          }
        }
        else
        {
          foreach (var tsi in ((TimestampSeries)ts).Items)
          {
            o.TimeSet.Times.Add(new HydroNumerics.OpenMI.Sdk.Backbone.Time(ts.StartTime));
            o.Values.Values2D.Add(new List<double> { tsi.Value });
          }
        }

        Outputs.Add(o);
      }

      Caption = timeSeriesGroup.Name;
      Description = timeSeriesGroup.Name;



    }