Beispiel #1
0
        async static public Task <GMLFile> Create(string filename)
        {
            try
            {
                var file = new GMLFile();

                file._gmlDataset = new Dataset();
                await file._gmlDataset.SetConnectionString(filename);

                if (!await file._gmlDataset.Open())
                {
                    file._gmlDataset = null;
                }

                file._filename = filename;

                file._doc = new XmlDocument();
                file._doc.Load(file._filename);

                file._ns = new XmlNamespaceManager(file._doc.NameTable);
                file._ns.AddNamespace("GML", "http://www.opengis.net/gml");
                file._ns.AddNamespace("WFS", "http://www.opengis.net/wfs");
                file._ns.AddNamespace("OGC", "http://www.opengis.net/ogc");
                file._ns.AddNamespace("myns", file._gmlDataset.targetNamespace);

                return(file);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #2
0
        public bool Flush(IFeatureClass fClass)
        {
            if (fClass == null || !(fClass.Dataset is Dataset))
            {
                return(false);
            }

            GMLFile gmlFile = null;

            try
            {
                // use always the same GMLFile...
                if (!_gmlFiles.TryGetValue(((Dataset)fClass.Dataset).ConnectionString, out gmlFile))
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
            if (gmlFile == null)
            {
                return(false);
            }

            return(gmlFile.Flush());
        }
Beispiel #3
0
        public bool Flush(IFeatureClass fClass)
        {
            if (fClass == null || !(fClass.Dataset is Dataset))
            {
                return(false);
            }

            GMLFile gmlFile = null;

            try
            {
                // use always the same GMLFile...
                if (!_gmlFiles.TryGetValue(((Dataset)fClass.Dataset).ConnectionString, out gmlFile))
                {
                    _errMsg = "Can't get gmlfile form dictionary";
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message;
                return(false);
            }
            if (gmlFile == null)
            {
                return(false);
            }

            if (!gmlFile.Flush())
            {
                _errMsg = gmlFile.LastErrorMessage;
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        public bool DeleteFeatureClass(string fcName)
        {
            string filename = _directoryName + @"\" + fcName + ".gml";

            FileInfo fi = new FileInfo(filename);

            if (fi.Exists)
            {
                GMLFile file = new GMLFile(fi.FullName);
                return(file.Delete());
            }
            return(false);
        }
Beispiel #5
0
        async public Task <bool> DeleteFeatureClass(string fcName)
        {
            string filename = _directoryName + @"/" + fcName + ".gml";

            FileInfo fi = new FileInfo(filename);

            if (fi.Exists)
            {
                GMLFile file = await GMLFile.Create(fi.FullName);

                return(file.Delete());
            }
            return(false);
        }
Beispiel #6
0
        public bool Insert(gView.Framework.Data.IFeatureClass fClass, List <gView.Framework.Data.IFeature> features)
        {
            if (fClass == null || !(fClass.Dataset is Dataset) || features == null)
            {
                return(false);
            }

            GMLFile gmlFile = null;

            try
            {
                // use always the same GMLFile...
                if (_gmlFiles.TryGetValue(((Dataset)fClass.Dataset).ConnectionString, out gmlFile))
                {
                }
                else
                {
                    gmlFile = ((Dataset)fClass.Dataset).GMLFile;
                    _gmlFiles.Add(((Dataset)fClass.Dataset).ConnectionString, gmlFile);
                }
            }
            catch
            {
                return(false);
            }
            if (gmlFile == null)
            {
                return(false);
            }

            foreach (IFeature feature in features)
            {
                if (feature == null)
                {
                    continue;
                }

                if (!gmlFile.AppendFeature(fClass, feature))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #7
0
        async internal Task <GMLFile> GetGMLFile()
        {
            try
            {
                if (_state != DatasetState.opened)
                {
                    return(null);
                }

                FileInfo fi = new FileInfo(_connectionString);
                if (fi.Exists)
                {
                    return(await GMLFile.Create(_connectionString));
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #8
0
        public int CreateFeatureClass(string dsname, string fcname, gView.Framework.Geometry.IGeometryDef geomDef, IFields fields)
        {
            if (geomDef == null || fields == null)
            {
                return(-1);
            }

            string filename = _directoryName + @"\" + fcname + ".gml";
            Fields f        = new Fields();

            foreach (IField field in fields)
            {
                f.Add(field);
            }

            if (!GMLFile.Create(filename, geomDef, f, _gmlVersion))
            {
                return(-1);
            }

            return(0);
        }