Exemple #1
0
        public void SnapToLineStringUsingFreeAtObject()
        {
            var mockRepository = new MockRepository();
            var feature        = mockRepository.CreateMock <IFeature>();

            using (mockRepository.Record())
            {
                Expect.Call(feature.Geometry).Return(lineString).Repeat.Any();
            }

            using (mockRepository.Playback())
            {
                var features = new [] { feature };
                var layers   = new[] { new VectorLayer() };

                IPoint   snapSource = new Point(5, 5);
                SnapRule snapRule   = new SnapRule
                {
                    SnapRole     = SnapRole.FreeAtObject,
                    Obligatory   = true,
                    PixelGravity = 40
                };

                SnapResult snapResults = snapRule.Execute(null, features, layers, snapSource, null,
                                                          snapSource.Coordinates[0],
                                                          CreateEnvelope(snapSource, 10),
                                                          0);
                Assert.IsNotNull(snapResults);
                Assert.IsNotNull(snapResults.Location);
                Assert.AreEqual(0, snapResults.Location.Y);
                Assert.AreEqual(5, snapResults.Location.X);
            }
        }
Exemple #2
0
        public void SnapToLineStringUsingFreeAtObject()
        {
            MockRepository mockRepository = new MockRepository();
            IFeature       feature        = mockRepository.CreateMock <IFeature>();

            using (mockRepository.Record())
            {
                Expect.Call(feature.Geometry).Return(lineString).Repeat.Any();
            }
            using (mockRepository.Playback())
            {
                VectorLayer lineStringLayer = new VectorLayer
                {
                    DataSource = new FeatureCollection
                    {
                        Features = new List <IFeature> {
                            feature
                        }
                    }
                };

                IPoint   snapSource = new Point(5, 5);
                SnapRule snapRule   = new SnapRule
                {
                    TargetLayer  = lineStringLayer,
                    SnapRole     = SnapRole.FreeAtObject,
                    Obligatory   = true,
                    PixelGravity = 40
                };

                ISnapResult snapResults = snapRule.Execute(null, snapSource, null,
                                                           snapSource.Coordinates[0],
                                                           CreateEnvelope(snapSource, 10),
                                                           0);
                Assert.IsNotNull(snapResults);
                Assert.IsNotNull(snapResults.Location);
                Assert.AreEqual(0, snapResults.Location.Y);
                Assert.AreEqual(5, snapResults.Location.X);
            }
        }