本文整理汇总了C#中SqlGeometry.STNumPoints方法的典型用法代码示例。如果您正苦于以下问题:C# SqlGeometry.STNumPoints方法的具体用法?C# SqlGeometry.STNumPoints怎么用?C# SqlGeometry.STNumPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlGeometry
的用法示例。
在下文中一共展示了SqlGeometry.STNumPoints方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPoints
private static IList<SMPoint> GetPoints(SqlGeometry geometry)
{
SMPoint[] pts = new SMPoint[(int)geometry.STNumPoints()];
for (int i = 0; i < (int)geometry.STNumPoints(); i++)
{
SqlGeometry ptGeometry = geometry.STPointN(i);
pts[i] = new SMPoint((double)ptGeometry.STX, (double)ptGeometry.STY);
}
return pts;
}
示例2: ExpandEnv
private static void ExpandEnv(Envelope env, SqlGeometry geom)
{
for (int i = 0, c = geom.STNumPoints().Value; i < c; i++)
{
SqlGeometry geomPoint = geom.STPointN(i + 1);
env.ExpandToInclude(geomPoint.STX.Value, geomPoint.STY.Value);
}
}
示例3: GetPoints
private static Coordinate[] GetPoints(SqlGeometry geometry)
{
Coordinate[] pts = new Coordinate[geometry.STNumPoints().Value];
for (int i = 1; i <= pts.Length; i++)
{
SqlGeometry ptGeometry = geometry.STPointN(i);
pts[i - 1] = new Coordinate(ptGeometry.STX.Value, ptGeometry.STY.Value);
}
return pts;
}
示例4: ToPointList
// Converts a geometry (ring or linestring) to list of points
public static List<Point> ToPointList(SqlGeometry sqlGeometry)
{
List<Point> points = new List<Point>();
for (int i = 1; i <= sqlGeometry.STNumPoints(); i++)
{
SqlGeometry p = sqlGeometry.STPointN(i);
points.Add(new Point(p.STX.Value, p.STY.Value));
}
return points;
}
示例5: GetPoints
private static IList<SMPoint> GetPoints(SqlGeometry geometry)
{
int pointsNum = (int)geometry.STNumPoints();
SMPoint[] pts = new SMPoint[pointsNum];
for (int i = 1; i <= pointsNum; i++)
{
SqlGeometry ptGeometry = geometry.STPointN(i);
double z = ptGeometry.Z == SqlDouble.Null ? (double)ptGeometry.Z : 0;
pts[i - 1] = new SMPoint((double)ptGeometry.STX, (double)ptGeometry.STY, z);
}
return pts;
}
示例6: GetPoints
private static Coordinate[] GetPoints(SqlGeometry geometry)
{
var pts = new Coordinate[(int)geometry.STNumPoints()];
for (int i = 1; i <= (int)geometry.STNumPoints(); i++)
{
var ptGeometry = geometry.STPointN(i);
pts[i-1] = new Coordinate((double)ptGeometry.STX, (double)ptGeometry.STY);
}
return pts;
}
示例7: AddShortenedRingByBuilder
/// <summary>
/// Add points to single ring in polygon
/// </summary>
/// <param name="builder"></param>
/// <param name="ring"></param>
/// <param name="shortestDistance"></param>
private static void AddShortenedRingByBuilder(SqlGeometryBuilder builder, SqlGeometry ring,
SqlDouble shortestDistance)
{
var pointCount = ring.STNumPoints();
//var area = GetGeography(ring).STArea();
if (pointCount <= MinPointCountToProceed ) AddRingByBuilder(builder, ring);
else
{
try
{
var firstPoint = ring.STPointN(1);
var startPoint = firstPoint;
int resulPointCount = 0;
// Begin the polygon with the first point
builder.BeginFigure((double) firstPoint.STX, (double) firstPoint.STY);
// While there are still unchecked points in polygon
for (int i = 2; i <= pointCount; i++)
{
var secondPoint = ring.STPointN(i);
if (GetDistanceBetweenPoints(firstPoint, secondPoint) >= shortestDistance || (resulPointCount < MinPointCountInPolygon && i >= (pointCount - 1)))
{
resulPointCount++;
builder.AddLine((double) secondPoint.STX, (double) secondPoint.STY);
firstPoint = ring.STPointN(i);
}
}
// Add last point - the same as first
builder.AddLine((double) startPoint.STX, (double) startPoint.STY);
builder.EndFigure();
}
catch (System.Exception ex)
{
throw new Exception(string.Format(" AddShortenedRingByBuilder: {0} Точек в кольце:{1}", ex.Message,
pointCount));
}
}
}
示例8: AddRingByBuilder
private static void AddRingByBuilder(SqlGeometryBuilder builder, SqlGeometry ring)
{
try
{
var firstPoint = ring.STPointN(1);
var startPoint = firstPoint;
var pointCount = ring.STNumPoints();
// Begin the polygon with the first point
builder.BeginFigure((double) firstPoint.STX, (double) firstPoint.STY);
// While there are still unchecked points in polygon
for (int i = 2; i <= pointCount; i++)
{
var secondPoint = ring.STPointN(i);
builder.AddLine((double) secondPoint.STX, (double) secondPoint.STY);
}
// Add last point - the same as first
builder.AddLine((double) startPoint.STX, (double) startPoint.STY);
builder.EndFigure();
}
catch (System.Exception ex)
{
throw new Exception(string.Format(" AddRingByBuilder: {0}", ex.Message));
}
}
示例9: GetSegmentLength
/// <summary>
/// Returns length of segment in polygon
/// </summary>
/// <param name="geometry"></param>
/// <param name="firstPoint"></param>
/// <param name="secondPoint"></param>
/// <returns></returns>
public static SqlDouble GetSegmentLength(SqlGeometry geometry, SqlInt32 firstPoint, SqlInt32 secondPoint)
{
SqlInt32 pointNums = geometry.STNumPoints();
if (pointNums < firstPoint || pointNums < secondPoint) return 0;
var firstCoords = geometry.STPointN((int) firstPoint);
var secondCoords = geometry.STPointN((int) secondPoint);
return GetDistanceBetweenPoints(firstCoords, secondCoords);
}
示例10: GetPointsFromSqlGeometry
private static Point[] GetPointsFromSqlGeometry(SqlGeometry sqlGeometry)
{
Point[] points = new Point[(Int32)(sqlGeometry.STNumPoints())];
for (int i = 0; i < sqlGeometry.STNumPoints(); i++)
{
SqlGeometry pointGeometry = sqlGeometry.STPointN(i + 1);
points[i] = new Point((float)pointGeometry.STX.Value, (float)pointGeometry.STY.Value);
}
return points;
}
示例11: getBoundsFromPolygon
void getBoundsFromPolygon(SqlGeometry pol, ref int MinX, ref int MinY, ref int MaxX, ref int MaxY)
{
for (int i = 1; i <= pol.STNumPoints(); i++)
{
int x = (int)pol.STPointN(i).STX.Value;
int y = (int)pol.STPointN(i).STY.Value;
if (x < MinX) { MinX = x; }
if (y < MinX) { MinY = y; }
if (x > MinX) { MaxX = x; }
if (y > MinX) { MaxY = y; }
}
}
示例12: Decode
private Geometry Decode(SqlGeometry g)
{
PathGeometry result = new PathGeometry();
switch (g.STGeometryType().Value.ToLower())
{
case "point":
PathFigure pointFig = new PathFigure();
pointFig.StartPoint = new Point(g.STX.Value - 2, g.STY.Value - 2);
LineSegment pointLs = new LineSegment(new Point(g.STX.Value + 2, g.STY.Value + 2), true);
pointFig.Segments.Add(pointLs);
result.Figures.Add(pointFig);
pointFig = new PathFigure();
pointFig.StartPoint = new Point(g.STX.Value - 2, g.STY.Value + 2);
pointLs = new LineSegment(new Point(g.STX.Value + 2, g.STY.Value - 2), true);
pointFig.Segments.Add(pointLs);
result.Figures.Add(pointFig);
return result;
case "polygon":
string cmd = new string(g.STAsText().Value).Trim().Substring(8);
string[] polyArray = (cmd.Substring(1, cmd.Length - 2) + ", ").Split('(');
var polys = from s in polyArray
where s.Length > 0
select s.Trim().Substring(0, s.Length - 3);
PathFigure fig;
foreach (var item in polys)
{
fig = new PathFigure();
var polyPoints = from p in item.Split(',')
select p.Trim().Replace(" ", ",");
fig.StartPoint = Point.Parse(polyPoints.ElementAt(0));
for (int i = 1; i < polyPoints.Count(); i++)
{
LineSegment ls = new LineSegment(Point.Parse(polyPoints.ElementAt(i)), true);
fig.Segments.Add(ls);
}
result.Figures.Add(fig);
}
return result;
case "linestring":
PathFigure lsfig = new PathFigure();
lsfig.StartPoint = new Point(g.STPointN(1).STX.Value, g.STPointN(1).STY.Value);
for (int i = 1; i <= g.STNumPoints(); i++)
{
LineSegment ls = new LineSegment();
ls.Point = new Point(g.STPointN(i).STX.Value, g.STPointN(i).STY.Value);
lsfig.Segments.Add(ls);
}
result.Figures.Add(lsfig);
return result;
case "multipoint":
case "multilinestring":
case "multipolygon":
case "geometrycollection":
GeometryGroup mpG = new GeometryGroup();
for (int i = 1; i <= g.STNumGeometries().Value; i++)
mpG.Children.Add(Decode(g.STGeometryN(i)));
return mpG;
default:
return Geometry.Empty;
}
}
示例13: ReprojectFigure
private void ReprojectFigure(SqlGeometry geometry, SqlGeometryBuilder bldr)
{
SqlGeometry point;
int numPoints = geometry.STNumPoints().Value;
double[] pts = new double[numPoints * 2];
for (int i = 0, idx = 0; i < numPoints; i++)
{
point = geometry.STPointN(i + 1);
pts[idx++] = point.STX.Value;
pts[idx++] = point.STY.Value;
}
if (numPoints > 0)
{
DotSpatial.Projections.Reproject.ReprojectPoints(pts, null, _proj_source, _proj_target, 0, numPoints);
bldr.BeginFigure(pts[0], pts[1]);
for (int i = 2; i < pts.Length; i += 2)
bldr.AddLine(pts[i], pts[i + 1]);
bldr.EndFigure();
}
}