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["CH1903+_LV95",GEOGCS["GCS_CH1903+",DATUM["D_CH1903+",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["False_Easting",2600000.0],PARAMETER["False_Northing",1200000.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Azimuth",90.0],PARAMETER["Longitude_Of_Center",7.439583333333333],PARAMETER["Latitude_Of_Center",46.95240555555556],UNIT["Meter",1.0],AUTHORITY["EPSG",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)); }
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)); }
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}"); } }