C# SqlGeography从multipolygon获取多边形
我有一个表C# SqlGeography从multipolygon获取多边形,c#,polygon,geography,sqlgeography,C#,Polygon,Geography,Sqlgeography,我有一个表Town,其中列townbound包含相关城镇的多边形(geographydatatype) 对于每个城镇,我都会获得生成KML(XML)文件所需的多边形数据,如: sqlg = SqlGeography.STPolyFromText(new SqlChars( town.TownBoundary.WellKnownValue.WellKnownText), town.TownBoundary.CoordinateSystemId); for (int i = 1; i <= s
Town
,其中列townbound
包含相关城镇的多边形(geography
datatype)
对于每个城镇,我都会获得生成KML(XML)文件所需的多边形数据,如:
sqlg = SqlGeography.STPolyFromText(new SqlChars(
town.TownBoundary.WellKnownValue.WellKnownText),
town.TownBoundary.CoordinateSystemId);
for (int i = 1; i <= sqlg.STNumPoints(); i++)
{
SqlGeography point = sqlg.STPointN(i);
var pLong = (point.Long).ToString().Replace(",", ".");
var pLat = (point.Lat).ToString().Replace(",", ".");
double dLong = double.Parse(pLong, CultureInfo.InvariantCulture);
double dLat = double.Parse(pLat, CultureInfo.InvariantCulture);
kmlCoordinates.Add(new Vector(dLat, dLong)); //one point od polygon
}
sqlg=SqlGeography.STPolyFromText(新的SqlChars)(
城镇。城镇边界。驰名价值。驰名文本),
城镇、城镇边界、协调体系);
对于(int i=1;i求解它,在方法STMPolyFromText
中,我可以使用STNumGeometries
获得多边形数组
sqlg = SqlGeography.STMPolyFromText(
new SqlChars(town.TownBoundary.WellKnownValue.WellKnownText),
town.TownBoundary.CoordinateSystemId);
for (int i = 1; i <= sqlg.STNumGeometries(); i++)
{
SqlGeography poly = sqlg.STGeometryN(i);
//foreach poly
}
sqlg=SqlGeography.STMPolyFromText(
新SqlChars(town.TownBoundary.WellKnownValue.WellKnownText),
城镇、城镇边界、协调体系);
对于(int i=1;i