Hi Thinkgeo Team,
I am using PostgreSqlFeatureLayer to query and dissolve features as shown in the code snipet below
public
void
DissolveDistrict(Persistence.Web.Map.PostgreSqlFeatureLayer layer) {
layer.Open();
DataTable data = layer.FeatureSource.ExecuteQuery(
“select distinct dist_name from iringa_region”
);
DbfColumn NameColumn =
new
DbfColumn(
“dist_name”
, DbfColumnType.String,250,0);
PostgreSqlFeatureSource sources =
new
PostgreSqlFeatureSource(layer.ConnectionString, layer.TableName,
“gid”
);
ThinkGeo.MapSuite.Core.InMemoryFeatureLayer districts =
new
ThinkGeo.MapSuite.Core.InMemoryFeatureLayer();
districts.Open();
foreach
(DataRow dataRow
in
data.Rows)
{
Collection<AreaBaseShape> polygonShapes =
new
Collection<AreaBaseShape>();
Collection<Feature> features = layer.FeatureSource.GetFeaturesByColumnValue(
“dist_name”
, System.Convert.ToString(dataRow[0]));
foreach
(Feature feature
in
features)
{
AreaBaseShape polygonShape = (AreaBaseShape)feature.GetShape();
polygonShapes.Add(polygonShape);
}
int
count = polygonShapes.Count;
MultipolygonShape multiPolygonShape = PolygonShape.Union(polygonShapes);
Dictionary<
string
,
string
> Columns =
new
Dictionary<
string
,
string
>();
Columns.Add(
“dist_name”
, System.Convert.ToString(dataRow[0]));
Feature newFeature =
new
Feature(multiPolygonShape, Columns);
districts.InternalFeatures.Add(dataRow[0].ToString(),newFeature);
}
DefaultMap.DynamicOverlay.Layers.Clear();
districts.ZoomLevelSet.ZoomLevel02.DefaultTextStyle = TextStyles.Capital3(
“dist_name”
);
districts.ZoomLevelSet.ZoomLevel02.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
districts.ZoomLevelSet.ZoomLevel02.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.SimpleColors.PaleGreen);
districts.DrawingQuality = DrawingQuality.HighQuality;
DefaultMap.DynamicOverlay.Layers.Add(
“districts”
,districts);
DefaultMap.CurrentExtent = districts.GetBoundingBox();
districts.Close();
}
The result is as shown in the image below
The problem with the resulting layer as seen in the image above is that, it has alot of unwanted dots and lines. I expected to have only 5 polygons with clear area.
Secondly in my codes above there is a line as shown below for lebeling each resulting polygon but the labels are not appearing
districts.ZoomLevelSet.ZoomLevel02.DefaultTextStyle = TextStyles.Capital3(
“dist_name”
);
Can you please help me where I am going wrong?
Best Regards,
Vincent