Exemplo n.º 1
0
 public pgFDBGraphTableAdapter(pgFDB fdb, pgNetworkFeatureClass nfc)
 {
     _connString = fdb.ConnectionString;
     _nfc        = nfc;
     _name       = _nfc.Name; //name;
 }
Exemplo n.º 2
0
        async static public Task <pgNetworkFeatureClass> Create(pgFDB fdb, IDataset dataset, string name, GeometryDef geomDef)
        {
            var fc = new pgNetworkFeatureClass();

            fc._fdb  = fdb;
            fc._fcid = await fc._fdb.FeatureClassID(await fc._fdb.DatasetID(dataset.DatasetName), name);

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

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

            fc._fields = new Fields();

            fc._name = fc._aliasname = name;

            IDatasetElement element = await fc._dataset.Element(fc._name + "_Nodes");

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

            element = await fc._dataset.Element(fc._name + "_ComplexEdges");

            if (element != null && element.Class is IFeatureClass)
            {
                fc._edgeFcs.Add(-1, (IFeatureClass)element.Class);
            }

            DataTable tab = await fc._fdb.Select("\"FCID\"", "\"FDB_NetworkClasses\"", "\"NetworkId\"=" + fc._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 = await fc._fdb.Select("\"ID\",\"Name\"", "\"FDB_FeatureClasses\"", where.ToString());

                if (tab != null)
                {
                    foreach (DataRow row in tab.Rows)
                    {
                        element = await fc._dataset.Element(row["name"].ToString());

                        if (element != null && element.Class is IFeatureClass)
                        {
                            fc._edgeFcs.Add((int)row["id"], element.Class as IFeatureClass);
                        }
                    }
                }
            }

            fc._weights = await fc._fdb.GraphWeights(name);

            Dictionary <Guid, string> weightTableNames             = null;
            Dictionary <Guid, GraphWeightDataType> weightDataTypes = null;

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

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

            return(fc);
        }