예제 #1
0
        private void OnMakeColorMapClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                ArcGISImageServiceLayer lyr           = map1.Layers[0] as ArcGISImageServiceLayer;
                RenderingRule           renderingRule = new RenderingRule();
                // Note: The .RasterFunctonName must use the text string 'Colormap'.
                renderingRule.RasterFunctionName = "Colormap";

                // Note: the .VariableName must use the text string 'Raster'.
                renderingRule.VariableName = "Raster";

                // Define a Dictionary object with String/Object pairs. The Strings that are used for the keys as
                // Dictionary entries will need to have exact text strings depending on what raster function is being used.
                Dictionary <string, object> rasterParams = new Dictionary <string, object>();

                // Example #1: Create a random set of colors for the color map.
                // Note: The a key of 'ColormapName' takes the string 'Random'.

                rasterParams.Add("ColormapName", RasterParamCombo.SelectionBoxItem.ToString());
                // Add the rasterParms Dictionary as the RenderingRule's RasterFunctionArguments.
                renderingRule.RasterFunctionArguments = rasterParams;
                // Apply the user defined myRenderingRule to the ArcGISImageServiceLayer's .RenderingRule
                lyr.RenderingRule = renderingRule;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error making color map: " + ex.Message);
            }
        }
        /// <summary>
        /// Called when a rendering rule info name is changed in the combo box
        /// </summary>
        private void comboBox_RenderingRuleChooser_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Loop through each rendering rule info in the image service raster
            foreach (RenderingRuleInfo myRenderingRuleInfo in _myReadOnlyListRenderRuleInfos)
            {
                // Get the name of the rendering rule info
                string myRenderingRuleName = myRenderingRuleInfo.Name;

                // If the name of the rendering rule info matches what was chosen in the combo box, proceed
                if (myRenderingRuleName == (string)RenderingRuleChooser.SelectedItem)
                {
                    // Create a new rendering rule from the rendering rule info
                    RenderingRule myRenderingRule = new RenderingRule(myRenderingRuleInfo);

                    // Create a new image service raster
                    ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(_myUri)
                    {
                        // Set the image service raster's rendering rule to the rendering rule created earlier
                        RenderingRule = myRenderingRule
                    };

                    // Create a new raster layer from the image service raster
                    RasterLayer myRasterLayer = new RasterLayer(myImageServiceRaster);

                    // Add the raster layer to the operational layers of the  map view
                    MyMapView.Map.OperationalLayers.Add(myRasterLayer);
                }
            }
        }
        private void OnMakeColorMapClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                ArcGISImageServiceLayer lyr = map1.Layers[0] as ArcGISImageServiceLayer;
                RenderingRule renderingRule = new RenderingRule();
                // Note: The .RasterFunctonName must use the text string 'Colormap'.
                renderingRule.RasterFunctionName = "Colormap";

                // Note: the .VariableName must use the text string 'Raster'.
                renderingRule.VariableName = "Raster";

                // Define a Dictionary object with String/Object pairs. The Strings that are used for the keys as 
                // Dictionary entries will need to have exact text strings depending on what raster function is being used.
                Dictionary<string, object> rasterParams = new Dictionary<string, object>();

                // Example #1: Create a random set of colors for the color map.
                // Note: The a key of 'ColormapName' takes the string 'Random'.

                rasterParams.Add("ColormapName", RasterParamCombo.SelectionBoxItem.ToString());
                // Add the rasterParms Dictionary as the RenderingRule's RasterFunctionArguments.
                renderingRule.RasterFunctionArguments = rasterParams;
                // Apply the user defined myRenderingRule to the ArcGISImageServiceLayer's .RenderingRule
                lyr.RenderingRule = renderingRule;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error making color map: " + ex.Message);
            }
        }
