Intersection of Geometry and point

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Dec 11, 2009 at 10:37 AM
Edited Dec 11, 2009 at 11:32 AM

Hey all,


Using Sharpmap V0.9 in a WinForms project.  I mostly work ontop of a raster file.


I've created a route via mouse clicks which is added to a vector layer similar to this (Just like in the how to):




...And so on...

GeomColl.Add(new SharpMap.Geometries.LineString(PointColl));

 vectorLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);




Now, the route draws correctly, and looks good, however, I wish to place points on the lines based upon where someone clicks.  Also using the how to documents,

I use the method FindGeoNearPoint from this how to:

Now, using this method, I run into the issue that "Attribute data is not supported by the geometryprovider".

So, this approach won't work for getting the nearest geometry for me; what should I use?

I tried using myVectorLayer.DataSource.GetGeometriesInView using a bounding box based upon where the user clicks +-100. That returns nothing.
If I make my +-1000, it WILL get the geometry of the line, however no matter where I click on the map it will return something. Obviously
this isnt what I want as Id like to get just the route (ideally, Id like to get the nearest segment of the route/the nearest point along that
particular segment), though I dont see any other obvious way to get the LINESTRING/POINT.

Any suggestions? Should I maybe use something other than a geometry layer so I can access my route?
Dec 11, 2009 at 11:22 AM

Hi soonerthennow, the GeometryProvider does not have any attribute data so cannot be used for labelling or theming use a GeometryFeatureProvider instead.

For the other issue have a look at the true intersection testing with nts example code.. hth jd

Dec 11, 2009 at 11:30 AM

Perfect, that worked with a simple one line change, thank you!