private static FeatureDataTable <TOid> internalCreateTableWithId(FeatureDataTable tableCopy, DataColumn objectIdColumn, IGeometryFactory factory)
        {
            FeatureDataTable <TOid> tableWithId = new FeatureDataTable <TOid>(tableCopy, objectIdColumn.ColumnName, factory);

            // TODO: shouldn't this be in the base class? Need to check if changing base behavior will break stuff.
            foreach (DataColumn col in tableCopy.Columns)
            {
                if (String.Compare(col.ColumnName, objectIdColumn.ColumnName, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    continue;
                }

                DataColumn colCopy = new DataColumn(col.ColumnName, col.DataType);
                colCopy.AllowDBNull       = col.AllowDBNull;
                colCopy.AutoIncrement     = col.AutoIncrement;
                colCopy.AutoIncrementSeed = col.AutoIncrementSeed;
                colCopy.AutoIncrementStep = col.AutoIncrementStep;
                colCopy.DateTimeMode      = col.DateTimeMode;
                colCopy.DefaultValue      = col.DefaultValue;

                foreach (DictionaryEntry entry in col.ExtendedProperties)
                {
                    colCopy.ExtendedProperties[entry.Key] = entry.Value;
                }

                colCopy.MaxLength = col.MaxLength;
                colCopy.ReadOnly  = col.ReadOnly;
                colCopy.Unique    = col.Unique;
                tableWithId.Columns.Add(colCopy);
            }

            foreach (DataRow row in tableCopy)
            {
                FeatureDataRow <TOid> newRow = tableWithId.NewRow() as FeatureDataRow <TOid>;
                Debug.Assert(newRow != null);
                Int32 itemCount = newRow.ItemArray.Length;
                newRow.ItemArray = new Object[itemCount];
                //Array.Copy(row.ItemArray, newRow.ItemArray, itemCount);
                newRow.ItemArray = row.ItemArray;
                tableWithId.AddRow(newRow);
            }

            return(tableWithId);
        }
        public void Add(IFeature item)
        {
            if (Contains(item))
            {
                throw new ArgumentException("This item is already in the table", "item");
            }

            var fdrp = item as FeatureDataRowProxy;

            if (fdrp == null)
            {
                throw new NotImplementedException();
            }

            if (fdrp.DataRow.Table != _table)
            {
                throw new ArgumentException("The item to add was not created by this factory", "item");
            }
            _table.AddRow((FeatureDataRow)fdrp.DataRow);
        }
Beispiel #3
0
    public SharpMap.Layers.VectorLayer CreateGeometryLayer()
    {
        SharpMap.Data.FeatureDataTable fdt = new SharpMap.Data.FeatureDataTable();
        fdt.Columns.Add(new DataColumn("Name", typeof(String)));

        SharpMap.Data.FeatureDataRow fdr;

        fdr = fdt.NewRow();

        fdr["Name"]  = "Mayence";
        fdr.Geometry = (Geometry) new Point(8.1, 50.0);

        fdt.AddRow(fdr);


        SharpMap.Layers.VectorLayer vLayer = new SharpMap.Layers.VectorLayer("GeometryProvider");
        vLayer.DataSource = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);
        vLayer.SRID       = 4326;

        return(vLayer);
    }