本文整理汇总了C#中Envelope.Grow方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.Grow方法的具体用法?C# Envelope.Grow怎么用?C# Envelope.Grow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Envelope
的用法示例。
在下文中一共展示了Envelope.Grow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateToPointOnLine
/// <summary>
/// When the user clicks on a source point we will need to trabnslate that location to the nearest point on the network
/// </summary>
/// <param name="userPoint"></param>
/// <param name="tolerence"></param>
/// <param name="growValue"></param>
/// <param name="theLayer"></param>
/// <returns></returns>
public IntersectionPackage TranslateToPointOnLine(Coordinate userPoint, double tolerence, double growValue, VectorLayer theLayer)
{
try
{
// How much should we increase the search area by until we reach tolerence.
double GROWVALUE = growValue;
// Record how many features are in the bounding box
int featureCount = 0;
// The features that are withinthe boundbox of GROWVALUE of UserPoints.
Collection<IGeometry> geometrysInTolerence = null;
IGeometry clickPointAsNts = null;
while ((featureCount == 0) && (GROWVALUE < tolerence))
{
// Take the point where the user clicked. Grow it by a set a given amount. We use the boundry
// box to find all lines within a given tolerence.
clickPointAsNts = _geomFactory.CreatePoint(userPoint);
var clickPointBoundry = new Envelope(userPoint);
clickPointBoundry = clickPointBoundry.Grow(GROWVALUE);
var originalLayer = theLayer;
originalLayer.DataSource.Open();
geometrysInTolerence =
originalLayer.DataSource.GetGeometriesInView(clickPointBoundry);
GROWVALUE *= 2;
if (geometrysInTolerence != null)
featureCount = geometrysInTolerence.Count;
}
// If there are any geometries in the boundry box then we loop around them them. We are looking for the cloest point so
// we can **try** to perform a snap operation. NOTE: This entire procedure is a bit flawed.
if (geometrysInTolerence == null)
return null;
if (geometrysInTolerence.Count > 0)
{
double closestDistance = double.MaxValue;
Coordinate intersectionPointAsNts = null;
ILineString closestToThisLine = null;
foreach (IGeometry geometryInTolerence in geometrysInTolerence)
{
var nearestPoints = NetTopologySuite.Operation.Distance.DistanceOp.NearestPoints(clickPointAsNts, geometryInTolerence);
if (nearestPoints == null)
return null;
// We get two points back. The point where we clicked and the point of intersection (?????) on the line). If
// we calculate the distance between the two we can
var p1 = nearestPoints[0];
var p2 = nearestPoints[1];
var lDistance = p1.Distance(p2);
if (lDistance < closestDistance)
{
closestDistance = lDistance;
intersectionPointAsNts = p2;
closestToThisLine = (ILineString)geometryInTolerence;
}
}
// Getting Here would mean that we now know the line we
if (closestDistance < double.MaxValue)
{
var theDeliveryPackage = new IntersectionPackage((IPoint)clickPointAsNts,
_geomFactory.CreatePoint(intersectionPointAsNts), closestToThisLine);
return theDeliveryPackage;
}
}
else
return null;
return null;
}
catch (Exception e1)
{
System.Diagnostics.Debug.WriteLine(e1.ToString());
return null;
}
}
示例2: OnMouseUp
//.........这里部分代码省略.........
if (MapCenterChanged != null)
MapCenterChanged(_map.Center);
}
}
}
else if (_activeTool == Tools.QueryBox || _activeTool == Tools.QueryPoint /*|| _activeTool == Tools.QueryPolygon*/)
{
//OnMouseUpQuery(e);
var mqs = MapQueryStarted;
if (mqs != null)
mqs(this, new EventArgs());
var layersToQuery = GetLayersToQuery();
if (layersToQuery.Count > 0)
{
var foundData = false;
foreach (var layer in layersToQuery)
{
Envelope bounding;
var isPoint = false;
if (_dragging)
{
Coordinate lowerLeft, upperRight;
GetBounds(_map.ImageToWorld(_dragStartPoint), _map.ImageToWorld(_dragEndPoint),
out lowerLeft, out upperRight);
bounding = new Envelope(lowerLeft, upperRight);
}
else
{
bounding = new Envelope(_map.ImageToWorld(new Point(e.X, e.Y)));
bounding = bounding.Grow(_map.PixelSize*_queryGrowFactor);
isPoint = true;
}
var ds = new Data.FeatureDataSet();
if (_activeTool == Tools.QueryBox)
{
layer.ExecuteIntersectionQuery(bounding, ds);
}
else
{
IGeometry geom;
if (isPoint && QueryGrowFactor == 0)
geom = _map.Factory.CreatePoint(_map.ImageToWorld(new Point(e.X, e.Y)));
else
geom = _map.Factory.ToGeometry(bounding);
layer.ExecuteIntersectionQuery(geom, ds);
}
if (MapQueried != null)
{
if (ds.Tables.Count > 0)
{
//Fire the event for all the resulting tables
foreach (var dt in ds.Tables)
{
if (dt.Rows.Count > 0)
{
MapQueried(dt);
foundData = true;
if (_mapQueryMode == MapQueryType.TopMostLayer)
break;
}
示例3: OnMouseUp
//.........这里部分代码省略.........
OnMapCenterChanged(_map.Center);
}
}
}
}
else if (_activeTool == Tools.QueryBox || _activeTool == Tools.QueryPoint
/*|| _activeTool == Tools.QueryPolygon*/)
{
//OnMouseUpQuery(e);
var mqs = MapQueryStarted;
if (mqs != null)
mqs(this, new EventArgs());
var layersToQuery = GetLayersToQuery();
if (layersToQuery.Count > 0)
{
var foundData = false;
foreach (var layer in layersToQuery)
{
Envelope bounding;
var isPoint = false;
if (_dragging)
{
Coordinate lowerLeft, upperRight;
GetBounds(_map.ImageToWorld(_dragStartPoint), _map.ImageToWorld(_dragEndPoint),
out lowerLeft, out upperRight);
bounding = new Envelope(lowerLeft, upperRight);
}
else
{
bounding = new Envelope(_map.ImageToWorld(new Point(e.X, e.Y)));
bounding = bounding.Grow(_map.PixelSize*_queryGrowFactor);
isPoint = true;
}
var ds = new Data.FeatureDataSet();
if (_activeTool == Tools.QueryBox)
{
layer.ExecuteIntersectionQuery(bounding, ds);
}
else
{
IGeometry geom;
if (isPoint && QueryGrowFactor == 0)
geom = _map.Factory.CreatePoint(_map.ImageToWorld(new Point(e.X, e.Y)));
else
geom = _map.Factory.ToGeometry(bounding);
layer.ExecuteIntersectionQuery(geom, ds);
}
if (MapQueried != null)
{
if (ds.Tables.Count > 0)
{
//Fire the event for all the resulting tables
foreach (var dt in ds.Tables)
{
if (dt.Rows.Count > 0)
{
MapQueried(dt);
foundData = true;
if (_mapQueryMode == MapQueryType.TopMostLayer)
break;
}