How to determine whether two features are intersecting?

2820
11
01-15-2013 05:22 AM
Labels (1)
GeorgeFaraj
Occasional Contributor III
How can I test whether the symbol of one feature is intersecting the geometry of another feature? For example, I have a feature whose geometry is a MapPoint, but has a TextSymbol set. I want to know if the text is intersecting/overlapping another feature whose geometry is a Polygon.

Is this doable?
0 Kudos
11 Replies
GeorgeFaraj
Occasional Contributor III
At the very least, can someone tell me how to center a TextSymbol inside a polygon feature? I'm using the LabelPoints geometry task to get the position of the text as a MapPoint, but then the text isn't centered.
0 Kudos
MatthewBrown1
Occasional Contributor
That sounds like Maplex for Runtime!

Are you labelling multipart features? This might have put the label point in an undesirable position, but my understanding is that LabelPoint should be within the polygon. You might be able to change the offset with a control template in your XAML.
0 Kudos
GeorgeFaraj
Occasional Contributor III
LabelPoints returns the correct points, but then the text's top-left (or bottom-left) corner is placed at that point. I want to center the text. Not sure how to offset it, since the text can change. Any ideas?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
LabelPoints returns the correct points, but then the text's top-left (or bottom-left) corner is placed at that point. I want to center the text. Not sure how to offset it, since the text can change. Any ideas?


You can retemplate the symbol and use either OffsetX/OffsetY or the margin to translate the text.
If you can know the max width of your text (100 here), this should work:
<esri:TextSymbol FontSize="14" OffsetX="50" OffsetY="7" Text="{Binding Attributes[myAttribute]}">
    <esri:TextSymbol.ControlTemplate>
        <ControlTemplate>
            <TextBlock Width="100" FontFamily="{Binding Symbol.FontFamily}"
                        FontSize="{Binding Symbol.FontSize}"
                        Foreground="{Binding Symbol.Foreground}"
                        Text="{Binding Symbol.Text}" TextAlignment="Center" />
        </ControlTemplate>
    </esri:TextSymbol.ControlTemplate>
</esri:TextSymbol>
0 Kudos
GeorgeFaraj
Occasional Contributor III
I tried that and it worked. I think we can manage with that. Thank you. Now, is there a way to have the symbol hide if it doesn't fit inside the polygon? Look how ugly the attached screenshot looks.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The easier way is to set a MaximumResolution to your graphics layer that contains your text symbols so your labels won't be visible when the user zooms out.
0 Kudos
GeorgeFaraj
Occasional Contributor III
Yeah I tried that but then there are different-sized features that should have their labels visible at different resolutions. Any idea about that?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Yeah I tried that but then there are different-sized features that should have their labels visible at different resolutions. Any idea about that?


At this time, my only idea is to create several graphicslayers, one by range of feature sizes and to set the MaximumResolution accordingly.

I guess, you'd rather to get a labelling engine at client side working label by label but unfortunately, that doesn't exist yet.
0 Kudos
GeorgeFaraj
Occasional Contributor III
I guess, you'd rather to get a labelling engine at client side working label by label but unfortunately, that doesn't exist yet.


Exactly. Mike mentioned that there were talks about adding advanced labeling in next versions of the Runtime. Is there an estimated time frame for that by any chance?
0 Kudos