/// <summary> /// Returns a System.Collections.List if integer shape indecies /// </summary> /// <param name="mwShapefile">The MapWinGIS.Shapefile to find shapes from</param> /// <param name="ShapeIndex">The integer shape index in shapefile of the shape to compare with</param> /// <returns>A System.Collections.List of integers that are the shape indecies of shapes overlapping extents</returns> public static List <int> ShapesWithIntersectingEnvelope(MapWinGIS.Shapefile mwShapefile, int ShapeIndex) { List <int> Shapelist = new List <int>(); MapWinGIS.Extents ext1, ext2; ext1 = mwShapefile.QuickExtents(ShapeIndex); for (int shp = 0; shp < mwShapefile.NumShapes; shp++) { if (shp == ShapeIndex) { continue; } ext2 = mwShapefile.QuickExtents(shp); if (ext1.xMin >= ext2.xMax) { continue; } if (ext1.yMin >= ext2.yMax) { continue; } if (ext2.xMin >= ext1.xMax) { continue; } if (ext2.yMin >= ext1.yMax) { continue; } Shapelist.Add(shp); } return(Shapelist); }
/// <summary> /// Determines if two shapes in the same shapefile have rectangular extents that touch or intersect. /// </summary> /// <param name="mwShapefile">A MapWinGIS.Shapefile containing both shapes to compare</param> /// <param name="ShapeIndex1">The integer index of the first shape</param> /// <param name="ShapeIndex2">The integer index of the second shape</param> /// <returns>Boolean, true if the extents overlap or touch</returns> public static bool EnvelopeIntersect(MapWinGIS.Shapefile mwShapefile, int ShapeIndex1, int ShapeIndex2) { MapWinGIS.Extents ext1; MapWinGIS.Extents ext2; ext1 = mwShapefile.QuickExtents(ShapeIndex1); ext2 = mwShapefile.QuickExtents(ShapeIndex2); if (ext1.xMin >= ext2.xMax) { return(false); } if (ext1.yMin >= ext2.yMax) { return(false); } if (ext2.xMin >= ext1.xMax) { return(false); } if (ext2.yMin >= ext1.yMax) { return(false); } return(true); }