Hello,
I need to create shapefile from scratch and also make some queries afterwards and update some features.
Basically, I want to find all features that lie within each other.
I tried to use feature’s IsWithin and Contains method, but it didn’t work.
Here is my code:
ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polyline, sShapeFileName, pressureDef.Columns, Encoding.Default, OverwriteMode.Overwrite);
ShapeFileFeatureSource featureSource =
new
ShapeFileFeatureSource(sShapeFileName, ShapeFileReadWriteMode.ReadWrite);
featureSource.Open();
featureSource.BeginTransaction();
foreach
(PolyLine poly
in
polyLines)
{
if
(poly.Type.ToUpper() !=
"CLOSE"
)
continue
;
Collection<
string
> col =
new
Collection<
string
>();
col.Add(
"val:"
+ poly.Value.ToString(
"0.#"
));
LineShape line =
new
LineShape();
foreach
(PointD point
in
poly.PointList)
{
line.Vertices.Add(
new
Vertex(point.X, point.Y));
}
Feature f =
new
Feature(line, col);
f = f.MakeValid();
featureSource.AddFeature(f);
}
featureSource.CommitTransaction();
List<Feature> group;
var features = featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
foreach
(Feature curFeature
in
features)
{
group =
new
List<Feature>();
group.Add(curFeature);
foreach
(Feature f
in
features)
{
if
(f == curFeature)
continue
;
if
(curFeature.IsWithin(f))
{
group.Add(f);
}
}
if
(group.Count > 1)
{
}
}
featureSource.Close();
Thanks,
Inna