public void CanDetectNonUniqueSpatialReference() { ISpatialReference sref1 = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95); ISpatialReference sref2 = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV03); ISpatialReference sref3 = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); SpatialReferenceUtils.SetXYDomain(sref1, 0, 0, 1000, 1000, 0.001, 0.01); SpatialReferenceUtils.SetXYDomain(sref2, 0, 0, 1000, 1000, 0.00001, 0.0001); SpatialReferenceUtils.SetXYDomain(sref3, 0, 0, 1000, 1000, 0.0001, 0.001); var spatialReferences = new List <ISpatialReference> { sref1, sref2, sref3 }; string exception = null; try { TestUtils.GetUniqueSpatialReference(spatialReferences, requireEqualVerticalCoordinateSystems : true); } catch (Exception ex) { exception = ex.Message; } Assert.True(exception == "Coordinate systems are not equal: CH1903_LV03, CH1903+_LV95"); }
public void CanGetUniqueSpatialReferenceIgnoringVerticalCoordinateSystems() { ISpatialReference sref1 = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95); ISpatialReference sref2 = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LN02); ISpatialReference sref3 = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); const double maxRes = 0.00001; SpatialReferenceUtils.SetXYDomain(sref1, 0, 0, 1000, 1000, maxRes * 100, 0.01); SpatialReferenceUtils.SetXYDomain(sref2, 0, 0, 1000, 1000, maxRes * 10, 0.001); SpatialReferenceUtils.SetXYDomain(sref3, 0, 0, 1000, 1000, maxRes, 0.0001); var spatialReferences = new List <ISpatialReference> { sref1, sref2, sref3 }; ISpatialReference uniqueSpatialReference = TestUtils.GetUniqueSpatialReference( spatialReferences, requireEqualVerticalCoordinateSystems: false); Assert.IsNotNull(uniqueSpatialReference); Assert.AreEqual(maxRes, SpatialReferenceUtils.GetXyResolution( uniqueSpatialReference)); }
private static ISpatialReference CreateLV95() { ISpatialReference result = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(result, -10000, -10000, 10000, 10000, 0.0001, _xyTolerance); return(result); }
private static ISpatialReference CreateSpatialReference() { ISpatialReference result = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, true); SpatialReferenceUtils.SetXYDomain(result, -100000, -100000, 100000, 100000, _resolution, _tolerance); return(result); }
private static ISpatialReference CreateSpatialReference() { ISpatialReference spatialReference = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); SpatialReferenceUtils.SetXYDomain(spatialReference, -1000, -1000, 1000, 1000, 0.0001, 0.001); return(spatialReference); }
private static ISpatialReference CreateSpatialReference() { const bool defaultXyDomain = true; ISpatialReference spatialReference = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, defaultXyDomain); SpatialReferenceUtils.SetXYDomain(spatialReference, -10000, -10000, 10000, 10000, 0.001, 0.01); return(spatialReference); }
private static ISpatialReference CreateSpatialReference(double mTolerance, double xyTolerance) { ISpatialReference result = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetMDomain(result, 0, 1000000, mTolerance / 10, mTolerance); SpatialReferenceUtils.SetXYDomain(result, -1000, -1000, 100000, 100000, xyTolerance / 10, xyTolerance); return(result); }
public void SetUp() { _spatialReference = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903_LV03, true); SpatialReferenceUtils.SetXYDomain(_spatialReference, -1000, -1000, 1000, 1000, _tolerance / 10, _tolerance); Console.WriteLine(((ISpatialReferenceTolerance)_spatialReference).XYTolerance); _tile11 = CreateEnvelope(0, 0, 50, 50); _tile12 = CreateEnvelope(50, 0, 100, 50); _tile21 = CreateEnvelope(0, 50, 50, 100); _tile22 = CreateEnvelope(50, 50, 100, 100); }
public void SetupFixture() { _lic.Checkout(); _spatialReference = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, (int)esriSRVerticalCSType.esriSRVertCS_Landeshohennetz1995); SpatialReferenceUtils.SetXYDomain(_spatialReference, -100, -100, 1000, 1000, 0.0001, 0.001); SpatialReferenceUtils.SetZDomain(_spatialReference, -100, 5000, 0.0001, 0.001); }
public void TestUniqueGuid() { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateField("UniqueValue", esriFieldType.esriFieldTypeGUID), FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPoint, sref, 1000)); IFeatureClass featureClass1 = DatasetUtils.CreateSimpleFeatureClass(_fgdbWorkspace, "TestUniqueGuid", fields); for (var i = 0; i < 10; i++) { IFeature feature = featureClass1.CreateFeature(); feature.set_Value(1, Guid.NewGuid().ToString("B")); feature.Shape = GeometryFactory.CreatePoint(100, 100, sref); feature.Store(); } for (var i = 0; i < 2; i++) { IFeature emptyFeature = featureClass1.CreateFeature(); emptyFeature.set_Value(1, null); emptyFeature.Shape = GeometryFactory.CreatePoint(100, 100, sref); emptyFeature.Store(); } foreach (bool forceInMemoryTableSort in new[] { true, false }) { var test = new QaUnique((ITable)featureClass1, "UniqueValue") { ForceInMemoryTableSorting = forceInMemoryTableSort }; var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(2, runner.Errors.Count); } }
private IFeatureClass CreateFeatureClass([NotNull] string name, esriGeometryType type, bool zAware = false) { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, setDefaultXyDomain: true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateShapeField("Shape", type, sref, 1000, zAware)); return(DatasetUtils.CreateSimpleFeatureClass(_testWs, name, fields)); }
public void CanReduceToleranceIfTooSmall() { const double toleranceFactor = 0.1; const double resolution = 0.0001; const double tolerance = resolution * 2; ISpatialReference spatialReference = SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95); SpatialReferenceUtils.SetXYDomain(spatialReference, 0, 0, 5000000, 5000000, resolution, tolerance); const bool allowResolutionChange = true; CanReduceTolerance(spatialReference, toleranceFactor, allowResolutionChange); }
public void TestUniqueStrings() { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("Unique", 100), FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPoint, sref, 1000)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass(_pgdbWorkspace, "TestUniqueStrings", fields); for (var i = 0; i < 10; i++) { IFeature feature = featureClass.CreateFeature(); feature.set_Value(1, string.Format("A'{0}{1}", i, "\"")); feature.Shape = GeometryFactory.CreatePoint(100, 100, sref); feature.Store(); } IEnvelope testEnvelope = GeometryFactory.CreateEnvelope(0, 0, 200, 200, sref); foreach (bool forceInMemoryTableSort in new[] { false, true }) { var test = new QaUnique((ITable)featureClass, "Unique") { ForceInMemoryTableSorting = forceInMemoryTableSort }; var runner = new QaTestRunner(test); runner.Execute(testEnvelope); AssertUtils.NoError(runner); } }
private IFeatureClass CreateFeatureClass([NotNull] string name, esriGeometryType geometryType, params IField[] attributeFields) { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); var fields = new List <IField> { FieldUtils.CreateOIDField(), FieldUtils.CreateShapeField("Shape", geometryType, sref, 1000) }; fields.AddRange(attributeFields); return(DatasetUtils.CreateSimpleFeatureClass(_testWs, name, FieldUtils.CreateFields(fields))); }
private IFeatureClass CreateFeatureClass([NotNull] string name, esriGeometryType type, [NotNull] string urlFieldName) { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int) esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); const bool mAware = false; const bool hasZ = false; IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateShapeField("Shape", type, sref, 1000, hasZ, mAware), FieldUtils.CreateTextField(urlFieldName, 500)); return DatasetUtils.CreateSimpleFeatureClass(_testWs, name, fields); }
private void CreateSpatialReferences() { _wgs84 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRGeoCSType.esriSRGeoCS_WGS1984); SpatialReferenceUtils.SetXYDomain(_wgs84, -180, -90, 180, 90, 0.00001, 0.0001); SpatialReferenceUtils.SetZDomain(_wgs84, -100, 5000, 0.0001, 0.1); _lv03lhn95_xytol_01_ztol_01 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903_LV03, (int)esriSRVerticalCSType.esriSRVertCS_Landeshohennetz1995); SpatialReferenceUtils.SetXYDomain(_lv03lhn95_xytol_01_ztol_01, -100, -100, 1000, 1000, 0.0001, 0.1); SpatialReferenceUtils.SetZDomain(_lv03lhn95_xytol_01_ztol_01, -100, 5000, 0.0001, 0.1); _lv95_xytol_01_ztol_01 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95); SpatialReferenceUtils.SetXYDomain(_lv95_xytol_01_ztol_01, -100, -100, 1000, 1000, 0.0001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95_xytol_01_ztol_01, -100, 5000, 0.0001, 0.1); _lv95lhn95_xytol_01_ztol_02 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, (int)esriSRVerticalCSType.esriSRVertCS_Landeshohennetz1995); SpatialReferenceUtils.SetXYDomain(_lv95lhn95_xytol_01_ztol_02, -100, -100, 1000, 1000, 0.0001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95lhn95_xytol_01_ztol_02, -100, 5000, 0.0001, 0.2); _lv95lhn95_xytol_01_ztol_01 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, (int)esriSRVerticalCSType.esriSRVertCS_Landeshohennetz1995); SpatialReferenceUtils.SetXYDomain(_lv95lhn95_xytol_01_ztol_01, -100, -100, 1000, 1000, 0.0001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95lhn95_xytol_01_ztol_01, -100, 5000, 0.0001, 0.1); _lv95ln02_xytol_01_ztol_01 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, (int)esriSRVerticalCSType.esriSRVertCS_Landesnivellement1902); SpatialReferenceUtils.SetXYDomain(_lv95ln02_xytol_01_ztol_01, -100, -100, 1000, 1000, 0.0001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95ln02_xytol_01_ztol_01, -100, 5000, 0.0001, 0.1); _lv95_xytol_02_ztol_01 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95); SpatialReferenceUtils.SetXYDomain(_lv95_xytol_02_ztol_01, -100, -100, 1000, 1000, 0.0001, 0.2); SpatialReferenceUtils.SetZDomain(_lv95_xytol_02_ztol_01, -100, 5000, 0.0001, 0.1); _lv95_xyres_001_zres_001 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95); SpatialReferenceUtils.SetXYDomain(_lv95_xyres_001_zres_001, -100, -100, 1000, 1000, 0.001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95_xyres_001_zres_001, -100, 5000, 0.001, 0.1); _lv95_xyres_001_zres_001_largerdomains = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95); SpatialReferenceUtils.SetXYDomain(_lv95_xyres_001_zres_001_largerdomains, -10000, -10000, 100000, 100000, 0.001, 0.1); // note: a different ZMin value makes the ZPrecision different // (the same thing is not true for xy precision: domain differences alone // don't make the precision different, as long as the grids are compatible) SpatialReferenceUtils.SetZDomain(_lv95_xyres_001_zres_001_largerdomains, -100, 10000, 0.001, 0.1); _lv95_xyres_001_zres_001_offsetdomains = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95); SpatialReferenceUtils.SetXYDomain(_lv95_xyres_001_zres_001_offsetdomains, -100.0001, -100, 1000, 1000, 0.001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95_xyres_001_zres_001_offsetdomains, -100.0001, 5000, 0.001, 0.1); _lv95_xyres_001_zres_002 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, (int)esriSRVerticalCSType.esriSRVertCS_Landesnivellement1902); SpatialReferenceUtils.SetXYDomain(_lv95_xyres_001_zres_002, -100, -100, 1000, 1000, 0.001, 0.1); SpatialReferenceUtils.SetZDomain(_lv95_xyres_001_zres_002, -100, 5000, 0.001, 0.2); _lv95_xyres_002_zres_001 = SpatialReferenceUtils.CreateSpatialReference( (int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95); SpatialReferenceUtils.SetXYDomain(_lv95_xyres_002_zres_001, -100, -100, 1000, 1000, 0.002, 0.1); SpatialReferenceUtils.SetZDomain(_lv95_xyres_002_zres_001, -100, 5000, 0.001, 0.1); }
public void TestUniqueStringsMulti() { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("Unique", 100), FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPoint, sref, 1000)); IFeatureClass featureClass1 = DatasetUtils.CreateSimpleFeatureClass(_pgdbWorkspace, "TestUniqueStringsMulti1", fields); IFeatureClass featureClass2 = DatasetUtils.CreateSimpleFeatureClass(_pgdbWorkspace, "TestUniqueStringsMulti2", fields); for (var i = 0; i < 10; i++) { IFeature feature = featureClass1.CreateFeature(); feature.set_Value(1, string.Format("A'{0}{1}", i, "\"")); feature.Shape = GeometryFactory.CreatePoint(100, 100, sref); feature.Store(); } for (var i = 0; i < 2; i++) { IFeature emptyFeature = featureClass1.CreateFeature(); emptyFeature.set_Value(1, null); emptyFeature.Shape = GeometryFactory.CreatePoint(100, 100, sref); emptyFeature.Store(); } for (var i = 0; i < 10; i++) { IFeature feature = featureClass2.CreateFeature(); feature.set_Value(1, string.Format("B'{0}{1}", i, "\"")); feature.Shape = GeometryFactory.CreatePoint(100, 100, sref); feature.Store(); } for (var i = 0; i < 2; i++) { IFeature emptyFeature = featureClass2.CreateFeature(); emptyFeature.set_Value(1, null); emptyFeature.Shape = GeometryFactory.CreatePoint(100, 100, sref); emptyFeature.Store(); } foreach (bool forceInMemoryTableSort in new[] { true, false }) { var test = new QaUnique(new[] { (ITable)featureClass1, (ITable)featureClass2 }, new[] { "Unique", "Unique" }) { ForceInMemoryTableSorting = forceInMemoryTableSort }; var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(4, runner.Errors.Count); } }
private static void TestStringsWithNulls([NotNull] IFeatureWorkspace workspace) { ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true); SpatialReferenceUtils.SetXYDomain(sref, -10000, -10000, 10000, 10000, 0.0001, 0.001); IFields fields = FieldUtils.CreateFields( FieldUtils.CreateOIDField(), FieldUtils.CreateTextField("Unique", 100), FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPoint, sref, 1000)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass( workspace, "TestStringsWithNulls", fields); IFeature f = featureClass.CreateFeature(); f.Shape = GeometryFactory.CreatePoint(100, 100, sref); f.Store(); for (var i = 0; i < 300; i++) { IFeature feature = featureClass.CreateFeature(); feature.set_Value(1, string.Format("A'{0}{1}", i, "\"")); feature.Shape = GeometryFactory.CreatePoint(100, 100, sref); feature.Store(); } f = featureClass.CreateFeature(); f.set_Value(1, string.Format("A'{0}{1}", 4, "\"")); f.Shape = GeometryFactory.CreatePoint(100, 100, sref); f.Store(); f = featureClass.CreateFeature(); f.Shape = GeometryFactory.CreatePoint(300, 100, sref); f.Store(); IEnvelope testEnvelope = GeometryFactory.CreateEnvelope(0, 0, 200, 200, sref); foreach (bool forceInMemoryTableSort in new[] { true, false }) { var test = new QaUnique((ITable)featureClass, "Unique", maxRows: 200) { ForceInMemoryTableSorting = forceInMemoryTableSort }; using (var runner = new QaTestRunner(test)) { runner.Execute(); Assert.AreEqual(4, runner.Errors.Count); } using (var runner = new QaTestRunner(test)) { runner.Execute(testEnvelope); Assert.AreEqual(4, runner.Errors.Count); } using (var runner = new QaTestRunner(test)) { runner.Execute(); Assert.AreEqual(4, runner.Errors.Count); } using (var runner = new QaTestRunner(test)) { runner.Execute(testEnvelope); Assert.AreEqual(4, runner.Errors.Count); } } }