Hello.
@pmeems I implemented dynamic Labels generation on a Polilyne layer using Your code:
const string filename = @"sf/clipByMapExtents.shp";
var handle = _axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosVectorLayer, true);
Assert.IsTrue(handle != -1, "Could not load layer: " + _axMap1.get_ErrorMsg(_axMap1.LastErrorCode));
var sf = _axMap1.get_Shapefile(handle);
// Zoom in:
_axMap1.ZoomIn(0.3);
// Make shape from map extents:
var clipShape = _axMap1.Extents.ToShape();
Assert.IsNotNull(clipShape, "Could not make shape from map extents");
// Make in-memory shapefile from shape:
var sfClip = new Shapefile();
if (!sfClip.CreateNewWithShapeID("", ShpfileType.SHP_POLYGON))
Assert.Fail("Can't create shapefile. Error: " + sfClip.ErrorMsg[sfClip.LastErrorCode]);
// Set projection:
sfClip.GeoProjection = _axMap1.GeoProjection.Clone();
var shpIndex = sfClip.EditAddShape(clipShape);
Assert.IsTrue(shpIndex != -1, "Could not add shape: " + sfClip.ErrorMsg[sfClip.LastErrorCode]);
// Clip:
var sfResult = sf.Clip(false, sfClip, false);
Assert.AreNotEqual(sf.NumShapes, sfResult.NumShapes, "No shapes were clipped.");
Everything works fine. However, if the layer is large I have performance issues. I would like to optimize the code a bit. But I don’t know how to do it. Can I clip only some lines and not all at once?