public void TestSqlServer2008ExProviderOverridesValidateGeometries(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { NUnit.Framework.Assert.Throws <System.ArgumentException>(() => { var sq = GetTestProvider(SqlServerProviderMode.NativeSqlBytes, spatialType); sq.ValidateGeometries = false; }); }
public void TestGetFeatureNonExisting(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); var feature = sq.GetFeature(99999999); NUnit.Framework.Assert.IsNull(feature); }
public void TestGetFeatureCount(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(spatialType); int count = sq.GetFeatureCount(); // includes NULL, EMPTY, and INVALID geoms NUnit.Framework.Assert.AreEqual(_numFeatures, count); }
public void TestGetObjectIDsInView(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(spatialType); sq.ValidateGeometries = validateGeometries; var objectIds = sq.GetObjectIDsInView(GetTestEnvelope(spatialType)); NUnit.Framework.Assert.AreEqual(sq.ValidateGeometries ? _numValidatedGeoms : _numValidGeoms, objectIds.Count); }
public void TestGetFeatureEmptyGeometry(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); var feature = sq.GetFeature(_idEmptyGeom); NUnit.Framework.Assert.IsNotNull(feature); NUnit.Framework.Assert.IsTrue(feature.Geometry.IsEmpty); }
public void TestGetExtentsQueryIndividualFeatures(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(spatialType); sq.ExtentsMode = SharpMap.Data.Providers.SqlServer2008ExtentsMode.QueryIndividualFeatures; GeoAPI.Geometries.Envelope extents = sq.GetExtents(); NUnit.Framework.Assert.IsNotNull(extents); }
public void TestGetFeatureCountWithDefinitionQuery(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(SqlServerProviderMode.WellKnownBinary, spatialType); sq.DefinitionQuery = "NAME LIKE 'A%'"; int count = sq.GetFeatureCount(); NUnit.Framework.Assert.LessOrEqual(count, _numValidGeoms); }
public void TestGetGeometriesInView(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.ValidateGeometries = validateGeometries; var geometries = sq.GetGeometriesInView(GetTestEnvelope(spatialType)); NUnit.Framework.Assert.IsNotNull(geometries); NUnit.Framework.Assert.AreEqual(sq.ValidateGeometries ? _numValidatedGeoms : _numValidGeoms, geometries.Count); }
/// <summary> /// Get the envelope of the entire roads_ugl file /// </summary> private GeoAPI.Geometries.Envelope GetTestEnvelope(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { var env = SharpMap.Converters.WellKnownText.GeometryFromWKT.Parse("POLYGON ((-97.23724071609665 41.698023105763589, -82.424263624596563 41.698023105763589, -82.424263624596563 49.000629000758515, -97.23724071609665 49.000629000758515, -97.23724071609665 41.698023105763589))").EnvelopeInternal; if (spatialType == SharpMap.Data.Providers.SqlServerSpatialObjectType.Geography) { // Geography works with boundaries on the spheroid (not rectilinear), so enlarge to ensure we get all features env.ExpandBy(0.2); } return(env); }
public void TestExecuteIntersectionQuery(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.ValidateGeometries = validateGeometries; SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); sq.ExecuteIntersectionQuery(GetTestEnvelope(spatialType), ds); NUnit.Framework.Assert.AreEqual(sq.ValidateGeometries ? _numValidatedGeoms : _numValidGeoms, ds.Tables[0].Rows.Count); }
public void TestGetExtentsSpatialIndex(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(spatialType); if (spatialType == SharpMap.Data.Providers.SqlServerSpatialObjectType.Geography) { var ex = NUnit.Framework.Assert.Throws <System.ArgumentOutOfRangeException>(() => { sq.ExtentsMode = SharpMap.Data.Providers.SqlServer2008ExtentsMode.SpatialIndex; }); } else { sq.ExtentsMode = SharpMap.Data.Providers.SqlServer2008ExtentsMode.SpatialIndex; GeoAPI.Geometries.Envelope extents = sq.GetExtents(); NUnit.Framework.Assert.IsNotNull(extents); } }
public void TestGetExtentsEnvelopeAggregate(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { using (SqlConnection conn = new SqlConnection(UnitTests.Properties.Settings.Default.SqlServer2008)) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT SERVERPROPERTY('productversion')"; string productversion = (string)cmd.ExecuteScalar(); if (System.Version.Parse(productversion).Major < 11) { NUnit.Framework.Assert.Ignore("Requires SQL Server 2012 connection"); } } } SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(spatialType); sq.ExtentsMode = SharpMap.Data.Providers.SqlServer2008ExtentsMode.EnvelopeAggregate; GeoAPI.Geometries.Envelope extents = sq.GetExtents(); NUnit.Framework.Assert.IsNotNull(extents); }
public void TestExecuteIntersectionQueryAllHints(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.NoLockHint = true; sq.ForceSeekHint = true; sq.ForceIndex = spatialType == SharpMap.Data.Providers.SqlServerSpatialObjectType.Geometry ? GeometrySpatialIndex : GeographySpatialIndex;; sq.ValidateGeometries = validateGeometries; SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); sq.ExecuteIntersectionQuery(GetTestEnvelope(spatialType), ds); // Note: ValidateGeometries ignored when using ForceSeek or ForceIndex NUnit.Framework.Assert.AreEqual(_numValidGeoms, ds.Tables[0].Rows.Count); }
public void TestExecuteIntersectionQueryExceedGeogMaxExtents(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, double x1, double x2, double y1, double y2) { // occurs when user zooms out beyond map extents. For Geog, when latitude approaches 90 N or S can result in // error 24206: "The specified input cannot be accepted because it contains an edge with antipodal points." // Longitudes exceeding -179.99999999 or 180.0 are "wrapped" resulting in unexpected polygon (also contributes to err 24206) SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); sq.ExecuteIntersectionQuery(new GeoAPI.Geometries.Envelope(x1, x2, y1, y2), ds); NUnit.Framework.Assert.AreEqual(sq.ValidateGeometries ? _numValidatedGeoms : _numValidGeoms, ds.Tables[0].Rows.Count); }
private SharpMap.Data.Providers.SqlServer2008 GetTestProvider(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 provider; switch (providerMode) { case SqlServerProviderMode.NativeSqlBytes: //Assert.Ignore("Ignore SharpMap.Data.Providers.SqlServer2008Ex"); if (spatialType == SharpMap.Data.Providers.SqlServerSpatialObjectType.Geography) { // NB note forcing WGS84 provider = new SharpMap.Data.Providers.SqlServer2008Ex(UnitTests.Properties.Settings.Default.SqlServer2008, "roads_ugl_geog", "GEOG", "ID", spatialType, GeographySrid, SharpMap.Data.Providers.SqlServer2008ExtentsMode.QueryIndividualFeatures); } else { provider = new SharpMap.Data.Providers.SqlServer2008Ex(UnitTests.Properties.Settings.Default.SqlServer2008, "roads_ugl_geom", "GEOM", "ID", spatialType, _geometrySrid, SharpMap.Data.Providers.SqlServer2008ExtentsMode.QueryIndividualFeatures); } break; default: if (spatialType == SharpMap.Data.Providers.SqlServerSpatialObjectType.Geography) { // NB note forcing WGS84 provider = new SharpMap.Data.Providers.SqlServer2008(UnitTests.Properties.Settings.Default.SqlServer2008, "roads_ugl_geog", "GEOG", "ID", spatialType, GeographySrid, SharpMap.Data.Providers.SqlServer2008ExtentsMode.QueryIndividualFeatures); } else { provider = new SharpMap.Data.Providers.SqlServer2008(UnitTests.Properties.Settings.Default.SqlServer2008, "roads_ugl_geom", "GEOM", "ID", spatialType, _geometrySrid, SharpMap.Data.Providers.SqlServer2008ExtentsMode.QueryIndividualFeatures); } break; } //provider.ValidateGeometries = true //provider.DefinitionQuery = "ID NOT IN (103)" // Invalid Geom return(provider); }
public void TestGetGeometriesInViewDefinitionQuery(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.DefinitionQuery = "NAME LIKE 'A%'"; var geometries = sq.GetGeometriesInView(GetTestEnvelope(spatialType)); NUnit.Framework.Assert.IsNotNull(geometries); NUnit.Framework.Assert.LessOrEqual(geometries.Count, _numValidGeoms); }
public void TestGetGeometriesInViewFORCESEEK(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.ForceSeekHint = true; sq.ValidateGeometries = validateGeometries; var geometries = sq.GetGeometriesInView(GetTestEnvelope(spatialType)); NUnit.Framework.Assert.IsNotNull(geometries); // NOTE ValidateGeometries is ignored when using ForceSeek NUnit.Framework.Assert.AreEqual(_numValidGeoms, geometries.Count); }
public void TestGetGeometriesInViewAllHints(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.NoLockHint = true; sq.ForceSeekHint = true; sq.ForceIndex = spatialType == SharpMap.Data.Providers.SqlServerSpatialObjectType.Geometry ? GeometrySpatialIndex : GeographySpatialIndex; sq.ValidateGeometries = validateGeometries; var geometries = sq.GetGeometriesInView(GetTestEnvelope(spatialType)); NUnit.Framework.Assert.IsNotNull(geometries); // Note: ValidateGeometries is ignored when using ForceSeek or ForceIndex NUnit.Framework.Assert.AreEqual(_numValidGeoms, geometries.Count); }
public void TestGetFeatureInvalidGeometry(SqlServerProviderMode providerMode, SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType, bool validateGeometries) { SharpMap.Data.Providers.SqlServer2008 sq = GetTestProvider(providerMode, spatialType); sq.ValidateGeometries = validateGeometries; var feature = sq.GetFeature(_idInvalidGeom); NUnit.Framework.Assert.IsNotNull(feature); if (providerMode == SqlServerProviderMode.NativeSqlBytes) { // client side conversion always attempts validation NUnit.Framework.Assert.IsTrue(!feature.Geometry.IsEmpty && feature.Geometry.IsValid); } else { if (validateGeometries) { NUnit.Framework.Assert.IsTrue(!feature.Geometry.IsEmpty && feature.Geometry.IsValid); } else { NUnit.Framework.Assert.IsTrue(feature.Geometry.IsEmpty); } } }
private SharpMap.Data.Providers.SqlServer2008 GetTestProvider(SharpMap.Data.Providers.SqlServerSpatialObjectType spatialType) { return(GetTestProvider(SqlServerProviderMode.WellKnownBinary, spatialType)); }