Esempio n. 1
0
        /// <summary>
        /// Returns the metadata for a dataset
        /// </summary>
        /// <param name="Name">The name of the dataset</param>
        /// <returns>The metadata requested</returns>
        internal CatalogDatasetEntry GetEntry(string Name)
        {
            IMongoQuery  qry    = Query.EQ("Name", BsonValue.Create(Name));
            BsonDocument result = m_Conn[GDB_ITEMS].FindOne(qry);

            if (default(ResultPortionInfo) == result)
            {
                throw new COMException("No metadata for item: " + Name);
            }
            CatalogDatasetEntry retval = new CatalogDatasetEntry(this);

            retval.Load(result);
            return(retval);
        }
Esempio n. 2
0
        /// <summary>
        /// Internal dataset creator function. Creates all necessary metadata
        /// </summary>
        /// <param name="Name">Name of the dataset</param>
        /// <param name="FieldSet">Fields associated with the dataset</param>
        /// <param name="extent">The geographic extent of the dataset</param>
        /// <returns>A newly created MongoDBDataset</returns>
        public MongoDBDataset CreateDataset(string Name, IFields FieldSet, IEnvelope extent)
        {
            if (m_Connection.GetCollectionNames().Contains(Name))
            {
                throw new COMException("Dataset " + Name + " already exists");
            }

            m_Connection.CreateCollection(Name);

            var bsonIdex = new IndexKeysDocument {
                { CommonConst.SHAPEFIELD, "2d" }
            };

            m_Connection[Name].EnsureIndex(bsonIdex);

            CatalogDatasetEntry dsEntry = new CatalogDatasetEntry(this.m_CatalogDS);

            dsEntry.Name   = Name;
            dsEntry.Extent = extent;
            dsEntry.Fields = FieldSet;
            dsEntry.Save();
            return(new MongoDBDataset(dsEntry, m_Connection));
        }
Esempio n. 3
0
        /// <summary>
        /// Get's Metadata for all datasets stored in the database
        /// </summary>
        /// <returns>Enumerable of CatalogDatasetEntries</returns>
        internal IEnumerable <CatalogDatasetEntry> GetAllEntries()
        {
            List <CatalogDatasetEntry> retVal = new List <CatalogDatasetEntry>();
            var results = m_Conn[GDB_ITEMS].Find(Query.Null);

            List <ObjectId> deleteThese = new List <ObjectId>();

            foreach (var result in results)
            {
                try
                {
                    CatalogDatasetEntry tmp = new CatalogDatasetEntry(this);
                    tmp.Load(result);
                    if (!(String.IsNullOrEmpty(tmp.Name) || (tmp.Fields == null) || (tmp.Extent == null)))
                    {
                        retVal.Add(tmp);
                    }
                    else
                    {
                        deleteThese.Add(result.GetElement(CommonConst.OID).Value.AsObjectId);
                    }
                }
                catch (Exception)
                { }
            }
            if (deleteThese.Count > 0)
            {
                BsonValue[] ids = new BsonValue[deleteThese.Count];
                int         i   = 0;
                foreach (var x in deleteThese)
                {
                    ids[i++] = BsonValue.Create(x);
                }
                m_Conn[GDB_ITEMS].Remove(Query.In(CommonConst.OID, ids));
            }
            return(retVal);
        }
Esempio n. 4
0
        /// <summary>
        /// Opens a dataset given its name
        /// </summary>
        /// <param name="localName">the name of the dataset</param>
        /// <returns>a new IPlugInDatasetHelper</returns>
        public IPlugInDatasetHelper OpenDataset(string localName)
        {
            CatalogDatasetEntry entry = m_CatalogDS.GetEntry(localName);

            return(new MongoDBDataset(entry, m_Connection));
        }
Esempio n. 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="entry">metadata (i.e. extent and fields)</param>
 /// <param name="conn">Database it is located in</param>
 public MongoDBDataset(CatalogDatasetEntry entry, MongoDatabase conn)
 {
     m_Connection = conn;
     m_Entry      = entry;
 }