예제 #4
0
        private async Task ChangeRenderingRuleAsync()
        {
            // Display a picker to the user to choose among the available rendering rules for the image service raster
            string myRenderingRuleInfoName = await DisplayActionSheet("Select a Rendering Rule", "Cancel", null, _names.ToArray());

            // Loop through each rendering rule info in the image service raster
            foreach (RenderingRuleInfo myRenderingRuleInfo in _myReadOnlyListRenderRuleInfos)
            {
                // Get the name of the rendering rule info
                string myRenderingRuleName = myRenderingRuleInfo.Name;

                // If the name of the rendering rule info matches what was chosen by the user, proceed
                if (myRenderingRuleName == myRenderingRuleInfoName)
                {
                    // Create a new rendering rule from the rendering rule info
                    RenderingRule myRenderingRule = new RenderingRule(myRenderingRuleInfo);

                    // Create a new image service raster
                    ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(_myUri);

                    // Set the image service raster's rendering rule to the rendering rule created earlier
                    myImageServiceRaster.RenderingRule = myRenderingRule;

                    // Create a new raster layer from the image service raster
                    RasterLayer myRasterLayer = new RasterLayer(myImageServiceRaster);

                    // Add the raster layer to the operational layers of the  map view
                    MyMapView.Map.OperationalLayers.Add(myRasterLayer);
                }
            }
        }
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ArcGISImageServiceLayer imageLayer = MyMap.Layers["ImageServiceLayer"] as ArcGISImageServiceLayer;
                RenderingRule renderingRule = new RenderingRule();
                renderingRule.VariableName = "Raster";

                Dictionary<string, object> rasterParams = new Dictionary<string, object>();

                string[] strArray = BandIDsTextBox.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (strArray.Length == 1 || strArray.Length == 2 || strArray.Length > 3)
                {
                    ValidBandIdsTextBlock.Visibility = Visibility.Visible;
                    return;
                }
                else
                    ValidBandIdsTextBlock.Visibility = Visibility.Collapsed;

                renderingRule.RasterFunctionName = "Stretch";
                renderingRule.VariableName = "Raster";

                int stretchType = 0;
                if (StandardDevCheckBox.IsChecked.Value)
                    stretchType = 3;
                else if (HistogramCheckBox.IsChecked.Value)
                    stretchType = 4;
                else if (MinMaxCheckBox.IsChecked.Value)
                    stretchType = 5;

                rasterParams.Add("StretchType", stretchType);
                rasterParams.Add("NumberOfStandardDeviations",
                    string.IsNullOrEmpty(StnDevTextBox.Text) ? 1 : double.Parse(StnDevTextBox.Text));

                double[][] statistics = new double[3][] {
                    new double[4] { 0.2, 222.46, 99.35, 1.64 },
                    new double[4] { 5.56, 100.345, 45.4, 3.96 },
                    new double[4] { 0, 352.37, 172.284, 2 } };
                rasterParams.Add("Statistics", statistics);

                double[] gamma = new double[] { 1.25, 2, 3.95 };
                rasterParams.Add("Gamma", gamma);

                int[] numArray = new int[strArray.Length];
                for (int i = 0; i < strArray.Length; i++)
                {
                    numArray[i] = int.Parse(strArray[i]);
                }

                imageLayer.BandIds = numArray.Length < 1 ? null : numArray;

                renderingRule.RasterFunctionArguments = rasterParams;
                imageLayer.RenderingRule = renderingRule;
            }
            catch (Exception ex)
            {
                return;
            }
        }
        private void _segmentControl_ValueChanged(object sender, EventArgs e)
        {
            // Get the index number of the user choice of render rule names
            nint selectedSegmentId = (sender as UISegmentedControl).SelectedSegment;

            // Get the rendering rule info name from the UISegmentedControl that was chosen by the user
            string myRenderingRuleInfoName = (sender as UISegmentedControl).TitleAt(selectedSegmentId);

            // Loop through each rendering rule info in the image service raster
            foreach (RenderingRuleInfo myRenderingRuleInfo in _myReadOnlyListRenderRuleInfos)
            {
                // Get the name of the rendering rule info
                string myRenderingRuleName = myRenderingRuleInfo.Name;

                // If the name of the rendering rule info matches what was chosen by the user, proceed
                if (myRenderingRuleName == myRenderingRuleInfoName)
                {
                    // Create a new rendering rule from the rendering rule info
                    RenderingRule myRenderingRule = new RenderingRule(myRenderingRuleInfo);

                    // Create a new image service raster
                    ImageServiceRaster myImageServiceRaster2 = new ImageServiceRaster(_myUri);

                    // Set the image service raster's rendering rule to the rendering rule created earlier
                    myImageServiceRaster2.RenderingRule = myRenderingRule;

                    // Create a new raster layer from the image service raster
                    RasterLayer myRasterLayer = new RasterLayer(myImageServiceRaster2);

                    // Add the raster layer to the operational layers of the  map view
                    _myMapView.Map.OperationalLayers.Add(myRasterLayer);
                }
            }
        }
        private void OnChangeRenderingRuleMenuItemClicked(object sender, PopupMenu.MenuItemClickEventArgs e)
        {
            // Get the rendering rule from the selected item
            string selectedRenderingRuleType = e.Item.TitleCondensedFormatted.ToString();

            // Loop through each rendering rule info in the image service raster
            foreach (RenderingRuleInfo myRenderingRuleInfo in _myReadOnlyListRenderRuleInfos)
            {
                // Get the name of the rendering rule info
                string myRenderingRuleName = myRenderingRuleInfo.Name;

                // If the name of the rendering rule info matches what was chosen by the user, proceed
                if (myRenderingRuleName == selectedRenderingRuleType)
                {
                    // Create a new rendering rule from the rendering rule info
                    RenderingRule myRenderingRule = new RenderingRule(myRenderingRuleInfo);

                    // Create a new image service raster
                    ImageServiceRaster myImageServiceRaster = new ImageServiceRaster(_myUri)
                    {
                        // Set the image service raster's rendering rule to the rendering rule created earlier
                        RenderingRule = myRenderingRule
                    };

                    // Create a new raster layer from the image service raster
                    RasterLayer myRasterLayer = new RasterLayer(myImageServiceRaster);

                    // Add the raster layer to the operational layers of the  map view
                    _myMapView.Map.OperationalLayers.Add(myRasterLayer);
                }
            }
        }
