Hello,
I’m testing new geometry enhancement and getting “Object reference not set to an instance of an object.” exception in Buffer method.
Following code fails without BaseShape.GeometryLibrary = GeometryLibrary.Managed line:
Best regards,
private Collection<Feature> GetFeaturesOnScreenPos(FeatureLayer layer, PointShape WorldPos, Collection<string> returningColumns)
{
int ScreenBufferSize = 10;
Collection<Feature> selectedFeatures = new Collection<Feature>();
try
{
//Logic for converting screen coordinate values to world coordinate for the spatial query. Notice that the distance buffer for the spatial query
//will change according to the zoom level while it remains the same for the screen buffer distance.
ScreenPointF ScreenPos = ExtentHelper.ToScreenCoordinate(wpfMap1.CurrentExtent, WorldPos.X, WorldPos.Y, (float)wpfMap1.ActualWidth, (float)wpfMap1.ActualHeight);
ScreenPointF bufferPointF = new ScreenPointF(ScreenPos.X + ScreenBufferSize, ScreenPos.Y);
double distanceBuffer = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(wpfMap1.CurrentExtent, ScreenPos, bufferPointF, (float)wpfMap1.ActualWidth, (float)wpfMap1.ActualHeight, wpfMap1.MapUnit, DistanceUnit.Meter);
MultipolygonShape BufferedShape = WorldPos.Buffer(distanceBuffer, GeographyUnit.Meter, DistanceUnit.Meter);
lock (layer)
{
layer.Open();
selectedFeatures = layer.QueryTools.GetFeaturesInsideBoundingBox(BufferedShape.GetBoundingBox(), returningColumns);
layer.Close();
}
}
catch (Exception ex)
{
Logger.Log.Error(ex);
}
return selectedFeatures;
}
Inna