예제 #1
0
        public static IDatasource Open(string filename, OpenStrategy openStrategy = OpenStrategy.AutoDetect)
        {
            var result = TryOpenAsDatabaseLayer(filename);

            if (result != null)
            {
                return(result);
            }

            var source = _manager.Open(filename, (tkFileOpenStrategy)openStrategy);

            return(LayerSourceHelper.Convert(source));
        }
예제 #2
0
        private static IDatasource TryOpenAsDatabaseLayer(string filename)
        {
            // the expected format is: "OgrConnection|<connection>|<query_or_layer_name>"
            if (filename == null || !filename.ToLower().StartsWith("ogrconnection"))
            {
                return(null);
            }

            var parts = filename.Split('|');

            if (parts.Length == 3)
            {
                var source = _manager.OpenFromDatabase(parts[1], parts[2]);
                return(LayerSourceHelper.Convert(source));
            }

            return(null);
        }