Пример #1
0
        async public Task <bool> Import(string path, Dictionary <string, Guid> providers)
        {
            //_cancelTracker.Reset();
            if (!_cancelTracker.Continue)
            {
                _errMsg = "Canceled by user...";
                return(false);
            }

            if (!(_fdb is AccessFDB))
            {
                _errMsg = "Database in not a FeatureDatabase...";
                return(false);
            }

            AccessFDB fdb = (AccessFDB)_fdb;

            if (ReportAction != null)
            {
                ReportAction(this, "Open Raster Polygon Class...");
            }

            IFeatureClass rasterFC = await fdb.GetFeatureclass(_dsname, _dsname + "_IMAGE_POLYGONS");

            if (rasterFC == null)
            {
                if (rasterFC == null)
                {
                    Console.WriteLine("\n\nERROR: Open Featureclass - Can't init featureclass " + _dsname + "_IMAGE_POLYGONS");
                    return(false);
                }
            }

            DirectoryInfo di = new DirectoryInfo(path);
            FileInfo      fi = new FileInfo(path);

            if (di.Exists)
            {
                await SearchImages(fdb, rasterFC, di, providers);

                //if (_recalculateExtent) fdb.CalculateSpatialIndex(rasterFC, 100);
            }
            else if (fi.Exists)
            {
                if (!await InsertImage(fdb, rasterFC, fi, providers))
                {
                    return(false);
                }
                //if (_recalculateExtent) fdb.CalculateSpatialIndex(rasterFC, 100);
            }

            if (!_cancelTracker.Continue)
            {
                _errMsg = "Canceled by user...";
                return(false);
            }

            return(true);
        }
Пример #2
0
        static bool CalculateExtent(IFeatureDataset ds)
        {
            Console.WriteLine("\nCalculete new Extent");
            AccessFDB fdb = ds.Database as AccessFDB;

            if (fdb != null)
            {
                IFeatureClass fc = fdb.GetFeatureclass(ds.DatasetName, ds.DatasetName + "_IMAGE_POLYGONS");
                fdb.CalculateExtent(fc);
                //fdb.ShrinkSpatialIndex(ds.DatasetName + "_IMAGE_POLYGONS");
                //fdb.RebuildSpatialIndex(ds.DatasetName + "_IMAGE_POLYGONS");
            }
            return(true);
        }
Пример #3
0
        static void Truncate(IFeatureDataset ds, string fcname)
        {
            if (!((AccessFDB)ds.Database).TruncateTable(fcname))
            {
                Console.WriteLine("Error: " + ds.lastErrorMsg);
            }

            AccessFDB fdb = ds.Database as AccessFDB;

            if (fdb != null)
            {
                IFeatureClass fc = fdb.GetFeatureclass(ds.DatasetName, ds.DatasetName + "_IMAGE_POLYGONS");
                fdb.CalculateExtent(fc);
                //fdb.RebuildSpatialIndex(ds.DatasetName + "_IMAGE_POLYGONS");
            }
        }
        async private Task Import(object arg)
        {
            if (!(arg is ImportArguments))
            {
                return;
            }

            ImportArguments args = (ImportArguments)arg;

            await Task.Delay(300); // open reporter UI...

            bool succeeded = true;

            foreach (string filename in args.Data)
            {
                succeeded = await args.Operator.Import(filename, args.Providers);

                if (!succeeded)
                {
                    break;
                }
            }

            AccessFDB fdb = args.dataset.Database as AccessFDB;

            if (fdb != null)
            {
                IFeatureClass fc = await fdb.GetFeatureclass(args.dataset.DatasetName, args.dataset.DatasetName + "_IMAGE_POLYGONS");

                if (fc != null)
                {
                    await fdb.CalculateExtent(fc);
                }

                await fdb.ShrinkSpatialIndex(args.dataset.DatasetName + "_IMAGE_POLYGONS");

                //if (!fdb.CalculateSpatialIndex(fdb.GetFeatureclass(args.dataset.DatasetName, args.dataset.DatasetName + "_IMAGE_POLYGONS"), 10, 0))
                //{
                //    MessageBox.Show("ERROR: CalculateSpatialIndex - " + fdb.lastErrorMsg);
                //}
            }
        }