Why is the distance off?

797
4
11-01-2011 01:51 PM
GregRieck
Occasional Contributor III
Hello Everyone,

I'm using the IConstructPoint.ConstructAlong method to find a position along a poly line. I return the results as an IPoint and use that point to mark the location with a symbol.

The problem is that when I use the ESRI measure tool it doesn't match the length I passed into the Construct Along method. The point seems to be approximately 7 feet off.

As for code to get the point object I do a search for a feature on the poly line feature class to get the feature. I then cast the feature to ICurve and then call the Construct Along method.

  featurecursor = featureclass.Search(queryfilter, false);
  if (featurecursor != null)
    feature = featurecursor.NextFeature();
  if (feature != null)
  {
     ICurve curve = (ICurve)feature;
     IConstructPoint2 conpnt2 = new PointClass();
     conpnt2. ConstructAlong(curve, esriSegmentExtension.esriNoExtension, length, false);
     IPoint point = (IPoint)conpnt2;
  }

  IRgbColor rgbColorWhite = new RgbColorClass();
  rgbColorWhite.Red = 255;
  rgbColorWhite.Green = 255;
  rgbColorWhite.Blue = 255;
  IPictureMarkerSymbol bitmapPictureMarkerSymbolCls = new PictureMarkerSymbolClass();
  IMarkerElement markerElement = new MarkerElementClass();
  bitmapPictureMarkerSymbolCls.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, MyPicture);
  bitmapPictureMarkerSymbolCls.Angle = 0;
  bitmapPictureMarkerSymbolCls.Size = ((MarkerSize > 0) ? MarkerSize : 1);
  bitmapPictureMarkerSymbolCls.BitmapTransparencyColor = rgbColorWhite;
  bitmapPictureMarkerSymbolCls.XOffset = xoffset;
  bitmapPictureMarkerSymbolCls.YOffset = yoffset;
  markerElement.Symbol = bitmapPictureMarkerSymbolCls;
  IElement element = (IElement)markerElement;
  IElementProperties3 ep3 = (IElementProperties3)element;
  element.Geometry = point;
  ep3.Name = System.IO.Path.GetFileNameWithoutExtension(picFilePath);
  MxDoc.ActiveView.GraphicsContainer.AddElement(element, 0);
  MxDoc.ActiveView.GraphicsContainer.UpdateElement(element);
  MxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
0 Kudos
4 Replies
DuncanHornby
MVP Notable Contributor
Is your polyline data in meter units (for example UTM) but your DataFrame is in lat/long, or vice versa?
0 Kudos
GregRieck
Occasional Contributor III
Hi Duncan,

Thank you for responding to my post.

Indeed my polyline is in UTM meters, map units are Meters. Even when I alter the length by converting it to meters it's still off just over 2 meters or approximately 7 feet. Although I couldn't find any documentation on what unit the ConstructAlong length is expecting I was able to determine that if the Distance units were in feet no conversion needed to be done. However, if the map distance units were in meters I needed to convert the length to meters. At any rate the marked location and the measured location are always off approximately 7 feet.

Greg
0 Kudos
NeilClemmons
Regular Contributor III
The method expects the distance to be in the same units as the spatial reference of the curve that you pass into it (when you pass in False for the asRatio parameter).  When you use the measure tool you specify what distance units you want.  Make sure the curve you're passing in has a spatial reference set and that its linear unit is meters.  Also, make sure you have the Measure tool set to show distances in meters.
0 Kudos
GregRieck
Occasional Contributor III
Thank you for your comments Neil.  I got it working. I wasn't accounting for unit conversions. I think what was happening was I was expecting the ConstructAlong to use feet. However, it used meters. Then when the results were presented in meters and I measured in feet that was the difference. What confused the process was the fact that I wasn't converting the distance from feet to meters. So, if I had measured using meters and the converted length it would have given me the correct results. Very confusing. Easy solution.
G
0 Kudos