コード例 #1
0
        public pgNetworkFeatureClass(pgFDB fdb, IDataset dataset, string name, GeometryDef geomDef)
        {
            _fdb  = fdb;
            _fcid = _fdb.FeatureClassID(_fdb.DatasetID(dataset.DatasetName), name);

            _dataset = dataset;
            _geomDef = (geomDef != null) ? geomDef : new GeometryDef();

            if (_geomDef != null && _geomDef.SpatialReference == null && dataset is IFeatureDataset)
            {
                _geomDef.SpatialReference = ((IFeatureDataset)dataset).SpatialReference;
            }

            _fields = new Fields();

            _name = _aliasname = name;

            IDatasetElement element = _dataset[_name + "_Nodes"];

            if (element != null)
            {
                _nodeFc = element.Class as IFeatureClass;
            }

            element = _dataset[_name + "_ComplexEdges"];
            if (element != null && element.Class is IFeatureClass)
            {
                _edgeFcs.Add(-1, (IFeatureClass)element.Class);
            }

            DataTable tab = _fdb.Select("\"FCID\"", "\"FDB_NetworkClasses\"", "\"NetworkId\"=" + _fcid);

            if (tab != null && tab.Rows.Count > 0)
            {
                StringBuilder where = new StringBuilder();
                where.Append("\"GeometryType\"=" + ((int)geometryType.Polyline).ToString() + " AND \"ID\" in(");
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    if (i > 0)
                    {
                        where.Append(",");
                    }
                    where.Append(tab.Rows[i]["fcid"].ToString());
                }
                where.Append(")");

                tab = _fdb.Select("\"ID\",\"Name\"", "\"FDB_FeatureClasses\"", where.ToString());
                if (tab != null)
                {
                    foreach (DataRow row in tab.Rows)
                    {
                        element = _dataset[row["name"].ToString()];
                        if (element != null && element.Class is IFeatureClass)
                        {
                            _edgeFcs.Add((int)row["id"], element.Class as IFeatureClass);
                        }
                    }
                }
            }

            _weights = _fdb.GraphWeights(name);
            Dictionary <Guid, string> weightTableNames             = null;
            Dictionary <Guid, GraphWeightDataType> weightDataTypes = null;

            if (_weights != null && _weights.Count > 0)
            {
                weightTableNames = new Dictionary <Guid, string>();
                weightDataTypes  = new Dictionary <Guid, GraphWeightDataType>();
                foreach (IGraphWeight weight in _weights)
                {
                    if (weight == null)
                    {
                        continue;
                    }

                    weightTableNames.Add(weight.Guid, _fdb.TableName(_name + "_Weights_" + weight.Guid.ToString("N").ToLower()));
                    weightDataTypes.Add(weight.Guid, weight.DataType);
                }
            }
            _pageManager = new NetworkObjectSerializer.PageManager(
                gView.Framework.Db.DataProvider.PostgresProvider,
                _fdb.ConnectionString, _name,
                _fdb.TableName("FC_" + _name),
                _fdb.TableName(_name + "_Edges"),
                _fdb.TableName("FC_" + name + "_Nodes"),
                weightTableNames, weightDataTypes, _fdb
                );
        }