Simplify Online

This sample demonstrates use of a GeometryService to simplify a polygon, and demonstrates the importance of simplification. To use the sample, click the Query with Original Polygon button. Observe the results include parcels that are not wholly within the red polygon. Then click the Simplify Polygon, then Query button. Observe the results parcels are now wholly within the red polygon.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.Simplify"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009" >
    <Grid x:Name="LayoutRoot">

        <Grid.Resources>
            <esri:SimpleFillSymbol x:Key="ParcelFillSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="2" />
            <esri:SimpleFillSymbol x:Key="PolygonFillSymbol" Fill="#66FF0000" BorderBrush="Red" BorderThickness="2" />
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Extent="-9270434.248,5246977.326,-9269261.417,5247569.712" >
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
                      Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            <esri:GraphicsLayer ID="MyGraphicsLayer" />
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray" RadiusX="10" RadiusY="10"  Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical" Margin="30,20,25,30" >
                <TextBlock x:Name="ResponseText" Text="Many spatial operations require topologically correct geometry.  If you try to use the self-intersecting geometry below without simplifying it you will get incorrect results.  The query's spatial relationship is Contains, which should only return the parcels that the polygon contains." 
                           Width="550" TextAlignment="Left"  TextWrapping="Wrap" Foreground="Black" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
                    <Button Content="Query with Original Polygon" Margin="0,5,5,0" x:Name="QueryOnlyButton" Click="QueryOnlyButton_Click" />
                    <Button Content="Simplify Polygon, then Query" x:Name="SimplifyAndQueryButton" Click="SimplifyAndQueryButton_Click"  Margin="5,5,0,0" />
                </StackPanel>
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014