예제 #1
0
        public DatasourceInput(string filename)
        {
            // TODO: datasource must be closed in case of OGR layers
            var identity = new LayerIdentity(filename);
            var ds       = GeoSource.OpenFromIdentity(identity);

            Datasource = ds.GetLayers().FirstOrDefault();
        }
예제 #2
0
        public bool IsParentOf(LayerIdentity identity)
        {
            if (identity.IdentityType != LayerIdentityType.File)
            {
                return(false);
            }

            return(Shared.PathHelper.IsParentOf(GetPath(), identity.Filename));
        }
예제 #3
0
 public DatasourcePointer(LayerIdentity identity)
 {
     if (identity == null)
     {
         throw new ArgumentNullException("identity");
     }
     LayerIdentity = identity;
     LayerHandle   = -1;
     _name         = Path.GetFileNameWithoutExtension(identity.Filename);
 }
예제 #4
0
        public bool IsParentOf(LayerIdentity identity)
        {
            if (identity.IdentityType != LayerIdentityType.OgrDatasource)
            {
                return(false);
            }

            // it may be trickier than that since items in connection string
            // aren't necessarily in the same order
            return(Connection.ConnectionString.EqualsIgnoreCase(identity.Connection));
        }
예제 #5
0
        public static IDatasource OpenFromIdentity(LayerIdentity identity)
        {
            switch (identity.IdentityType)
            {
            case LayerIdentityType.File:
                return(Open(identity.Filename));

            case LayerIdentityType.OgrDatasource:
                return(OpenFromDatabase(identity.Connection, identity.Query));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #6
0
        private bool AddWmsLayer(LayerIdentity identity)
        {
            if (identity.IdentityType == LayerIdentityType.Wms)
            {
                var wms = new WmsSource("")
                {
                    BaseUrl = identity.Connection, Layers = identity.Query
                };

                // TODO: we don't notify plugin about it, perhaps we should
                int layerHandle = _context.Map.Layers.Add(wms);
                if (layerHandle != -1)
                {
                    _lastLayerHandle = layerHandle;
                    return(true);
                }
            }

            return(false);
        }
예제 #7
0
        public bool RemoveLayer(LayerIdentity identity)
        {
            var layers = _context.Map.Layers.Where(l => l.Identity == identity);

            BeginBatch();

            bool result = false;

            foreach (var l in layers)
            {
                if (!RemoveLayerCore(l.Handle, true))
                {
                    result = false;
                    break;
                }
                result = true;
            }

            EndBatch();
            return(result);
        }
예제 #8
0
        public bool AddLayerIdentity(LayerIdentity identity)
        {
            if (identity == null)
            {
                return(false);
            }

            switch (identity.IdentityType)
            {
            case LayerIdentityType.File:
                return(AddLayersFromFilenameCore(identity.Filename));

            case LayerIdentityType.OgrDatasource:
                return(AddDatabaseLayer(identity.Connection, identity.Query, identity.GeometryType));

            case LayerIdentityType.Wms:
                return(AddWmsLayer(identity));

            default:
                Logger.Current.Warn("Unexpected layer identity");
                return(false);
            }
        }
예제 #9
0
 public bool IsParentOf(LayerIdentity identity)
 {
     return(false);
 }
예제 #10
0
 public DatasourcePointer(string filename)
 {
     LayerIdentity = new LayerIdentity(filename);
     LayerHandle   = -1;
     _name         = Path.GetFileNameWithoutExtension(filename);
 }