Exemplo n.º 1
0
        public void MovePolygonWithTrackersShouldBeFast()
        {
            var factory = new GeometricShapeFactory();
            factory.NumPoints = 10000; // many
            factory.Size = 300;
            var circle = factory.CreateCircle();
            var circleSource = (IGeometry) circle.Clone();

            var trackers = new List<IGeometry>();
            for (int i=0; i < circle.Coordinates.Length; i++)
            {
                trackers.Add(new Point((ICoordinate)circle.Coordinates[i].Clone()));
            }

            var handles = Enumerable.Range(0, trackers.Count).ToList();

            TestHelper.AssertIsFasterThan(40,
                                          () => noFallOffPolicy.Move(circle, circleSource, trackers, handles, 0, 5, 5));
        }
Exemplo n.º 2
0
        public void GetIntersectionAreaCircles()
        {
            var factory = new GeometricShapeFactory {Size = 20};
            var circle = factory.CreateCircle();
            factory.Centre = new Coordinate(0, 5);
            var circle2 = factory.CreateCircle();

            //self area
            Assert.AreEqual(circle.Area, GeometryHelper.GetSampledIntersectionArea(circle, circle), 10);

            var actualArea = GeometryHelper.GetIntersectionArea(circle, circle2);
            Assert.AreEqual(102.68839131234732, actualArea, 0.1);
            Assert.AreEqual(actualArea, GeometryHelper.GetSampledIntersectionArea(circle, circle2), 10);
        }
Exemplo n.º 3
0
        public void GetTimeSeriesFromTimeDependentPolygonFeatureCoverageWithCentroid()
        {
            //QueryTimeSeriesMapCommand uses centroid

            var coverage = GetTimeDependentFeatureCoverage();

            foreach(var feature in coverage.Features)
            {
                var factory = new GeometricShapeFactory();
                factory.Centre = feature.Geometry.Coordinate;
                factory.Size = 5;
                feature.Geometry = factory.CreateCircle();
            }

            var coverageName = "Waste disposal";
            coverage.Name = coverageName;

            var t1 = new DateTime(2000, 1, 1);
            var t2 = new DateTime(2000, 1, 2);
            var t3 = new DateTime(2000, 1, 3);

            //set some values for each time step
            coverage[t1] = new[] { 1.0, 2.0, 3.0 };
            coverage[t2] = new[] { 4.0, 5.0, 6.0 };
            coverage[t3] = new[] { 7.0, 8.0, 9.0 };

            //get a timeseries for the 1st feature
            var firstFeature = coverage.FeatureVariable.Values.OfType<SimpleFeature>().First();
            var featureName = "Amsterdam";
            firstFeature.Name = featureName;
            var timesSeries = coverage.GetTimeSeries(firstFeature.Geometry.Centroid.Coordinate); 
            Assert.AreEqual(new[] { t1, t2, t3 }, timesSeries.Arguments[0].Values);
            Assert.AreEqual(new[] { 1.0d, 4.0d, 7.0d }, timesSeries.Components[0].Values);
            Assert.AreEqual(coverageName + " at " + featureName, timesSeries.Name);
            //check it is reduced
            Assert.AreEqual(1, timesSeries.Arguments.Count);
        }