Пример #1
0
        private void OpenShape()
        {
            try
            {
                FileInfo fi = new FileInfo(_filename);

                _shapeDataset = new ShapeDataset();
                _shapeDataset.ConnectionString = fi.Directory.FullName;

                if (!_shapeDataset.Open() || (_shape = _shapeDataset[fi.Name]) == null)
                {
                    _shapeDataset.Dispose();
                    _shapeDataset = null;
                    _icon         = new ShapeFileIcon(geometryType.Unknown);
                }
                else
                {
                    if (_shape.Class is IFeatureClass)
                    {
                        _icon = new ShapeFileIcon(((IFeatureClass)_shape.Class).GeometryType);
                    }
                    else
                    {
                        _icon = new ShapeFileIcon(geometryType.Unknown);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            string path        = String.Empty;
            bool   delExisting = false;

            gView.Framework.system.gViewEnvironment.UserInteractive = false;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-path")
                {
                    path = args[++i];
                }
                else if (args[i] == "-delexisting")
                {
                    delExisting = true;
                }
            }

            if (String.IsNullOrEmpty(path))
            {
                Console.WriteLine("USAGE:");
                Console.WriteLine("gView.Cmd.RefreshShapeIndices -path <shape file path>");
                Console.WriteLine("                     [-delexisting]");
                return;
            }

            if (delExisting)
            {
                foreach (FileInfo fi in new DirectoryInfo(path).GetFiles("*.idx"))
                {
                    Console.WriteLine("delete " + fi.FullName + "...");
                    fi.Delete();
                }
            }

            ShapeDataset ds = new ShapeDataset();

            ds.ConnectionString = path;

            if (!ds.Open())
            {
                Console.WriteLine("ERROR: " + ds.lastErrorMsg);
                return;
            }

            foreach (FileInfo fi in new DirectoryInfo(path).GetFiles("*.shp"))
            {
                var element = ds[fi.Name];
                if (element == null)
                {
                    continue;
                }

                Console.WriteLine("found shape: " + element.Class.Name);
            }

            Console.WriteLine("finished");
        }
Пример #3
0
 public void Dispose()
 {
     if (_shapeDataset != null)
     {
         _shapeDataset.Dispose();
         _shapeDataset = null;
     }
 }