Exemplo n.º 1
0
        /// <summary>
        /// Substitutes each layer input with datasource input .
        /// </summary>
        /// <remarks>
        /// Must be done immediately before the async execution when validation was passed.
        /// Layer inputs can't be accessed from background thread, since they are bound to map control.</remarks>
        public static void ExtractDatasources(this IEnumerable <BaseParameter> parameters)
        {
            foreach (var p in parameters.OfType <LayerParameterBase>())
            {
                var input = p.Value as LayerInput;
                if (input != null)
                {
                    var dsInput = new DatasourceInput(input.Layer)
                    {
                        SelectedOnly = input.SelectedOnly
                    };

                    p.SetToolValue(dsInput);
                    input.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        public void TestRandomPointsVectorSelected()
        {
            _timer.Restart();
            var fs = OpenFeatureSet(Path.Combine(UsaShapefilesPath, "cities.shp"));
            // Create Vector layer:
            var vector = new DatasourceInput(fs) as IVectorInput;

            vector.SelectedOnly = true;
            // Select first feature:
            vector.Datasource.Features[0].Selected = true;

            const int NumPoints = 5000;

            Debug.Write(string.Format("Creating {0} random points", NumPoints));
            var tool = new RandomPointsTool {
                NumPoints = NumPoints, InputLayer = vector, OutputLayer = new OutputLayerInfo {
                    MemoryLayer = true
                }
            };

            RunTool(tool);

            Debug.Write(" ... ");
            var result = tool.OutputLayer.Result as IFeatureSet;

            Assert.IsNotNull(result);

            // Check number of features:
            Assert.AreEqual(result.NumFeatures, NumPoints);

            // Check envelop:
            Assert.IsTrue(vector.Datasource.GetSelectedExtents().EqualsTo(result.Envelope, 1), "The resulting envelop is not equal to the input envelop");
            Debug.Write(" ..the resulting envelope is OK.. ");

            result.Dispose();
            Debug.WriteLine(" Done!");
            Debug.WriteLine("Elapsed time " + GetDateString(_timer.ElapsedMilliseconds));
        }