public void TestPostGISFullVersion() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { var fullVersion = db.Select(() => VersionFunctions.PostGISFullVersion()); Assert.IsNotNull(fullVersion); // Just to see in test runner output Console.WriteLine(new String('-', 40)); Console.WriteLine(fullVersion); Console.WriteLine(new String('-', 40)); var geosVersion = db.Select(() => VersionFunctions.PostGISGEOSVersion()); Console.WriteLine($"GEOS={geosVersion}"); var liblwgeomVersion = db.Select(() => VersionFunctions.PostGISLiblwgeomVersion()); Console.WriteLine($"liblwgeom={liblwgeomVersion}"); var libXmlVersion = db.Select(() => VersionFunctions.PostGISLibXMLVersion()); Console.WriteLine($"LibXML={libXmlVersion}"); var libBuildDate = db.Select(() => VersionFunctions.PostGISLibBuildDate()); Console.WriteLine($"PostGIS lib build date={libBuildDate}"); var libVersion = db.Select(() => VersionFunctions.PostGISLibVersion()); Console.WriteLine($"PostGIS lib version={libVersion}"); var projVersion = db.Select(() => VersionFunctions.PostGISPROJVersion()); Console.WriteLine($"PROJ4={projVersion}"); var currentVersion = new Version(db.Select(() => VersionFunctions.PostGISLibVersion())); if (currentVersion >= new Version("3.0")) { var wagyuVersion = db.Select(() => VersionFunctions.PostGISWagyuVersion()); Console.WriteLine($"Wagyu={wagyuVersion}"); } var scriptsBuildDate = db.Select(() => VersionFunctions.PostGISScriptsBuildDate()); Console.WriteLine($"PostGIS scripts build date={scriptsBuildDate}"); var scripts = db.Select(() => VersionFunctions.PostGISScriptsInstalled()); Console.WriteLine($"PostGIS scripts={scripts}"); var postGisVersion = db.Select(() => VersionFunctions.PostGISVersion()); Console.WriteLine($"PostGIS version={postGisVersion}"); Console.WriteLine(new String('-', 40)); } }
public void TestSTReducePrecision() { using (var db = new PostGisTestDataConnection(TestDatabaseConnectionString)) { // TODO: ? Some helper version classes / attributes for methods? var version = new Version(db.Select(() => VersionFunctions.PostGISLibVersion())); var geos = db.Select(() => VersionFunctions.PostGISGEOSVersion()); var geosVersion = geos != null ? new Version(geos.Substring(0, geos.IndexOf('-'))) : null; if ((version >= new Version("3.1.0")) && (geosVersion != null) && (geosVersion >= new Version("3.9"))) // TODO: ? const { const string Wkt = "POINT(1.412 19.323)"; Assert.AreEqual( "POINT(1.4 19.3)", db.Select(() => GeometryInput .STGeomFromText(Wkt) .STReducePrecision(0.1) .STAsText())); Assert.AreEqual( "POINT(1 19)", db.Select(() => GeometryInput .STGeomFromText(Wkt) .STReducePrecision(1.0) .STAsText())); Assert.AreEqual( "POINT(0 20)", db.Select(() => GeometryInput .STGeomFromText(Wkt) .STReducePrecision(10.0) .STAsText())); } } }