Relation

This sample demonstrates using the ArcGIS Runtime SDK for WPF to perform a geometry operation to calculate topological relationships. To use the sample, click points on the map and click Execute. The relationship of the points to the pre-defined polygons on the map is calculated and added to the points' MapTips.

In the code-behind, a LocalGeometryService is started and the url is passed into a GeometryService which is used to check whether the points are in the polygons by specifying a relation parameter of esriGeometryRelationWithin. The results are added to the points' MapTips when the are returned.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalRelation"
    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" Background="White">
        <Grid.Resources>
            <esri:PictureMarkerSymbol x:Key="DefaultPointMarkerSymbol" OffsetX="0" OffsetY="23" Source="/Assets/Images/flag-red-24x24.png" />
            <esri:SimpleFillSymbol x:Key="DefaultPolygonFillSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="4" />
            <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="-15000000,2000000,-7000000,8000000" Background="#FFE3E3E3">
            <esri:Map.Layers>
                <esri:ArcGISLocalTiledLayer ID="BaseMap" Path="..\\Data\\TPKs\\Topographic.tpk"/>
                <esri:GraphicsLayer ID="PolygonGraphicsLayer" x:Name="_polygonGraphicsLayer">
                    <esri:GraphicsLayer.Graphics >
                        <esri:Graphic x:Name="Graphic0" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_0">
                                <esri:Polygon.SpatialReference>
                                    <esri:SpatialReference WKID="102100"/>
                                </esri:Polygon.SpatialReference>
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>
                                        <esri:MapPoint X="-13411542" Y="8242944" />
                                        <esri:MapPoint X="-12399574" Y="8242944" />
                                        <esri:MapPoint X="-12399574" Y="4242944" />
                                        <esri:MapPoint X="-13411542" Y="4242944" />
                                        <esri:MapPoint X="-13411542" Y="8242944" />
                                    </esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                        <esri:Graphic x:Name="Graphic1" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_1">
                                <esri:Polygon.SpatialReference>
                                    <esri:SpatialReference WKID="102100"/>
                                </esri:Polygon.SpatialReference>
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>
                                        <esri:MapPoint X="-11511542" Y="4442944" />
                                        <esri:MapPoint X="-10399574" Y="4442944" />
                                        <esri:MapPoint X="-10399574" Y="2542944" />
                                        <esri:MapPoint X="-11511542" Y="2542944" />
                                        <esri:MapPoint X="-11511542" Y="4442944" />
                                    </esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                        <esri:Graphic x:Name="Graphic2" Symbol="{StaticResource DefaultPolygonFillSymbol}">
                            <esri:Polygon x:Name="Polygon_2">
                                <esri:Polygon.SpatialReference>
                                    <esri:SpatialReference WKID="102100"/>
                                </esri:Polygon.SpatialReference>
                                <esri:Polygon.Rings>
                                    <esri:PointCollection>
                                        <esri:MapPoint X="-13611542" Y="4442944" />
                                        <esri:MapPoint X="-10399574" Y="4442944" />
                                        <esri:MapPoint X="-10399574" Y="3542944" />
                                        <esri:MapPoint X="-13611542" Y="3542944" />
                                        <esri:MapPoint X="-13611542" Y="4442944" />
                                    </esri:PointCollection>
                                </esri:Polygon.Rings>
                            </esri:Polygon>
                        </esri:Graphic>
                    </esri:GraphicsLayer.Graphics>
                    <esri:GraphicsLayer.MapTip>
                        <Grid Background="LightYellow">
                            <StackPanel Orientation="Vertical" Margin="5">
                                <TextBlock Text="{Binding [Name]}" HorizontalAlignment="Left" Foreground="Black" />
                                <TextBlock Text="{Binding [Relation]}" HorizontalAlignment="Left" Foreground="Black"/>
                            </StackPanel>
                            <Border BorderBrush="Black" BorderThickness="1" />
                        </Grid>
                    </esri:GraphicsLayer.MapTip>
                </esri:GraphicsLayer>
                <esri:GraphicsLayer ID="PointGraphicsLayer" x:Name="_pointGraphicsLayer">
                    <esri:GraphicsLayer.MapTip>
                        <Grid Background="LightYellow">
                            <StackPanel Orientation="Vertical" Margin="5">
                                <TextBlock Text="{Binding [Name]}" HorizontalAlignment="Left" Foreground="Black"/>
                                <TextBlock Text="{Binding [Relation]}" HorizontalAlignment="Left" Foreground="Black" />
                            </StackPanel>
                            <Border BorderBrush="Black" BorderThickness="1" />
                        </Grid>
                    </esri:GraphicsLayer.MapTip>
                </esri:GraphicsLayer>
            </esri:Map.Layers>
        </esri:Map>
        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >
            <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="{StaticResource PanelGradient}" 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" HorizontalAlignment="Center" Margin="30,20,30,30" >
                <TextBlock x:Name="InformationText" Width="200" Foreground="Black" Text="Add points by clicking on map.  Click Execute to compute the relation between the points and the polygons. The results will be displayed by hovering over the polygons or markers." TextAlignment="Left"  TextWrapping="Wrap" />
                <Button x:Name="ExecuteRelationButton" Content="Execute" Click="ExecuteRelationButton_Click" Width="100" Visibility="Visible" Margin="0,5,0,0"/>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014