本文整理汇总了C#中SqlGeometry.STNumGeometries方法的典型用法代码示例。如果您正苦于以下问题:C# SqlGeometry.STNumGeometries方法的具体用法?C# SqlGeometry.STNumGeometries怎么用?C# SqlGeometry.STNumGeometries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlGeometry
的用法示例。
在下文中一共展示了SqlGeometry.STNumGeometries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlGeometryToGeometryMultiPoint
private static IGeometry SqlGeometryToGeometryMultiPoint(SqlGeometry geometry, GeometryFactory factory)
{
IPoint[] points = new IPoint[geometry.STNumGeometries().Value];
for (int i = 1; i <= points.Length; i++)
points[i - 1] = SqlGeometryToGeometryPoint(geometry.STGeometryN(i), factory);
return factory.CreateMultiPoint(points);
}
示例2: SqlGeometryToGeometryMultiLineString
private static IMultiLineString SqlGeometryToGeometryMultiLineString(SqlGeometry geometry, GeometryFactory factory)
{
ILineString[] lineStrings = new ILineString[geometry.STNumGeometries().Value];
for (int i = 1; i <= lineStrings.Length; i++)
lineStrings[i - 1] = SqlGeometryToGeometryLineString(geometry.STGeometryN(i), factory);
return factory.CreateMultiLineString(lineStrings);
}
示例3: SqlGeometryToGeometryGeometryCollection
private static IGeometryCollection SqlGeometryToGeometryGeometryCollection(SqlGeometry geometry, GeometryFactory factory)
{
IGeometry[] geoms = new IGeometry[geometry.STNumGeometries().Value];
for (int i = 1; i <= geoms.Length; i++)
geoms[i - 1] = SqlGeometryToGeometry(geometry.STGeometryN(i), factory);
return factory.CreateGeometryCollection(geoms);
}
示例4: BuildMultipolygonSimplified
/// <summary>
/// Builds multipoligon by each polygon inside geometry collection
/// </summary>
public static void BuildMultipolygonSimplified(SqlGeometryBuilder builder, SqlGeometry shape,
SqlDouble shortestDistance)
{
builder.BeginGeometry(OpenGisGeometryType.MultiPolygon);
var polygonCount = shape.STNumGeometries();
for (int i = 1; i <= polygonCount; i++)
{
BuildPolygonSimplified(builder, shape.STGeometryN(i), shortestDistance);
}
// End the geometry
builder.EndGeometry();
}
示例5: CorrigerUnionGeometry
public static SqlGeometry CorrigerUnionGeometry(SqlGeometry geom, int srid)
{
SqlGeometry geomBase = SqlTypesExtensions.STGeomFromText("POINT EMPTY", srid);
for (int i = 1; i <= geom.STNumGeometries(); i++)
{
SqlGeometry curGeom = geom.STGeometryN(i);
if (curGeom.STDimension().Value == 2)
{
SqlGeometry outerRing = curGeom.STExteriorRing();
List<SqlGeometry> holes = new List<SqlGeometry>();
for (int hole = 1; hole <= curGeom.STNumInteriorRing(); hole++)
{
SqlGeometry holeGeom = SqlTypesExtensions.PolygonFromRings(curGeom.STInteriorRingN(hole), null); // trou converti en polygone
double aire = holeGeom.GetAireEnMetres();
if (aire > AIRE_MINI_SCORIES)
{
List<SqlGeometry> nativeHoles = SqlTypesExtensions.ExteriorRingsFromPolygon(holeGeom); // polygone corrigé reconverti en linestring
holes.AddRange(nativeHoles);
}
}
curGeom = SqlTypesExtensions.PolygonFromRings(outerRing, holes);
geomBase = geomBase.STUnion(curGeom);
}
}
return geomBase;
}
示例6: SqlGeometryToSharpMapMultiPoint
private static SMGeometry SqlGeometryToSharpMapMultiPoint(SqlGeometry geometry)
{
SMMultiPoint multiPoint = new SMMultiPoint();
for (int i = 1; i <= geometry.STNumGeometries(); i++)
multiPoint.Points.Add((SMPoint)SqlGeometryToSharpMapPoint(geometry.STGeometryN(i)));
return multiPoint;
}
示例7: SqlGeometryToSharpMapGeometryCollection
private static SMGeometryCollection SqlGeometryToSharpMapGeometryCollection(SqlGeometry geometry)
{
SMGeometryCollection geometryCollection = new SMGeometryCollection();
for (int i = 0; i < geometry.STNumGeometries(); i++)
geometryCollection.Collection.Add(ToSharpMapGeometry(geometry.STGeometryN(i)));
return geometryCollection;
}
示例8: SqlGeometryToSharpMapMultiLineString
private static SMMultiLineString SqlGeometryToSharpMapMultiLineString(SqlGeometry geometry, Factory factory)
{
var fact = factory ?? Services.CreateGeometryFactory((int)geometry.STSrid);
var lineStrings = new SMLineString[(int)geometry.STNumGeometries()];
for (var i = 1; i <= geometry.STNumGeometries(); i++)
lineStrings[i-1] = (SMLineString)SqlGeometryToSharpMapLineString(geometry.STGeometryN(i), fact);
return fact.CreateMultiLineString(lineStrings);
}
示例9: MultiPolygonToMultiLineString
private SqlGeometry MultiPolygonToMultiLineString(SqlGeometry multipoly)
{
SqlGeometry result;
var geomBuilder = new SqlGeometryBuilder();
geomBuilder.SetSrid((0));
int geomnum = (int) multipoly.STNumGeometries();
for (int g = 1; g <= geomnum; g++)
{
AddMultiLineStringFromPolygon(geomBuilder, multipoly.STGeometryN(g));
}
result = geomBuilder.ConstructedGeometry;
if (result.STIsValid()) return result;
else return result.MakeValid();
}
示例10: CreateMultiPolygonFromGeometryCollectionWithExcludingLineString
private static SqlGeometry CreateMultiPolygonFromGeometryCollectionWithExcludingLineString( SqlGeometry geometry)
{
SqlGeometryBuilder builder = new SqlGeometryBuilder();
builder.SetSrid(0);
if (GetOpenGisGeometryType(geometry) != OpenGisGeometryType.GeometryCollection) return geometry;
builder.BeginGeometry(OpenGisGeometryType.MultiPolygon);
var polygonCount = geometry.STNumGeometries();
for (int i = 1; i <= polygonCount; i++)
{
var shape = geometry.STGeometryN(i);
if (GetOpenGisGeometryType(shape) == OpenGisGeometryType.Polygon)
{
RepeatPolygon(builder, shape);
}
}
// End the geometry
builder.EndGeometry();
return builder.ConstructedGeometry;
}
示例11: GetGeometryInfo
/// <summary>
/// Преобразует в списки координат с инфрмацией о типе геометрии
/// </summary>
/// <param name="shape"></param>
/// <returns></returns>
private GeometryInstanceInfo GetGeometryInfo(SqlGeometry shape)
{
var result = new GeometryInstanceInfo();
var type = (OpenGisGeometryType) Enum.Parse(typeof (OpenGisGeometryType), (string) shape.STGeometryType());
result.ShapeType = type;
//List<PointF> points = new List<PointF>();
PointF[] points;
List<GeometryPointSequence> pointSequenceList;
var shapesPointsCollection = new List<List<GeometryPointSequence>>();
switch (type)
{
case OpenGisGeometryType.Point:
points = new PointF[1];
SqlGeometry firstpoint = shape.STStartPoint();
points[0] = new PointF((float) firstpoint.STX, (float) firstpoint.STY);
pointSequenceList = new List<GeometryPointSequence>
{
new GeometryPointSequence {PointList = points, InnerRing = false}
};
shapesPointsCollection.Add(pointSequenceList);
break;
case OpenGisGeometryType.LineString:
points = shape.ToPointsFArray();
pointSequenceList = new List<GeometryPointSequence> { new GeometryPointSequence { PointList = points, InnerRing = false } };
shapesPointsCollection.Add(pointSequenceList);
break;
case OpenGisGeometryType.Polygon:
shapesPointsCollection = shape.ToGeometryPointsOfPolygon();
break;
case OpenGisGeometryType.MultiPoint:
case OpenGisGeometryType.MultiLineString:
shapesPointsCollection = shape.ToGeometryPointsOfMultiPointLineString();
break;
case OpenGisGeometryType.MultiPolygon:
shapesPointsCollection = shape.ToGeometryPointsOfMultiPolygon();
break;
case OpenGisGeometryType.GeometryCollection:
var geomNum = (int) shape.STNumGeometries();
var geometryList = new GeometryInstanceInfo[geomNum];
int i;
for ( i = 0; i < geomNum; i++)
geometryList[i] = GetGeometryInfo(shape.STGeometryN(i));
result.GeometryInstanceInfoCollection = geometryList;
break;
}
result.Points = shapesPointsCollection;
return result;
}
示例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: ReprojectMultiPolygon
private void ReprojectMultiPolygon(SqlGeometry geometry, SqlGeometryBuilder bldr)
{
bldr.BeginGeometry(OpenGisGeometryType.MultiPolygon);
for (int i = 1, c = geometry.STNumGeometries().Value; i <= c; i++)
ReprojectPolygon(geometry.STGeometryN(i), bldr);
bldr.EndGeometry();
}
示例14: SqlGeometryToGeometryMultiPolygon
private static IMultiPolygon SqlGeometryToGeometryMultiPolygon(SqlGeometry geometry, GeometryFactory factory)
{
IPolygon[] polygons = new IPolygon[geometry.STNumGeometries().Value];
for (var i = 1; i <= polygons.Length; i++)
polygons[i - 1] = SqlGeometryToGeometryPolygon(geometry.STGeometryN(i), factory);
return factory.CreateMultiPolygon(polygons);
}
示例15: DrawMultiLineString
private void DrawMultiLineString(SqlGeometry stroke, Color strokecolor, int width)
{
using (Pen pen = new Pen(strokecolor, width))
{
int geomnum = (int) stroke.STNumGeometries();
for (int i = 1; i <= geomnum; i++)
{
_graphics.DrawLines(pen, stroke.STGeometryN(i).ToPointsArray());
}
}
}