Ejemplo n.º 1
0
        public void Download()
        {
            MongoClient client   = new MongoClient("mongodb://localhost:27017");
            var         db       = client.GetDatabase("geo");
            var         context  = new WorkContext();
            var         provider = new GoogleMap();

            provider.Storage = db.GetCollection <BsonDocument>("googleTiles", new MongoCollectionSettings {
                AssignIdOnInsert = false
            });
            if (!db.ListCollectionNames().ToEnumerable().Contains("googleTiles"))
            {
                db.CreateCollection("googleTiles");
                var ikd = Builders <BsonDocument> .IndexKeys.Ascending("x").Ascending("y").Ascending("z");

                provider.Storage.Indexes.CreateOne(new CreateIndexModel <BsonDocument>(ikd));
            }
            context.ParallelLimit = 10;
            context.Provider      = provider;
            context.Changed();
            context.SynchronizationContext.ProcessWorks();
        }