public void Initialize(System.Collections.Hashtable properties)
        {

            getValuesWatch = new Stopwatch();
            setValuesWatch = new Stopwatch();
            performStepWatch = new Stopwatch();

            //List of exchange Items
            inputExchangeItems = new List<InputExchangeItem>();
            outputExchangeItems = new List<OutputExchangeItem>();

            //Initializes Engine
            mohidLandEngine = new MohidLandEngineDotNetAccess();
            mohidLandEngine.Initialize(properties["FilePath"].ToString());


            //
            //Dimensions
            //
            Dimension dimFlow = new Dimension();
            dimFlow.SetPower(DimensionBase.Length, 3);
            dimFlow.SetPower(DimensionBase.Time, -1);

            Dimension dimWaterlevel = new Dimension();
            dimWaterlevel.SetPower(DimensionBase.Length, 1);

            Dimension dimWaterColumn = new Dimension();
            dimWaterColumn.SetPower(DimensionBase.Length, 1);

            Dimension dimConcentration = new Dimension();
            dimConcentration.SetPower(DimensionBase.Mass, 1);
            dimConcentration.SetPower(DimensionBase.Length, -3);

            //
            //Units
            //
            Unit unitFlow = new Unit("m3/sec", 1, 0, "cubic meter per second");
            Unit unitWaterLevel = new Unit("m", 1, 0, "meters above mean sea level");
            Unit unitWaterColumn = new Unit("m", 1, 0, "meters above ground");
            Unit unitConcentration = new Unit("mg/l", 1, 0, "miligram per liter");

            //
            //Quantities
            //
            qtdOutflow = new Quantity(unitFlow, "Flow discharge at the outlet", "Outlet Flow", ValueType.Scalar, dimFlow);
            qtdOutletLevel = new Quantity(unitWaterLevel, "Waterlevel at the outlet", "OutletLevel",
                                                   ValueType.Scalar, dimWaterlevel);
            qtdWaterColumn = new Quantity(unitWaterColumn, "Ponded Water Column", "WaterColumn",
                                                   ValueType.Scalar, dimWaterColumn);
            qtdDischarges = new Quantity(unitFlow, "Distributed discharges (sewer sinks)", "Discharges", ValueType.Scalar,
                                                  dimFlow);

            qtdFlowToStorm = new Quantity(unitFlow, "Flow from the network to the storm water system (inlets)",
                                          "Storm Water Out Flow", ValueType.Scalar, dimFlow);

            qtdFlowFromStrom = new Quantity(unitFlow, "Flow from the storm water system to the network (discharges)",
                              "Storm Water In Flow", ValueType.Scalar, dimFlow);

            //
            //Spatial Reference
            //
            SpatialReference spatialReference = new SpatialReference("spatial reference");

            //
            //Element Sets
            //

            //Model Grid
            ElementSet modelGrid = new ElementSet("Model Grid Points of all Compute Points", "Model Grid",
                                       ElementType.XYPolygon, spatialReference);

            //Output exchange items - properties in each grid cell (surface only)
            numberOfWaterPoints = 0;
            for (int j = 1; j <= mohidLandEngine.GetJUB(horizontalGridInstanceID); j++)
            {
                for (int i = 1; i <= mohidLandEngine.GetIUB(horizontalGridInstanceID); i++)
                {
                    if (mohidLandEngine.IsWaterPoint(horizontalMapInstanceID, i, j))
                    {
                        String name = "i=" + i.ToString() + "/j=" + j.ToString();

                        double[] xCoords = new double[5];
                        double[] yCoords = new double[5];
                        mohidLandEngine.GetGridCellCoordinates(horizontalGridInstanceID, i, j, ref xCoords, ref yCoords);

                        Element element = new Element(name);
                        element.AddVertex(new Vertex(xCoords[0], yCoords[0], 0));
                        element.AddVertex(new Vertex(xCoords[1], yCoords[1], 0));
                        element.AddVertex(new Vertex(xCoords[2], yCoords[2], 0));
                        element.AddVertex(new Vertex(xCoords[3], yCoords[3], 0));

                        modelGrid.AddElement(element);

                        numberOfWaterPoints++;

                    }
                }
            }

            //Outlet Node
            ElementSet outletNode = new ElementSet("Outlet node", "Outlet", ElementType.XYPoint, spatialReference);
            Element outletElement = new Element("Outlet");
            int outletNodeID = mohidLandEngine.GetOutletNodeID(drainageNetworkInstanceID);
            outletElement.AddVertex(new Vertex(mohidLandEngine.GetXCoordinate(drainageNetworkInstanceID, outletNodeID),
                                               mohidLandEngine.GetYCoordinate(drainageNetworkInstanceID, outletNodeID),
                                               0));
            outletNode.AddElement(outletElement);

            //Outflow to Storm Water Model
            ElementSet stormWaterOutflowNodes = new ElementSet("Nodes which provide flow to the Storm Water System",
                                                          "Storm Water Inlets", ElementType.XYPoint, spatialReference);
            int numberOfOutflowNodes = mohidLandEngine.GetNumberOfStormWaterOutFlowNodes(drainageNetworkInstanceID);
            int[] outflowNodeIDs = new int[numberOfOutflowNodes];
            mohidLandEngine.GetStormWaterOutflowIDs(drainageNetworkInstanceID, numberOfOutflowNodes, ref outflowNodeIDs);
            for (int i = 1; i <= numberOfOutflowNodes; i++)
            {
                int nodeID = outflowNodeIDs[i - 1];

                Element element = new Element(nodeID.ToString());
                element.AddVertex(new Vertex(mohidLandEngine.GetXCoordinate(drainageNetworkInstanceID, nodeID),
                                             mohidLandEngine.GetYCoordinate(drainageNetworkInstanceID, nodeID),
                                             0));
                stormWaterOutflowNodes.AddElement(element);
            }

            //Inflow from Storm Water Model
            ElementSet stormWaterInflowNodes = new ElementSet("Nodes which receive flow to the Storm Water System",
                                                          "Storm Water Outlets", ElementType.XYPoint, spatialReference);
            int numberOfInflowNodes = mohidLandEngine.GetNumberOfStormWaterInFlowNodes(drainageNetworkInstanceID);
            if (numberOfInflowNodes > 0)
            {
                int[] inflowNodeIDs = new int[numberOfInflowNodes];
                mohidLandEngine.GetStormWaterInflowIDs(drainageNetworkInstanceID, numberOfOutflowNodes,
                                                       ref inflowNodeIDs);
                for (int i = 1; i <= numberOfInflowNodes; i++)
                {
                    int nodeID = inflowNodeIDs[i - 1];

                    Element element = new Element(nodeID.ToString());
                    element.AddVertex(new Vertex(mohidLandEngine.GetXCoordinate(drainageNetworkInstanceID, nodeID),
                                                 mohidLandEngine.GetYCoordinate(drainageNetworkInstanceID, nodeID),
                                                 0));
                    stormWaterInflowNodes.AddElement(element);
                }
            }


            //
            //Output Exchange Items
            //

            //Flow at the outlet
            OutputExchangeItem outletFlow = new OutputExchangeItem();
            outletFlow.Quantity = qtdOutflow;
            outletFlow.ElementSet = outletNode;
            outputExchangeItems.Add(outletFlow);

            //Overland water column
            OutputExchangeItem overlandWaterColumn = new OutputExchangeItem();
            overlandWaterColumn.Quantity = qtdWaterColumn;
            overlandWaterColumn.ElementSet = modelGrid;
            outputExchangeItems.Add(overlandWaterColumn);

            //Flow to the Storm Water Model
            if (stormWaterOutflowNodes.ElementCount > 0)
            {
                OutputExchangeItem stormWaterOutFlow = new OutputExchangeItem();
                stormWaterOutFlow.Quantity = qtdFlowToStorm;
                stormWaterOutFlow.ElementSet = stormWaterOutflowNodes;
                outputExchangeItems.Add(stormWaterOutFlow);
            }

            //
            //Input Exchange Items
            //

            //Water level at the outlet
            InputExchangeItem outletLevel = new InputExchangeItem();
            outletLevel.Quantity = qtdOutletLevel;
            outletLevel.ElementSet = outletNode;
            inputExchangeItems.Add(outletLevel);

            //Distributed discharges
            InputExchangeItem dischargeInflow = new InputExchangeItem();
            dischargeInflow.Quantity = qtdDischarges;
            dischargeInflow.ElementSet = modelGrid;
            inputExchangeItems.Add(dischargeInflow);

            //Flow from the Storm Water Model
            if (stormWaterInflowNodes.ElementCount > 0)
            {
                InputExchangeItem stormWaterInFlow = new InputExchangeItem();
                stormWaterInFlow.Quantity = qtdFlowFromStrom;
                stormWaterInFlow.ElementSet = stormWaterInflowNodes;
                inputExchangeItems.Add(stormWaterInFlow);
            }

            //
            //Properties
            //

            //Properties input / output exchange items
            for (int i = 1; i <= mohidLandEngine.GetNumberOfProperties(drainageNetworkInstanceID); i++)
            {
                int propertyIDNumber = mohidLandEngine.GetPropertyIDNumber(drainageNetworkInstanceID, i);
                string propertyName = mohidLandEngine.GetPropertyNameByIDNumber(propertyIDNumber);

                Quantity concentrationQuantity = new Quantity(unitConcentration, "Concentration of " + propertyName,
                                                              propertyIDNumber.ToString(), ValueType.Scalar, dimConcentration);

                OutputExchangeItem outletConc = new OutputExchangeItem();
                outletConc.Quantity = concentrationQuantity;
                outletConc.ElementSet = outletNode;

                outputExchangeItems.Add(outletConc);


                InputExchangeItem boundaryConc = new InputExchangeItem();
                boundaryConc.Quantity = concentrationQuantity;
                boundaryConc.ElementSet = outletNode;

                inputExchangeItems.Add(boundaryConc);

            }

        }
		public void Init()
		{
			spatialReference = new SpatialReference("ID");
		}
        public void Initialize(System.Collections.Hashtable properties)
        {
            //List of exchange Items
            inputExchangeItems = new List<InputExchangeItem>();
            outputExchangeItems = new List<OutputExchangeItem>();

            //Initializes Engine
            MohidWaterEngine = new MohidWaterEngineDotNetAccess();
            MohidWaterEngine.Initialize(properties["FilePath"].ToString());

            //
            //Dimensions
            //
            Dimension dimFlow = new Dimension();
            dimFlow.SetPower(DimensionBase.Length, 3);
            dimFlow.SetPower(DimensionBase.Time, -1);

            Dimension dimWaterlevel = new Dimension();
            dimWaterlevel.SetPower(DimensionBase.Length, 1);

            Dimension dimConcentration = new Dimension();
            dimConcentration.SetPower(DimensionBase.Mass, 1);
            dimConcentration.SetPower(DimensionBase.Length, -3);

            //
            //Units
            //
            Unit unitFlow = new Unit("m3/sec", 1, 0, "cubic meter per second");
            Unit unitWaterLevel = new Unit("m", 1, 0, "sea water level");
            Unit unitConcentration = new Unit("mg/l", 1, 0, "miligram per liter");

            //
            //Quantities
            //
            qtdDischargeFlow = new Quantity(unitFlow, "Input Discharge Flow", "Discharge Flow",
                                            global::OpenMI.Standard.ValueType.Scalar, dimFlow);
            qtdWaterLevel = new Quantity(unitWaterLevel, "Waterlevel of the water surface", "Waterlevel",
                                         global::OpenMI.Standard.ValueType.Scalar, dimWaterlevel);

            //
            //Spatial Reference
            //
            SpatialReference spatialReference = new SpatialReference("spatial reference");

            //
            //Element Sets
            //

            //Model Grid
            ElementSet modelGrid = new ElementSet("Model Grid Points of all Compute Points", "Model Grid",
                                                  ElementType.XYPolygon, spatialReference);

            //Output exchange items - properties in each grid cell (surface only)
            numberOfWaterPoints = 0;
            for (int i = 1; i <= MohidWaterEngine.GetIUB(horizontalGridInstanceID); i++)
            {
                for (int j = 1; j <= MohidWaterEngine.GetJUB(horizontalGridInstanceID); j++)
                {
                    if (MohidWaterEngine.IsWaterPoint(horizontalMapInstanceID, i, j))
                    {
                        String name = "i=" + i.ToString() + "/j=" + j.ToString();

                        double[] xCoords = new double[5];
                        double[] yCoords = new double[5];
                        MohidWaterEngine.GetGridCellCoordinates(horizontalGridInstanceID, i, j, ref xCoords, ref yCoords);

                        Element element = new Element(name);
                        element.AddVertex(new Vertex(xCoords[0], yCoords[0], 0));
                        element.AddVertex(new Vertex(xCoords[1], yCoords[1], 0));
                        element.AddVertex(new Vertex(xCoords[2], yCoords[2], 0));
                        element.AddVertex(new Vertex(xCoords[3], yCoords[3], 0));

                        modelGrid.AddElement(element);

                        numberOfWaterPoints++;

                    }
                }
            }

            //allocates waterlevels1D
            modelGridValues1D = new double[numberOfWaterPoints];

            //Discharge Points
            ElementSet dischargePoints = new ElementSet("Discharge Points", "Discharge Points", ElementType.XYPoint,
                                                        spatialReference);

            //Flow input exchange to discharges configured as OpenMI Discharges
            for (int i = 1; i <= MohidWaterEngine.GetNumberOfDischarges(dischargeInstanceID); i++)
            {
                if (MohidWaterEngine.GetDischargeType(dischargeInstanceID, i) == 4)
                {
                    Element dischargeElement = new Element(MohidWaterEngine.GetDischargeName(dischargeInstanceID, i));
                    dischargeElement.AddVertex(
                        new Vertex(MohidWaterEngine.GetDischargeXCoordinate(dischargeInstanceID, i),
                                   MohidWaterEngine.GetDischargeYCoordinate(dischargeInstanceID, i), 0));
                    dischargePoints.AddElement(dischargeElement);
                }
            }

            //
            //Output Exchange Items
            //

            //Water Level of the Hydrodynamic model
            OutputExchangeItem waterlevel = new OutputExchangeItem();
            waterlevel.Quantity = qtdWaterLevel;
            waterlevel.ElementSet = modelGrid;
            outputExchangeItems.Add(waterlevel);


            //Properties of the Water properties model
            for (int idx = 1; idx <= MohidWaterEngine.GetNumberOfProperties(waterPropertiesInstanceID); idx++)
            {

                int propertyID = MohidWaterEngine.GetPropertyIDNumber(waterPropertiesInstanceID, idx);
                string propertyName = MohidWaterEngine.GetPropertyNameByIDNumber(propertyID);

                Quantity concentrationQuantity = new Quantity(unitConcentration, "Concentration of " + propertyName, propertyID.ToString(),
                                                              ValueType.Scalar, dimConcentration);

                qtdProperties.Add(concentrationQuantity);

                OutputExchangeItem concExchangeItem = new OutputExchangeItem();
                concExchangeItem.Quantity = concentrationQuantity;
                concExchangeItem.ElementSet = modelGrid;

                outputExchangeItems.Add(concExchangeItem);
            }


            //Flow input exchange to discharges configured as OpenMI Discharges
            for (int i = 1; i <= MohidWaterEngine.GetNumberOfDischarges(dischargeInstanceID); i++)
            {
                if (MohidWaterEngine.GetDischargeType(dischargeInstanceID, i) == 4)
                {

                    String pointName = MohidWaterEngine.GetDischargeName(dischargeInstanceID, i);

                    ElementSet dischargePoint = new ElementSet("Discharge Point of MOHID Water", i.ToString(), ElementType.XYPoint, spatialReference);

                    InputExchangeItem inputDischarge = new InputExchangeItem();
                    inputDischarge.Quantity = qtdDischargeFlow;

                    Element element = new Element("Point: " + pointName);
                    element.AddVertex(new Vertex(MohidWaterEngine.GetDischargeXCoordinate(dischargeInstanceID, i), MohidWaterEngine.GetDischargeYCoordinate(dischargeInstanceID, i), 0));
                    dischargePoint.AddElement(element);

                    inputDischarge.ElementSet = dischargePoint;

                    inputExchangeItems.Add(inputDischarge);


                    for (int idx = 1; idx <= MohidWaterEngine.GetNumberOfDischargeProperties(dischargeInstanceID, i); idx++)
                    {
                        int propertyID = MohidWaterEngine.GetDischargePropertyID(dischargeInstanceID, i, idx);

                        string propertyName = MohidWaterEngine.GetPropertyNameByIDNumber(propertyID);

                        Quantity concentrationQuantity = new Quantity(unitConcentration, propertyName, propertyID.ToString(), global::OpenMI.Standard.ValueType.Scalar, dimConcentration);

                        InputExchangeItem inputExchangeItem = new InputExchangeItem();
                        inputExchangeItem.ElementSet = dischargePoint;
                        inputExchangeItem.Quantity = concentrationQuantity;

                        inputExchangeItems.Add(inputExchangeItem);

                    }

                }
            }




        }
        /// <summary>
        ///     This method adds vertices to the omiElementSet.  It provides the spatial representation for
        ///     the element set.  The vertices are extracted from the components input shapefile.
        /// </summary>
        /// <param name="omiElementSet">the components element set object</param>
        /// <param name="shapefilePath">path to a shapefile, spatially defining the elementset</param>
        /// <returns>the elementset with vertices added to it from the shapefile</returns>
        public ElementSet AddElementsFromShapefile(ElementSet omiElementSet, string shapefilePath)
        {
            //this uses the free SharpMap API for reading a shapefile
            var myLayer = new VectorLayer("elements_layer");
            myLayer.DataSource = new ShapeFile(shapefilePath);
            myLayer.DataSource.Open();

            //set spatial reference from shapefile
            var sprf = new SpatialReference();
            sprf.ID = myLayer.DataSource.SRID.ToString();
            omiElementSet.SpatialReference = sprf;

            //add elements to elementset from shapefile
            for (uint i = 0; i < myLayer.DataSource.GetFeatureCount(); ++i)
            {
                var feat = myLayer.DataSource.GetFeature(i);
                var GeometryType = Convert.ToString(
                    feat.Geometry.AsText().Substring(
                        0, feat.Geometry.AsText().IndexOf(' ')));

                var e = new Element();

                if (feat.Table.Columns.IndexOf("HydroCode") != -1)
                    e.ID = feat.ItemArray[feat.Table.Columns.IndexOf("HydroCode")].ToString();

                if (GeometryType == "POINT")
                {
                    omiElementSet.ElementType = ElementType.XYPoint;
                    var p = (Point)feat.Geometry;
                    var v = new Vertex();
                    v.x = p.X;
                    v.y = p.Y;
                    e.AddVertex(v);
                }
                if (GeometryType == "POLYGON")
                {
                    omiElementSet.ElementType = ElementType.XYPolygon;
                    var p = (Polygon)feat.Geometry;
                    var lr = p.ExteriorRing;

                    //Only loop until lr.Vertices.Count-2 b/c the first element is the same
                    // as the last element within the exterior ring.  This will thrown an error
                    // within the OATC element mapper, when trying to map elements.  Also this
                    // loop arranges the vertices of the exterior ring in counter clockwise order
                    // as needed for the element mapping.
                    for (var j = lr.Vertices.Count - 2; j >= 0; j--)
                    {
                        var v = new Vertex();
                        v.x = lr.Vertices[j].X;
                        v.y = lr.Vertices[j].Y;
                        e.AddVertex(v);
                    }
                }
                if (GeometryType == "LINESTRING")
                {
                    omiElementSet.ElementType = ElementType.XYPolyLine;
                    var ls = (LineString)feat.Geometry;
                    //Point endpt = ls.EndPoint;
                    //Point startpt = ls.StartPoint;
                    for (var j = 0; j < ls.Vertices.Count; j++)
                    {
                        var v = new Vertex();
                        v.x = ls.Vertices[j].X;
                        v.y = ls.Vertices[j].Y;
                        e.AddVertex(v);
                    }
                }
                omiElementSet.AddElement(e);
            }
            return omiElementSet;
        }