2014-07-07 1 views
4

다각형 인 SqlGeography 목록이 있습니다. 나는 이것을 다중 다각형 형태의 하나의 SqlGeography에 결합하고 싶습니다.다각형 SqlGeographys에서 MultiPolygon SqlGeography 만들기

List<SqlGeography> areaPolygons = GetAreaPolygons() 
SqlGeography multiPoly = null; 

foreach (SqlGeography geog in areaPolygons) 
{ 
    /// Combine them somehow? 
} 

답변

5

나는, 더 효율적인 방법이 될 수있다 SqlGeographyBuilder를 사용하는 방법을 발견하지만,이 작품 :

List<SqlGeography> areaPolygons = GetAreaPolygons() 
SqlGeography multiPoly = null; 

SqlGeographyBuilder sqlbuilder = new SqlGeographyBuilder(); 
sqlbuilder.SetSrid(4326); 
sqlbuilder.BeginGeography(OpenGisGeographyType.MultiPolygon); 

foreach (SqlGeography geog in areaPolygons) 
{ 
    sqlbuilder.BeginGeography(OpenGisGeographyType.Polygon); 

    for (int i = 1; i <= geog.STNumPoints(); i++) 
     { 
      if (i == 1) 
       sqlbuilder.BeginFigure((double)geog.STPointN(i).Lat, (double)geog.STPointN(i).Long); 
      else 
       sqlbuilder.AddLine((double)geog.STPointN(i).Lat, (double)geog.STPointN(i).Long); 
     } 

     sqlbuilder.EndFigure(); 
     sqlbuilder.EndGeography(); 
} 

sqlbuilder.EndGeography(); 
multiPoly = sqlbuilder.ConstructedGeography; 
관련 문제