本文整理汇总了C#中IGeometry.GetGeometryN方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.GetGeometryN方法的具体用法?C# IGeometry.GetGeometryN怎么用?C# IGeometry.GetGeometryN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.GetGeometryN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndicesOf
/// <summary>
///
/// </summary>
/// <param name="subLine"></param>
/// <returns></returns>
public virtual LinearLocation[] IndicesOf(IGeometry subLine)
{
var startPt = ((ILineString) subLine.GetGeometryN(0)).GetCoordinateN(0);
var lastLine = (ILineString) subLine.GetGeometryN(subLine.NumGeometries - 1);
var endPt = lastLine.GetCoordinateN(lastLine.NumPoints - 1);
var locPt = new LocationIndexOfPoint(_linearGeom);
var subLineLoc = new LinearLocation[2];
subLineLoc[0] = locPt.IndexOf(startPt);
// check for case where subline is zero length
if (subLine.Length == 0)
subLineLoc[1] = (LinearLocation) subLineLoc[0].Clone();
else subLineLoc[1] = locPt.IndexOfAfter(endPt, subLineLoc[0]);
return subLineLoc;
}
示例2: LoadSourceGeometries
public void LoadSourceGeometries(IGeometry geoms)
{
for (var i = 0; i < geoms.NumGeometries; i++)
{
var g = geoms.GetGeometryN(i);
LoadVertices(g.Coordinates, g.UserData);
}
}
示例3: SetComponentDataToIndex
public static void SetComponentDataToIndex(IGeometry geom)
{
for (int i = 0; i < geom.NumGeometries; i++)
{
IGeometry comp = geom.GetGeometryN(i);
comp.UserData = "Component # " + i;
}
}
示例4: GetItems
private static IEnumerable<IGeometry> GetItems(IGeometry coll)
{
if (coll == null)
throw new ArgumentNullException("coll");
for (int i = 0; i < coll.NumGeometries; i++)
yield return coll.GetGeometryN(i);
}
示例5: FirstNComponents
public static IGeometry FirstNComponents(IGeometry g, int n)
{
var comp = new List<IGeometry>();
for (int i = 0; i < g.NumGeometries && i < n; i++)
{
comp.Add(g.GetGeometryN(i));
}
return g.Factory.BuildGeometry(comp);
}
示例6: TransferData
/// <summary>
/// Input is assumed to be a multiGeometry
/// in which every component has its userData
/// set to be a Coordinate which is the key to the output data.
/// The Coordinate is used to determine
/// the output data object to be written back into the component.
/// </summary>
/// <param name="targetGeom" />
public void TransferData(IGeometry targetGeom)
{
for (int i = 0; i < targetGeom.NumGeometries; i++)
{
var geom = targetGeom.GetGeometryN(i);
var vertexKey = (Coordinate)geom.UserData;
if (vertexKey == null) continue;
geom.UserData = _coordDataMap[vertexKey];
}
}
示例7: Clip
public static IGeometry Clip(IGeometry a, IGeometry mask)
{
var geoms = new List<IGeometry>();
for (var i = 0; i < a.NumGeometries; i++)
{
var clip = a.GetGeometryN(i).Intersection(mask);
geoms.Add(clip);
}
return FunctionsUtil.BuildGeometry(geoms, a);
}
示例8: Map
/// <summary>
/// Maps the members of a <see cref="IGeometry"/>
/// (which may be atomic or composite)
/// into another <tt>Geometry</tt> of most specific type.
/// <tt>null</tt> results are skipped.
/// In the case of hierarchical <see cref="IGeometryCollection"/>s,
/// only the first level of members are mapped.
/// </summary>
/// <param name="geom">The input atomic or composite geometry</param>
/// <param name="op">The mapping operation</param>
/// <returns>A result collection or geometry of most specific type</returns>
public static IGeometry Map(IGeometry geom, IMapOp op)
{
var mapped = new List<IGeometry>();
for (var i = 0; i < geom.NumGeometries; i++)
{
var g = op.Map(geom.GetGeometryN(i));
if (g != null)
mapped.Add(g);
}
return geom.Factory.BuildGeometry(mapped);
}
示例9: intersects
public static IGeometry intersects(IGeometry a, IGeometry mask)
{
var selected = new List<IGeometry>();
for (int i = 0; i < a.NumGeometries; i++)
{
var g = a.GetGeometryN(i);
if (mask.Intersects(g))
{
selected.Add(g);
}
}
return a.Factory.BuildGeometry(selected);
}
示例10: Select
private static IGeometry Select(IGeometry geom, Func<IGeometry, bool> predicate)
{
var selected = new List<IGeometry>();
for (int i = 0; i < geom.NumGeometries; i++)
{
var g = geom.GetGeometryN(i);
if (predicate(g))
{
selected.Add(g);
}
}
return geom.Factory.BuildGeometry(selected);
}
示例11: ExtractElements
private static void ExtractElements(IGeometry geom, ICollection<IGeometry> elems)
{
if (geom == null)
return;
for (var i = 0; i < geom.NumGeometries; i++)
{
var elemGeom = geom.GetGeometryN(i);
if (skipEmpty && elemGeom.IsEmpty)
continue;
elems.Add(elemGeom);
}
}
示例12: TransformByVectors
public static IGeometry TransformByVectors(IGeometry g, IGeometry control)
{
var nControl = control.NumGeometries;
var src = new Coordinate[nControl];
var dest = new Coordinate[nControl];
for (int i = 0; i < nControl; i++) {
var contComp = control.GetGeometryN(i);
var pts = contComp.Coordinates;
src[i] = pts[0];
dest[i] = pts[1];
}
var trans = AffineTransformationFactory.CreateFromControlVectors(src, dest);
Console.WriteLine(trans);
return trans.Transform(g);
}
示例13: InvalidGeoms
public static IGeometry InvalidGeoms(IGeometry g)
{
var invalidGeoms = new List<IGeometry>();
for (var i = 0; i < g.NumGeometries; i++)
{
var geom = g.GetGeometryN(i);
var ivop = new IsValidOp(geom);
var err = ivop.ValidationError;
if (err != null)
{
invalidGeoms.Add(geom);
}
}
return g.Factory.BuildGeometry(invalidGeoms);
}
示例14: InvalidLocations
/// <summary>
/// Validates all geometries in a collection independently.
/// Errors are returned as points at the invalid location
/// </summary>
/// <param name="g"></param>
/// <returns>the invalid locations, if any</returns>
public static IGeometry InvalidLocations(IGeometry g)
{
var invalidLoc = new List<IPoint>();
for (var i = 0; i < g.NumGeometries; i++)
{
var geom = g.GetGeometryN(i);
var ivop = new IsValidOp(geom);
var err = ivop.ValidationError;
if (err != null)
{
invalidLoc.Add(g.Factory.CreatePoint(err.Coordinate));
}
}
return g.Factory.BuildGeometry(invalidLoc.ToArray());
}
示例15: ApplyTo
/// <summary>
///
/// </summary>
/// <param name="geom"></param>
public void ApplyTo(IGeometry geom)
{
for (int i = 0; i < geom.NumGeometries && !_isDone; i++)
{
IGeometry element = geom.GetGeometryN(i);
if (!(element is GeometryCollection))
{
Visit(element);
if (IsDone())
{
_isDone = true;
return;
}
}
else ApplyTo(element);
}
}