public void WellKnownTextConverterIdentifiedObjectTest() { // conversion from string instance String projectedUTMZone33 = "PROJCS[\"UTM Zone 33, Northern Hemisphere\",GEOGCS[\"Geographic Coordinate System\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137,298.257223560493]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",15],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]"; String UTMZone10NAD83 = "PROJCS[\"NAD_1983_UTM_Zone_10N\", GEOGCS[\"GCS_North_American_1983\", DATUM[ \"D_North_American_1983\",ELLIPSOID[\"GRS_1980\",6378137,298.257222101]], PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]], PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",500000.0], PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-123.0], PARAMETER[\"Scale_Factor\",0.9996],PARAMETER[\"Latitude_of_Origin\",0.0], UNIT[\"Meter\",1.0]]"; String geodeticBase = "GEOGCS[\"Unknown\",DATUM[\"D_Unknown\",SPHEROID[\"Clarke_1866\",6378206.4,294.978698213901]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]"; String wgs1984 = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.017453292519943295]]"; Assert.IsNotNull(WellKnownTextConverter.ToWellKnownText(WellKnownTextConverter.ToIdentifiedObject(projectedUTMZone33))); Assert.IsNotNull(WellKnownTextConverter.ToWellKnownText(WellKnownTextConverter.ToIdentifiedObject(UTMZone10NAD83))); Assert.IsNotNull(WellKnownTextConverter.ToWellKnownText(WellKnownTextConverter.ToIdentifiedObject(geodeticBase))); Assert.IsNotNull(WellKnownTextConverter.ToWellKnownText(WellKnownTextConverter.ToIdentifiedObject(wgs1984))); // conversion from identified object instance foreach (ProjectedCoordinateReferenceSystem projected in ProjectedCoordinateReferenceSystems.All) { String wkt = WellKnownTextConverter.ToWellKnownText(projected as IReferenceSystem); ProjectedCoordinateReferenceSystem converted = WellKnownTextConverter.ToIdentifiedObject(wkt) as ProjectedCoordinateReferenceSystem; Assert.AreEqual(projected, converted); } foreach (GeographicCoordinateReferenceSystem geodetic in Geographic2DCoordinateReferenceSystems.All) { String wkt = WellKnownTextConverter.ToWellKnownText(geodetic as IReferenceSystem); GeographicCoordinateReferenceSystem converted = WellKnownTextConverter.ToIdentifiedObject(wkt) as GeographicCoordinateReferenceSystem; Assert.AreEqual(geodetic, converted); } }
/// <summary> /// Writes the reference system file. /// </summary> /// <param name="referenceSystem">The reference system.</param> protected override void WriteGeometryReferenceSystem(IReferenceSystem referenceSystem) { using (StreamWriter writer = new StreamWriter(_fileSystem.CreateFile(_basePath + _fileSystem.DirectorySeparator + _baseFileName + ".prj"))) { String refSystem = WellKnownTextConverter.ToWellKnownText(referenceSystem); writer.Write(refSystem); } }
public void WellKnownTextConverterGeometryTest() { foreach (IGeometry geometry in _geometries) { String wkt = WellKnownTextConverter.ToWellKnownText(geometry); IGeometry converted = WellKnownTextConverter.ToGeometry(wkt, _factory); Assert.AreEqual(0, new GeometryComparer().Compare(geometry, converted)); } }
public void WellKnownTextConverterToWellKnownTextTest() { for (Int32 index = 0; index < this.geometries.Length; index++) { String text = WellKnownTextConverter.ToWellKnownText(this.geometries[index]); Assert.AreEqual(this.geometriesText[index], text); } Assert.Throws <ArgumentNullException>(() => WellKnownTextConverter.ToWellKnownText(null)); Assert.Throws <ArgumentException>(() => WellKnownTextConverter.ToWellKnownText(this.factory.CreatePoint(Coordinate.Empty), 1)); Assert.Throws <ArgumentException>(() => WellKnownTextConverter.ToWellKnownText(this.factory.CreateGeometryCollection <IGeometry>())); }
public void WellKnownTextConverterToWellKnownTextTest() { for (Int32 index = 0; index < this.identifiedObjects.Length - 1; index++) { String text = WellKnownTextConverter.ToWellKnownText(this.identifiedObjects[index]); IdentifiedObject identifiedObject = WellKnownTextConverter.ToIdentifiedObject(text, TestUtilities.ReferenceProvider); Assert.AreEqual(this.identifiedObjects[index], identifiedObject); } Assert.Throws <ArgumentNullException>(() => WellKnownTextConverter.ToWellKnownText((IdentifiedObject)null)); Assert.Throws <ArgumentNullException>(() => WellKnownTextConverter.ToWellKnownText((IReferenceSystem)null)); }
/// <summary> /// Writes the reference system. /// </summary> private void WriteReferenceSystem() { if (_referenceSystem == null) { return; } // writes the reference system as WKT text using (StreamWriter writer = new StreamWriter(OpenPath(ReferenceSystemFilePath))) { String text = WellKnownTextConverter.ToWellKnownText(_referenceSystem); writer.WriteLine(text); } }