/// <summary>
        /// Saves this out to a FDO XML configuration document
        /// </summary>
        /// <param name="xmlFile"></param>
        public void Save(string xmlFile)
        {
            using (var fact = new FgfGeometryFactory())
            using (var ws = new IoFileStream(xmlFile, "w"))
            {
                using (var writer = new XmlWriter(ws, true, XmlWriter.LineFormat.LineFormat_Indent))
                {
                    //Write spatial contexts
                    if (this.SpatialContexts != null && this.SpatialContexts.Length > 0)
                    {
                        var flags = new XmlSpatialContextFlags();
                        using (var scWriter = new XmlSpatialContextWriter(writer))
                        {
                            foreach (var sc in this.SpatialContexts)
                            {
                                //XmlSpatialContextWriter forbids writing dynamically calculated extents
                                if (sc.ExtentType == OSGeo.FDO.Commands.SpatialContext.SpatialContextExtentType.SpatialContextExtentType_Dynamic)
                                    continue;

                                scWriter.CoordinateSystem = sc.CoordinateSystem;
                                scWriter.CoordinateSystemWkt = sc.CoordinateSystemWkt;
                                scWriter.Description = sc.Description;
                                
                                scWriter.ExtentType = sc.ExtentType;

                                using (var geom = fact.CreateGeometry(sc.ExtentGeometryText))
                                {
                                    byte[] fgf = fact.GetFgf(geom);
                                    scWriter.Extent = fgf;
                                }

                                scWriter.Name = sc.Name;
                                scWriter.XYTolerance = sc.XYTolerance;
                                scWriter.ZTolerance = sc.ZTolerance;

                                scWriter.WriteSpatialContext();
                            }
                        }
                    }

                    

                    //Write logical schema
                    if (this.Schemas != null)
                    {
                        var schemas = CloneSchemas(this.Schemas);

                        schemas.WriteXml(writer);
                    }

                    //Write physical mappings
                    if (this.Mappings != null)
                    {
                        this.Mappings.WriteXml(writer);
                    }

                    writer.Close();
                }
                ws.Close();
            }
        }
Пример #2
0
        /// <summary>
        /// Saves this out to a FDO XML configuration document
        /// </summary>
        /// <param name="xmlFile"></param>
        public void Save(string xmlFile)
        {
            using (var fact = new FgfGeometryFactory())
                using (var ws = new IoFileStream(xmlFile, "w"))
                {
                    using (var writer = new XmlWriter(ws, true, XmlWriter.LineFormat.LineFormat_Indent))
                    {
                        //Write spatial contexts
                        if (this.SpatialContexts != null && this.SpatialContexts.Length > 0)
                        {
                            var flags = new XmlSpatialContextFlags();
                            using (var scWriter = new XmlSpatialContextWriter(writer))
                            {
                                foreach (var sc in this.SpatialContexts)
                                {
                                    //XmlSpatialContextWriter forbids writing dynamically calculated extents
                                    if (sc.ExtentType == OSGeo.FDO.Commands.SpatialContext.SpatialContextExtentType.SpatialContextExtentType_Dynamic)
                                    {
                                        continue;
                                    }

                                    scWriter.CoordinateSystem    = sc.CoordinateSystem;
                                    scWriter.CoordinateSystemWkt = sc.CoordinateSystemWkt;
                                    scWriter.Description         = sc.Description;

                                    scWriter.ExtentType = sc.ExtentType;

                                    using (var geom = fact.CreateGeometry(sc.ExtentGeometryText))
                                    {
                                        byte[] fgf = fact.GetFgf(geom);
                                        scWriter.Extent = fgf;
                                    }

                                    scWriter.Name        = sc.Name;
                                    scWriter.XYTolerance = sc.XYTolerance;
                                    scWriter.ZTolerance  = sc.ZTolerance;

                                    scWriter.WriteSpatialContext();
                                }
                            }
                        }



                        //Write logical schema
                        if (this.Schemas != null)
                        {
                            var schemas = CloneSchemas(this.Schemas);

                            schemas.WriteXml(writer);
                        }

                        //Write physical mappings
                        if (this.Mappings != null)
                        {
                            this.Mappings.WriteXml(writer);
                        }

                        writer.Close();
                    }
                    ws.Close();
                }
        }