Hi. I'm creating a series of MapTools to sketch a line on the map that will represent a new feature. A criteria of the sketch is that the first node of the sketch must intersect a line feature. So for example, to create a hydrant lateral the first click must intersect a watermain....the second click will represent the hydrant valve and the last the hydrant.
I have created a routine for checking for the intersection of the first click to a given layer, but I am getting mixed results. With certain layers it works (ie. my sewer layer for my sewer connection tool), but other layers (ie. my watermain layer for my hydrant tool). Here is the code:
public static bool IntersectsLayer(MapPoint point, FeatureLayer layer)
SpatialQueryFilter spatialFilter = new SpatialQueryFilter();
spatialFilter.FilterGeometry = point;
spatialFilter.SpatialRelationship = SpatialRelationship.Intersects;
RowCursor theCursor = layer.Search(spatialFilter);
using (feature = (Feature)theCursor.Current)
catch (Exception ex)
And here is the code that calls it:
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
//use the sketch geometry to create the connectionPoint, valve and hydrant
var pointCollection = ((Multipart)geometry).Points;
MapPoint connectionPoint = pointCollection;
MapPoint hydrantPoint = pointCollection[pointCollection.Count - 1];
MapPoint valvePoint = pointCollection;
//start creating the features
if (Global.IntersectsLayer(connectionPoint, waterMainLayer) == false)
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(connectionPoint.X.ToString() + ", " + connectionPoint.Y.ToString(), "Error");
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("The starting point must intersect the WaterMain or Water Service layer.", "Error");
Can anyone see anything wrong in the code? For some reason it always returns false when using the watermain layer. I have snapping turned on, and it always works when using my similarly coded sewer connection tool.
Any ideas are appreciated.
Solved! Go to Solution.
I really want a help from you if it is possible.
currently Im working on Asp.Net MVC web Application and it consume some Arcgis services such as tileLayer ..
and my object is to draw Line on the map and get the intersect with the TileLayer with the geometry engine if possible?
Could you please share with me a link or some sample code that I can start from?
Just to follow up on this, I did work with esri Canada on this and the end result is that the TEST environment I was using must have some flaw in it. esri Canada also could not reproduce the issue, and after trying the exact same code in our PRODUCTION environment there were no issues.
So I guess a rebuild of our TEST environment is in order, which should happen soon.
Thanks for all your help with this.