Exemplo n.º 1
0
 public void GetColumn()
 {
     Daisy daisy = GetInitDaisy();
     string name = "Andeby";
     if (daisy.HasColumn(name))
     {
         Column col = daisy.GetColumn(name);
         Assert.AreEqual(col.GetColumnName(), "Andeby");
     }
 }
Exemplo n.º 2
0
        public void Initialize(Hashtable properties) //part of System.Collections
        {
            _inputExchangeItems  = new ArrayList();
            _outputExchangeItems = new ArrayList();
            _elementSets         = new Hashtable();
            _elementScopes       = new Hashtable();
            FilePath             = ((string)properties["FilePath"]);

            InitializeDaisy((string)properties["FilePath"]);
            ModelDescription = ((string)GetDescription());

            for (int i = 0; i < _daisyEngine.ScopeSize(); i++)
            {
                Scope scope = _daisyEngine.GetScope(i);

                // Attribut column?
                if (!scope.HasString("column"))
                {
                    continue;
                }

                // Create element.
                string  columnID = scope.String("column");
                Element element  = new Element(columnID);
                _elementScopes[element] = scope;
                if (_daisyEngine.HasColumn(columnID))
                {
                    Column column = _daisyEngine.GetColumn(columnID);
                    for (uint ii = 0; ii < column.LocationSize(); ii++)
                    {
                        double x = column.LocationX(ii);
                        double y = column.LocationY(ii);
                        double z = 0.0;
                        element.AddVertex(new Vertex(x, y, z));
                    }
                }

                // Add exchange items.
                for (uint j = 0; j < scope.NumberSize(); j++)
                {
                    string     name = scope.NumberName(j);
                    ElementSet elementSet;

                    // Find or create element set.
                    if (_elementSets.Contains(name))
                    {
                        elementSet              = (ElementSet)_elementSets[name];
                        elementSet.Description += " " + columnID;
                        // TODO: We should test the type matches here.
                    }
                    else
                    {
                        switch (element.VertexCount)
                        {
                        case 0:
                            // ID based
                            elementSet = new ElementSet(columnID, name, ElementType.XYPoint, new SpatialReference(""));
                            break;

                        case 1:
                            // Point based
                            elementSet = new ElementSet(columnID, name, ElementType.XYPoint, new SpatialReference(""));
                            break;

                        case 2:
                            // Error
                            throw new ApplicationException("Error: Column must not contain exactly two (X Y)-points!");

                        default:
                            // Polygon
                            elementSet = new ElementSet(columnID, name, ElementType.XYPolygon, new SpatialReference(""));
                            break;
                        }
                        _elementSets[name] = elementSet;
                        string dim         = scope.Dimension(name);
                        string description = scope.Description(name);

                        Quantity quantity = Quantity(dim, description, name);
                        if (scope.Writeable())
                        {
                            InputExchangeItem input = new InputExchangeItem();
                            input.Quantity   = quantity;
                            input.ElementSet = elementSet;
                            _inputExchangeItems.Add(input);
                        }
                        else
                        {
                            OutputExchangeItem output = new OutputExchangeItem();
                            output.Quantity   = quantity;
                            output.ElementSet = elementSet;
                            _outputExchangeItems.Add(output);
                        }
                    }

                    // Add it.
                    elementSet.AddElement(element);
                }
            }
        }