public void CanExportToXml()
        {
            IWorkspace workspace = TestUtils.OpenUserWorkspaceOracle();

            IFeatureClass fclass =
                DatasetUtils.OpenFeatureClass(workspace, "TOPGIS_TLM.TLM_STRASSE");

            ISpatialReference spatialReference = ((IGeoDataset)fclass).SpatialReference;

            string xml = SpatialReferenceUtils.ToXmlString(spatialReference);

            Console.WriteLine(xml);

            Assert.IsNotNull(xml);
            Assert.IsNotEmpty(xml);

            ISpatialReference imported = SpatialReferenceUtils.FromXmlString(xml);

            Assert.IsTrue(
                SpatialReferenceUtils.AreEqual(imported, spatialReference));
        }
예제 #2
0
        public static SpatialReferenceMsg ToSpatialReferenceMsg(
            [CanBeNull] ISpatialReference spatialReference,
            SpatialReferenceMsg.FormatOneofCase format)
        {
            if (spatialReference == null)
            {
                return(null);
            }

            SpatialReferenceMsg result = new SpatialReferenceMsg();

            switch (format)
            {
            case SpatialReferenceMsg.FormatOneofCase.None:
                break;

            case SpatialReferenceMsg.FormatOneofCase.SpatialReferenceEsriXml:
                result.SpatialReferenceEsriXml = SpatialReferenceUtils.ToXmlString(
                    spatialReference);
                break;

            case SpatialReferenceMsg.FormatOneofCase.SpatialReferenceWkid:
                result.SpatialReferenceWkid = spatialReference.FactoryCode;
                break;

            case SpatialReferenceMsg.FormatOneofCase.SpatialReferenceWkt:
                result.SpatialReferenceWkt =
                    SpatialReferenceUtils.ExportToESRISpatialReference(spatialReference);
                break;

            default:
                throw new NotImplementedException(
                          $"Unsupported spatial reference format: {format}");
            }

            return(result);
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialReferenceDescriptor"/> class.
 /// </summary>
 /// <param name="spatialReference">The spatial reference.</param>
 public SpatialReferenceDescriptor([NotNull] ISpatialReference spatialReference)
     : this(spatialReference.Name, SpatialReferenceUtils.ToXmlString(spatialReference))
 {
 }