예제 #1
0
        private static ISpatialReference CreateDefaultSpatialReference()
        {
            const string xml =
                @"<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/9.3'><WKT>PROJCS[&quot;CH1903+_LV95&quot;,GEOGCS[&quot;GCS_CH1903+&quot;,DATUM[&quot;D_CH1903+&quot;,SPHEROID[&quot;Bessel_1841&quot;,6377397.155,299.1528128]],PRIMEM[&quot;Greenwich&quot;,0.0],UNIT[&quot;Degree&quot;,0.0174532925199433]],PROJECTION[&quot;Hotine_Oblique_Mercator_Azimuth_Center&quot;],PARAMETER[&quot;False_Easting&quot;,2600000.0],PARAMETER[&quot;False_Northing&quot;,1200000.0],PARAMETER[&quot;Scale_Factor&quot;,1.0],PARAMETER[&quot;Azimuth&quot;,90.0],PARAMETER[&quot;Longitude_Of_Center&quot;,7.439583333333333],PARAMETER[&quot;Latitude_Of_Center&quot;,46.95240555555556],UNIT[&quot;Meter&quot;,1.0],AUTHORITY[&quot;EPSG&quot;,2056]]</WKT><XOrigin>-27386400</XOrigin><YOrigin>-32067900</YOrigin><XYScale>800</XYScale><ZOrigin>-100000</ZOrigin><ZScale>800</ZScale><MOrigin>0</MOrigin><MScale>1</MScale><XYTolerance>0.0125</XYTolerance><ZTolerance>0.0125</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>2056</WKID></ProjectedCoordinateSystem>";

            return(SpatialReferenceUtils.FromXmlString(xml));
        }
예제 #2
0
        private ISpatialReference CreateSpatialReference()
        {
            if (string.IsNullOrEmpty(_xmlString))
            {
                throw new InvalidConfigurationException(
                          "Spatial reference xml string not defined");
            }

            return(SpatialReferenceUtils.FromXmlString(_xmlString));
        }
 public QaSchemaSpatialReference(
     [Doc(nameof(DocStrings.QaSchemaSpatialReference_featureClass))][NotNull]
     IFeatureClass featureClass,
     [Doc(nameof(DocStrings.QaSchemaSpatialReference_spatialReferenceXml))][NotNull]
     string
     spatialReferenceXml,
     bool compareXYPrecision,
     bool compareZPrecision,
     bool compareMPrecision,
     bool compareTolerances,
     bool compareVerticalCoordinateSystems)
     : this(featureClass,
            SpatialReferenceUtils.FromXmlString(spatialReferenceXml),
            compareXYPrecision, compareZPrecision, compareMPrecision,
            compareTolerances, compareTolerances, compareTolerances,
            compareVerticalCoordinateSystems)
 {
 }
        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));
        }
예제 #5
0
        public static ISpatialReference FromSpatialReferenceMsg(
            [CanBeNull] SpatialReferenceMsg spatialRefMsg,
            [CanBeNull] ISpatialReference classSpatialRef = null)
        {
            if (spatialRefMsg == null)
            {
                return(null);
            }

            switch (spatialRefMsg.FormatCase)
            {
            case SpatialReferenceMsg.FormatOneofCase.None:
                return(null);

            case SpatialReferenceMsg.FormatOneofCase.SpatialReferenceEsriXml:

                string xml = spatialRefMsg.SpatialReferenceEsriXml;

                return(string.IsNullOrEmpty(xml)
                                                       ? null
                                                       : SpatialReferenceUtils.FromXmlString(xml));

            case SpatialReferenceMsg.FormatOneofCase.SpatialReferenceWkid:

                int wkId = spatialRefMsg.SpatialReferenceWkid;

                return(classSpatialRef?.FactoryCode == wkId
                                                       ? classSpatialRef
                                                       : SpatialReferenceUtils.CreateSpatialReference(wkId));

            case SpatialReferenceMsg.FormatOneofCase.SpatialReferenceWkt:

                return(SpatialReferenceUtils.ImportFromESRISpatialReference(
                           spatialRefMsg.SpatialReferenceWkt));

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