Exemplo n.º 1
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);
        }