예제 #8
0
        public static RenderingRuleSet CreateTestRenderingRules()
        {
            RenderingRuleSet rules = new RenderingRuleSet();

            for (int i = 0; i < pointTypesCount; i++)
            {
                IOsmElementSelector selector = new KeyValueSelector(
                    "garmin_icon",
                    i.ToString(CultureInfo.InvariantCulture));
                IconTemplate template = new IconTemplate();

                template.Style.SetParameter("standardtype", i);
                template.Style.SetParameter("label", i.ToString("x", CultureInfo.InvariantCulture));

                RenderingRule rule = new RenderingRule(
                    string.Format(CultureInfo.InvariantCulture, "GarminIcon{0}", i),
                    RenderingRuleTargets.Nodes,
                    selector,
                    template);

                rules.AddRule(rule);
            }

            return(rules);
        }
 private void RasterFunctionsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ArcGISImageServiceLayer imageLayer = mapView1.Map.Layers["MyImageLayer"] as ArcGISImageServiceLayer;
     var rasterFunction = (sender as ComboBox).SelectedItem as RasterFunctionInfo;
     if (rasterFunction != null)
     {
         RenderingRule renderingRule = new RenderingRule() { RasterFunctionName = rasterFunction.FunctionName };
         imageLayer.RenderingRule = renderingRule;
     }
 }
 private void RasterFunctionsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ArcGISImageServiceLayer imageLayer = MyMap.Layers["MyImageLayer"] as ArcGISImageServiceLayer;
     var rasterFunction = (sender as ComboBox).SelectedItem as RasterFunctionInfo;
     if (rasterFunction != null)
     {
         RenderingRule renderingRule = new RenderingRule() { RasterFunctionName = rasterFunction.Name };
         imageLayer.RenderingRule = renderingRule;
         imageLayer.Refresh();
     }
 }
