private void MakeDefaultDocument()
        {
            try
            {
                _config = (WmsConfigurationDocument)_service.FeatureService.GetSchemaMapping("OSGeo.WMS", _fs.ConnectionString); //NOXLATE
                //BOGUS: This was not as sufficient as I originally thought, nevertheless this contains
                //information that would not exist if we constructed the document the old fashioned way.
                string defaultScName = string.Empty;
                if (_config.SpatialContexts.Length > 0)
                {
                    defaultScName = _config.SpatialContexts[0].Name;
                }
                else
                {
                    var list = _fs.GetSpatialInfo(false);
                    if (list.SpatialContext.Count > 0)
                    {
                        defaultScName = list.SpatialContext[0].Name;
                    }
                    else //Really? What kind of WMS service are you????
                    {
                        var sc = new FdoSpatialContextListSpatialContext()
                        {
                            Name = "EPSG:4326", //NOXLATE
                            Description = "Maestro-generated spatial context", //NOXLATE
                            CoordinateSystemName = "EPSG:4326", //NOXLATE
                            CoordinateSystemWkt = "GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]", //NOXLATE
                            Extent = new FdoSpatialContextListSpatialContextExtent()
                            {
                                LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
                                {
                                    X = "-180.0", //NOXLATE
                                    Y = "-90.0" //NOXLATE
                                },
                                UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
                                {
                                    X = "180.0", //NOXLATE
                                    Y = "90.0" //NOXLATE
                                }
                            },
                            ExtentType = FdoSpatialContextListSpatialContextExtentType.Static,
                            IsActive = true,
                            XYTolerance = 0.0001,
                            ZTolerance = 0.0001,
                        };
                        _config.AddSpatialContext(sc);
                        defaultScName = sc.Name;
                    }
                }

                EnsureRasterProperties(defaultScName);
                _config.EnsureConsistency();
            }
            catch
            {
                _config = BuildDefaultWmsDocument();
            }
        }
示例#2
0
        public void TestOdbcSaveLoad()
        {
            var schema = new FeatureSchema("Default", "Test schema");
            var cls = new ClassDefinition("Cities", "Cities class");

            cls.AddProperty(new DataPropertyDefinition("ID", "Primary Key")
            {
                DataType = DataPropertyType.Int64,
                IsNullable = false,
                IsAutoGenerated = true
            }, true);

            cls.AddProperty(new DataPropertyDefinition("Name", "City Name")
            {
                DataType = DataPropertyType.String,
                IsNullable = true,
                IsAutoGenerated = false,
                Length = 255
            });

            cls.AddProperty(new GeometricPropertyDefinition("Geometry", "Geometry property")
            {
                GeometricTypes = FeatureGeometricType.Point,
                SpecificGeometryTypes = new SpecificGeometryType[] { SpecificGeometryType.Point },
                HasElevation = false,
                HasMeasure = false,
                SpatialContextAssociation = "Default"
            });

            cls.AddProperty(new DataPropertyDefinition("Population", "Population")
            {
                DataType = DataPropertyType.Int32,
                IsNullable = true,
                IsAutoGenerated = false
            });

            cls.DefaultGeometryPropertyName = "Geometry";

            schema.AddClass(cls);

            var sc = new FdoSpatialContextListSpatialContext();
            sc.CoordinateSystemName = "LL84";
            sc.CoordinateSystemWkt = "";
            sc.Description = "Default Spatial Context";
            sc.Extent = new FdoSpatialContextListSpatialContextExtent()
            {
                LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
                {
                    X = "-180.0",
                    Y = "-180.0"
                },
                UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
                {
                    X = "180.0",
                    Y = "180.0"
                }
            };
            sc.ExtentType = FdoSpatialContextListSpatialContextExtentType.Static;
            sc.Name = "Default";
            sc.XYTolerance = 0.0001;
            sc.ZTolerance = 0.0001;

            var conf = new OdbcConfigurationDocument();
            conf.AddSchema(schema);
            conf.AddSpatialContext(sc);

            var ov = new OdbcTableItem();
            ov.SchemaName = schema.Name;
            ov.ClassName = cls.Name;
            ov.SpatialContextName = sc.Name;
            ov.XColumn = "Lon";
            ov.YColumn = "Lat";

            conf.AddOverride(ov);

            string path = "OdbcConfigTest.xml";
            File.WriteAllText(path, conf.ToXml());

            conf = null;
            string xml = File.ReadAllText(path);
            conf = ConfigurationDocument.LoadXml(xml) as OdbcConfigurationDocument;
            Assert.NotNull(conf);

            ov = conf.GetOverride("Default", "Cities");
            Assert.NotNull(ov);
            Assert.AreEqual("Default", ov.SchemaName);
            Assert.AreEqual("Cities", ov.ClassName);
            Assert.AreEqual(sc.Name, ov.SpatialContextName);
            Assert.AreEqual("Lon", ov.XColumn);
            Assert.AreEqual("Lat", ov.YColumn);
        }
 public static bool LoadFromFile(string fileName, out FdoSpatialContextListSpatialContext obj) {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an FdoSpatialContextListSpatialContext object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output FdoSpatialContextListSpatialContext object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out FdoSpatialContextListSpatialContext obj, out System.Exception exception) {
     exception = null;
     obj = default(FdoSpatialContextListSpatialContext);
     try {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out FdoSpatialContextListSpatialContext obj) {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an FdoSpatialContextListSpatialContext object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output FdoSpatialContextListSpatialContext object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out FdoSpatialContextListSpatialContext obj, out System.Exception exception) {
     exception = null;
     obj = default(FdoSpatialContextListSpatialContext);
     try {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }