Exemplo n.º 1
0
        public void SimplifyClick(Map map, GeoCollection <object> args)
        {
            if (null == areaBaseShape)
            {
                areaBaseShape = ((InMemoryFeatureLayer)map.StaticOverlay.Layers["SimplificationLayer"]).InternalFeatures[0].GetShape() as AreaBaseShape;
            }
            string toleranceString                   = args[0] as string;
            string simplificationTypeString          = args[1] as string;
            InMemoryFeatureLayer simplificationLayer = (InMemoryFeatureLayer)map.StaticOverlay.Layers["SimplificationLayer"];

            double             tolerance          = Convert.ToDouble(toleranceString, CultureInfo.InvariantCulture);
            SimplificationType simplificationType = SimplificationType.DouglasPeucker;

            switch (simplificationTypeString)
            {
            case "TopologyPreserving":
                simplificationType = SimplificationType.TopologyPreserving;
                break;

            case "DouglasPeucker":
                simplificationType = SimplificationType.DouglasPeucker;
                break;
            }

            MultipolygonShape multipolygonShape = areaBaseShape.Simplify(tolerance, simplificationType);

            simplificationLayer.InternalFeatures.Clear();
            simplificationLayer.InternalFeatures.Add(new Feature(multipolygonShape));
        }
        private void btnSimplify_Click(object sender, RoutedEventArgs e)
        {
            InMemoryFeatureLayer simplificationLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("SimplificationLayer");

            double             tolerance          = Convert.ToDouble(cmbTolerance.SelectedItem.ToString().Split(':')[1], CultureInfo.InvariantCulture);
            SimplificationType simplificationType = (SimplificationType)cmbSimplificationType.SelectedIndex;

            MultipolygonShape multipolygonShape = areaBaseShape.Simplify(tolerance, simplificationType);

            simplificationLayer.InternalFeatures.Clear();
            simplificationLayer.InternalFeatures.Add(new Feature(multipolygonShape));

            mapView.Overlays["SimplificationOverlay"].Refresh();
        }
Exemplo n.º 3
0
        private void btnSimplify_Click(object sender, EventArgs e)
        {
            InMemoryFeatureLayer simplificationLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("SimplificationLayer");

            double             tolerance          = Convert.ToDouble(cmbTolerance.Text, CultureInfo.InvariantCulture);
            SimplificationType simplificationType = (SimplificationType)cmbSimplificationType.SelectedIndex;

            MultipolygonShape multipolygonShape = areaBaseShape.Simplify(tolerance, simplificationType);

            simplificationLayer.InternalFeatures.Clear();
            simplificationLayer.InternalFeatures.Add(new Feature(multipolygonShape));

            winformsMap1.Refresh(winformsMap1.Overlays["SimplificationOverlay"]);
        }
Exemplo n.º 4
0
        private void simplifyShape_Click(object sender, EventArgs e)
        {
            LayerOverlay layerOverlay = (LayerOverlay)mapView.Overlays["layerOverlay"];

            ShapeFileFeatureLayer cityLimits    = (ShapeFileFeatureLayer)layerOverlay.Layers["cityLimits"];
            InMemoryFeatureLayer  simplifyLayer = (InMemoryFeatureLayer)layerOverlay.Layers["simplifyLayer"];

            // Query the cityLimits layer to get all the features
            cityLimits.Open();
            var features = cityLimits.QueryTools.GetAllFeatures(ReturningColumnsType.NoColumns);

            cityLimits.Close();

            // Simplify the first feature using the Douglas Peucker method
            var simplify = AreaBaseShape.Simplify(features[0].GetShape() as AreaBaseShape, Convert.ToInt32(tolerance.Text), SimplificationType.DouglasPeucker);

            // Add the simplified shape into simplifyLayer to display the result.
            // If this were to be a permanent change to the cityLimits FeatureSource, you would modify the underlying data using BeginTransaction and CommitTransaction instead.
            simplifyLayer.InternalFeatures.Clear();
            simplifyLayer.InternalFeatures.Add(new Feature(simplify));

            // Redraw the layerOverlay to see the simplified feature on the map
            layerOverlay.Refresh();
        }