예제 #11
0
 private void OnApplyRenderingRuleClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         ArcGISImageServiceLayer lyr           = map1.Layers[0] as ArcGISImageServiceLayer;
         RenderingRule           renderingRule = new RenderingRule();
         renderingRule.RasterFunctionName = "Aspect";
         lyr.RenderingRule = renderingRule;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error applying rendering rule: " + ex.Message);
     }
 }
 private void OnApplyRenderingRuleClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         ArcGISImageServiceLayer lyr = map1.Layers[0] as ArcGISImageServiceLayer;
         RenderingRule renderingRule = new RenderingRule();
         renderingRule.RasterFunctionName = "Aspect";
         lyr.RenderingRule = renderingRule;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error applying rendering rule: " + ex.Message);
     }
 }
예제 #13
0
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ArcGISImageServiceLayer     imageLayer    = MyMap.Layers["ImageServiceLayer"] as ArcGISImageServiceLayer;
                RenderingRule               renderingRule = new RenderingRule();
                Dictionary <string, object> rasterParams  = new Dictionary <string, object>();

                if (SRRadioButton.IsChecked.Value)
                {
                    renderingRule.RasterFunctionName = "ShadedRelief";
                    renderingRule.VariableName       = "Raster";

                    rasterParams.Add("Azimuth", string.IsNullOrEmpty(AzimuthTextBox.Text) ? 0 : double.Parse(AzimuthTextBox.Text));
                    rasterParams.Add("Altitude", string.IsNullOrEmpty(AltitudeTextBox.Text) ? 0 : double.Parse(AltitudeTextBox.Text));
                    rasterParams.Add("ZFactor", string.IsNullOrEmpty(ZFactorTextBox.Text) ? 0 : double.Parse(ZFactorTextBox.Text));

                    if (ColormapCheckBox.IsChecked.Value)
                    {
                        rasterParams.Add("Colormap", CreateColorMap());
                    }
                    else
                    {
                        renderingRule.RasterFunctionName = "Hillshade";
                        renderingRule.VariableName       = "DEM";
                    }
                    renderingRule.RasterFunctionArguments = rasterParams;
                }
                else
                {
                    renderingRule.RasterFunctionName = "Slope";
                    renderingRule.VariableName       = "DEM";

                    rasterParams.Add("ZFactor", string.IsNullOrEmpty(ZFactorTextBox.Text) ? 0 : double.Parse(ZFactorTextBox.Text));

                    renderingRule.RasterFunctionArguments = rasterParams;
                }

                imageLayer.RenderingRule = renderingRule;
                imageLayer.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ArcGISImageServiceLayer imageLayer = MyMap.Layers["ImageServiceLayer"] as ArcGISImageServiceLayer;
                RenderingRule renderingRule = new RenderingRule();
                Dictionary<string, object> rasterParams = new Dictionary<string, object>();

                if (SRRadioButton.IsChecked.Value)
                {
                    renderingRule.RasterFunctionName = "ShadedRelief";
                    renderingRule.VariableName = "Raster";

                    rasterParams.Add("Azimuth", string.IsNullOrEmpty(AzimuthTextBox.Text) ? 0 : double.Parse(AzimuthTextBox.Text));
                    rasterParams.Add("Altitude", string.IsNullOrEmpty(AltitudeTextBox.Text) ? 0 : double.Parse(AltitudeTextBox.Text));
                    rasterParams.Add("ZFactor", string.IsNullOrEmpty(ZFactorTextBox.Text) ? 0 : double.Parse(ZFactorTextBox.Text));

                    if (ColormapCheckBox.IsChecked.Value)
                        rasterParams.Add("Colormap", CreateColorMap());
                    else
                    {
                        renderingRule.RasterFunctionName = "Hillshade";
                        renderingRule.VariableName = "DEM";
                    }
                    renderingRule.RasterFunctionArguments = rasterParams;
                }
                else
                {
                    renderingRule.RasterFunctionName = "Slope";
                    renderingRule.VariableName = "DEM";

                    rasterParams.Add("ZFactor", string.IsNullOrEmpty(ZFactorTextBox.Text) ? 0 : double.Parse(ZFactorTextBox.Text));

                    renderingRule.RasterFunctionArguments = rasterParams;
                }

                imageLayer.RenderingRule = renderingRule;
                imageLayer.Refresh();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #15
