Skip to content
Discussion options

You must be logged in to vote

I have not tried it exactly but sth along these lines should work:

public class ClipLabelPosition
{
    private readonly SharpMap.Map _map;
    private GeoAPI.Geometries.IGeometry _clip;

    public ClipLabelPosition(SharpMap.Map map)
    {
        _map = map;
        map.MapViewOnChange += () => _clip = _map.Factory.ToGeometry(_map.Envelope);
    }

    public GeoAPI.Geometries.Coordinate GetClippedPosition(SharpMap.Data.FeatureDataRow row)
    {
        var g = _clip.Intersection(row.Geometry);
        return g.PointOnSurface.Coordinate;
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gcapnias
Comment options

Answer selected by gcapnias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #189 on March 08, 2021 11:51.