Skip to content

Commit

Permalink
Updated the FeatureTypeFromGeometryType method to work with GeometryC…
Browse files Browse the repository at this point in the history
…ollections (DotSpatial#1044)
  • Loading branch information
joe-Keysoft authored and jany-tenaj committed Aug 21, 2017
1 parent fdf6baf commit 6c78470
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ Be aware that code written for 1.9 will not work out of the box because DotSpati
- Some errors in SetSelectable plugin (#1008)
- Crash when attempting to use a serial GPS device on Mono
- Clear the selection inside FeatureLayer.RemoveSelectedFeatures so the removed features are no longer contained when IFeatureSet.FeatureRemoved is raised
- In InRamImageData.Open don't draw the image unscaled because this can cause the image not to be drawn
- In InRamImageData.Open don't draw the image unscaled because this can cause the image not to be drawn
- FeatureTypeFromGeometryType Method updated to work with GeometryCollection
3 changes: 2 additions & 1 deletion Contributors
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ Teva Veluppillai
Peder Wikstrom <[email protected]>
Chris Wilson
Ping Yang
Trent Muhr
Trent Muhr
Joe Houghton
29 changes: 27 additions & 2 deletions Source/DotSpatial.Data/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public virtual int Fid
{
return ShapeIndex?.RecordNumber - 1 ?? -2; // -1 because RecordNumber for shapefiles is 1-based.

// todo: The better will be remove RecordNumber from public interface to avoid ±1 issues.
// todo: The better will be remove RecordNumber from public interface to avoid ±1 issues.
}

return _parentFeatureSet.Features.IndexOf(this);
Expand Down Expand Up @@ -451,6 +451,31 @@ private static FeatureType FeatureTypeFromGeometryType(IGeometry geometry)
break;
case OgcGeometryType.MultiPoint:
featureType = FeatureType.MultiPoint;
break;
case OgcGeometryType.GeometryCollection:
IGeometryCollection geomCollection = geometry as IGeometryCollection;
if (geomCollection != null)
{
// Check to see if every featureType in the GeometryCollection matches
// else leave as FeatureType.Unspecified
FeatureType testFeatureType = FeatureType.Unspecified;
for (int i = 0; i < geomCollection.Count; i++)
{
if (i == 0)
{
testFeatureType = FeatureTypeFromGeometryType(geomCollection[i]);
}
else
{
FeatureType tempFeatureType = FeatureTypeFromGeometryType(geomCollection[i]);
if (testFeatureType != tempFeatureType)
return FeatureType.Unspecified; // if feature types do not match, then return Unspecified
}
}

featureType = testFeatureType;
}

break;
}

Expand Down Expand Up @@ -565,4 +590,4 @@ private void ReadPolygonShape(Shape shape)

#endregion
}
}
}

0 comments on commit 6c78470

Please sign in to comment.