0
        private void ParseAreaRule(IList <string> tableRowCells)
        {
            string ruleName     = GetTableRowCell(tableRowCells, 0, false, "Rule name missing");
            string selectorText = GetTableRowCell(tableRowCells, 1, false, "Rule selector missing");
            string minLevelText = GetTableRowCell(tableRowCells, 2, true, null);
            string maxLevelText = GetTableRowCell(tableRowCells, 3, true, null);
            string typeName     = GetTableRowCell(tableRowCells, 4, true, null);
            string label        = GetTableRowCell(tableRowCells, 5, true, null);
            string colorsText   = GetTableRowCell(tableRowCells, 6, false, "Area colors value missing");
            string patternText  = GetTableRowCell(tableRowCells, 7, true, null);

            IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]);
            IList <string>      colors             = ParseColors(colorsText);

            PolygonTemplate template = new PolygonTemplate();

            template.Style.SetParameter("rulename", ruleName);
            if (false == string.IsNullOrEmpty(minLevelText))
            {
                template.Style.MinZoomFactor = ParseLevel(minLevelText);
            }
            if (false == string.IsNullOrEmpty(maxLevelText))
            {
                template.Style.MaxZoomFactor = ParseLevel(maxLevelText);
            }
            template.Style.SetParameter("colors", colors);
            if (false == string.IsNullOrEmpty(typeName))
            {
                template.Style.SetParameter("typename", typeName);
            }
            if (false == String.IsNullOrEmpty(label))
            {
                template.Style.SetParameter("label", label);
            }
            if (false == String.IsNullOrEmpty(patternText))
            {
                template.Style.SetParameter("pattern", ParseAreaPattern(patternText));
            }

            RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Areas, osmElementSelector, template);

            rules.AddRule(rule);
        }
        private void _segmentControl_ValueChanged(object sender, EventArgs e)
        {
            // Get the index number of the user choice of render rule names.
            nint selectedSegmentId = ((UISegmentedControl)sender).SelectedSegment;

            // Get the rendering rule info name from the UISegmentedControl that was chosen by the user.
            string selectedRuleName = ((UISegmentedControl)sender).TitleAt(selectedSegmentId);

            // Loop through each rendering rule info in the image service raster.
            foreach (RenderingRuleInfo renderingRuleInfo in _renderRuleInfos)
            {
                // Get the name of the rendering rule info.
                string renderingRuleName = renderingRuleInfo.Name;

                // If the name of the rendering rule info matches what was chosen by the user, proceed.
                if (renderingRuleName == selectedRuleName)
                {
                    // Create a new rendering rule from the rendering rule info.
                    RenderingRule renderingRule = new RenderingRule(renderingRuleInfo);

                    // Create a new image service raster.
                    ImageServiceRaster imageServiceRaster2 = new ImageServiceRaster(_myUri)
                    {
                        // Set the image service raster's rendering rule to the rendering rule created earlier.
                        RenderingRule = renderingRule
                    };

                    // Create a new raster layer from the image service raster.
                    RasterLayer rasterLayer = new RasterLayer(imageServiceRaster2);

                    // Add the raster layer to the operational layers of the  map view.
                    _myMapView.Map.OperationalLayers.Add(rasterLayer);

                    // Stop iterating once match is found.
                    break;
                }
            }
        }
예제 #17
0
        public RenderingRulesMother AddLineRule()
        {
            string ruleName = counter.ToString(CultureInfo.InvariantCulture);

            PolylineTemplate template = new PolylineTemplate();

            template.Style.SetParameter("rulename", ruleName);

            List <string> colors = new List <string> ();

            colors.Add("ffffff");
            template.Style.SetParameter("colors", colors);

            currentRule = new RenderingRule(
                ruleName,
                RenderingRuleTargets.Ways,
                new OsmElementSelectorContainer(OsmElementSelectorContainerOperation.And),
                template);
            rules.AddRule(currentRule);

            counter++;
            return(this);
        }
예제 #18
0
        private void SelectRenderingRule(RenderingRuleInfo renderingRuleInfo)
        {
            // Create a new rendering rule from the rendering rule info.
            RenderingRule renderingRule = new RenderingRule(renderingRuleInfo);

            // Create a new image service raster.
            ImageServiceRaster imageServiceRaster = new ImageServiceRaster(_myUri)
            {
                // Set the image service raster's rendering rule to the rendering rule created earlier.
                RenderingRule = renderingRule
            };

            // Create a new raster layer from the image service raster.
            RasterLayer rasterLayer = new RasterLayer(imageServiceRaster);

            // Clear the existing layer from the map.
            _myMapView.Map.OperationalLayers.Clear();

            // Add the raster layer to the operational layers of the  map view.
            _myMapView.Map.OperationalLayers.Add(rasterLayer);

            // Update the label.
            _selectionLabel.Text = $"Rule \"{renderingRuleInfo.Name}\" selected.";
        }
예제 #19
0
        private void ParsePointRule(IList <string> tableRowCells)
        {
            string ruleName     = GetTableRowCell(tableRowCells, 0, false, "Rule name missing");
            string selectorText = GetTableRowCell(tableRowCells, 1, false, "Rule selector missing");
            string minLevelText = GetTableRowCell(tableRowCells, 2, true, null);
            string maxLevelText = GetTableRowCell(tableRowCells, 3, true, null);
            string typeName     = GetTableRowCell(tableRowCells, 4, true, null);
            string label        = GetTableRowCell(tableRowCells, 5, true, null);
            string iconText     = GetTableRowCell(tableRowCells, 6, true, null);

            IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]);

            IconTemplate template = new IconTemplate();

            template.Style.SetParameter("rulename", ruleName);
            if (false == string.IsNullOrEmpty(minLevelText))
            {
                template.Style.MinZoomFactor = ParseLevel(minLevelText);
            }
            if (false == string.IsNullOrEmpty(maxLevelText))
            {
                template.Style.MaxZoomFactor = ParseLevel(maxLevelText);
            }
            if (false == string.IsNullOrEmpty(typeName))
            {
                template.Style.SetParameter("typename", typeName);
            }
            if (false == String.IsNullOrEmpty(label))
            {
                template.Style.SetParameter("label", label);
            }

            if (false == String.IsNullOrEmpty(iconText))
            {
                // first check if it is a Wiki link
                Match match = regexWikiLink.Match(iconText);
                if (match.Success)
                {
                    string wikiLink = match.Groups["link"].Value.Trim();

                    // now check that the link is a local one (we are currently not supporting remote links)
                    if (false == wikiLink.StartsWith("#", StringComparison.OrdinalIgnoreCase))
                    {
                        ThrowParseError(
                            "Currently only local links (to the same page) are supported for point patterns: '{0}'",
                            wikiLink);
                    }

                    template.Style.SetParameter("patternurl", wikiLink);
                }
                else
                {
                    template.Style.SetParameter("iconurl", iconText);
                }
            }

            // NOTE: the rule will target both OSM nodes and areas
            // this way we can put an icon on the conter of an area (example: place=locality)
            RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Nodes | RenderingRuleTargets.Areas, osmElementSelector, template);

            rules.AddRule(rule);
        }
예제 #20
0
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ArcGISImageServiceLayer imageLayer    = MyMapView.Map.Layers["ImageServiceLayer"] as ArcGISImageServiceLayer;
                RenderingRule           renderingRule = new RenderingRule();
                renderingRule.VariableName = "Raster";

                Dictionary <string, object> rasterParams = new Dictionary <string, object>();

                string[] strArray = BandIDsTextBox.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (strArray.Length == 1 || strArray.Length == 2 || strArray.Length > 3)
                {
                    ValidBandIdsTextBlock.Visibility = Visibility.Visible;
                    return;
                }
                else
                {
                    ValidBandIdsTextBlock.Visibility = Visibility.Collapsed;
                }

                renderingRule.RasterFunctionName = "Stretch";
                renderingRule.VariableName       = "Raster";

                int stretchType = 0;
                if (StandardDevCheckBox.IsChecked.Value)
                {
                    stretchType = 3;
                }
                else if (HistogramCheckBox.IsChecked.Value)
                {
                    stretchType = 4;
                }
                else if (MinMaxCheckBox.IsChecked.Value)
                {
                    stretchType = 5;
                }

                rasterParams.Add("StretchType", stretchType);
                rasterParams.Add("NumberOfStandardDeviations",
                                 string.IsNullOrEmpty(StnDevTextBox.Text) ? 1 : double.Parse(StnDevTextBox.Text));

                double[][] statistics = new double[3][] {
                    new double[4] {
                        0.2, 222.46, 99.35, 1.64
                    },
                    new double[4] {
                        5.56, 100.345, 45.4, 3.96
                    },
                    new double[4] {
                        0, 352.37, 172.284, 2
                    }
                };
                rasterParams.Add("Statistics", statistics);

                double[] gamma = new double[] { 1.25, 2, 3.95 };
                rasterParams.Add("Gamma", gamma);


                int[] numArray = new int[strArray.Length];
                for (int i = 0; i < strArray.Length; i++)
                {
                    numArray[i] = int.Parse(strArray[i]);
                }

                imageLayer.BandIds = numArray.Length < 1 ? null : numArray;


                renderingRule.RasterFunctionArguments = rasterParams;
                imageLayer.RenderingRule = renderingRule;
            }
            catch (Exception ex)
            {
                var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
            }
        }
예제 #21
0
        private void ParseLineRule(IList <string> tableRowCells)
        {
            string ruleName        = GetTableRowCell(tableRowCells, 0, false, "Rule name missing");
            string selectorText    = GetTableRowCell(tableRowCells, 1, false, "Rule selector missing");
            string minLevelText    = GetTableRowCell(tableRowCells, 2, true, null);
            string maxLevelText    = GetTableRowCell(tableRowCells, 3, true, null);
            string typeName        = GetTableRowCell(tableRowCells, 4, true, null);
            string label           = GetTableRowCell(tableRowCells, 5, true, null);
            string colorsText      = GetTableRowCell(tableRowCells, 6, false, "Line colors value missing");
            string widthText       = GetTableRowCell(tableRowCells, 7, true, null);
            string borderWidthText = GetTableRowCell(tableRowCells, 8, true, null);
            string patternText     = GetTableRowCell(tableRowCells, 9, true, null);

            IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]);

            bool lineWidthsSpecified = false;

            PolylineTemplate template = new PolylineTemplate();

            template.Style.SetParameter("rulename", ruleName);
            if (false == string.IsNullOrEmpty(minLevelText))
            {
                template.Style.MinZoomFactor = ParseLevel(minLevelText);
            }
            if (false == string.IsNullOrEmpty(maxLevelText))
            {
                template.Style.MaxZoomFactor = ParseLevel(maxLevelText);
            }
            template.Style.SetParameter("colors", ParseColors(colorsText));
            if (false == string.IsNullOrEmpty(typeName))
            {
                template.Style.SetParameter("typename", typeName);
            }
            if (false == String.IsNullOrEmpty(label))
            {
                template.Style.SetParameter("label", label);
            }
            if (false == String.IsNullOrEmpty(widthText))
            {
                lineWidthsSpecified = true;
                template.Style.SetParameter("width", ParseLineWidth(widthText));
            }
            if (false == String.IsNullOrEmpty(borderWidthText))
            {
                lineWidthsSpecified = true;
                template.Style.SetParameter("borderwidth", ParseLineWidth(borderWidthText));
            }
            if (false == String.IsNullOrEmpty(patternText))
            {
                if (lineWidthsSpecified)
                {
                    ThrowParseError("Both line widths and the line pattern are specified. These are mutually exclusive - choose one or the other");
                }

                template.Style.SetParameter("pattern", ParseLinePattern(patternText));
            }

            RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Ways, osmElementSelector, template);

            rules.AddRule(rule);
        }