
Hi everybody,
Does anybody know how I can access the coordinates from a shapefile for examble to to get the nearest arc to a point?
Thank you very much in advance for your help!
Cheers
Madison


Coordinator
Mar 13, 2007 at 6:25 PM

Hi Madison,
I don't quite understand  do you want the coordinates of the extents of a shapefile (the full bounds of the all the shapes in the shapefile in the coordinate system of the shapefile) or the coordinates of a shape in the shapefile?
Also, determining the nearest spatial geometry (arc) to another geometry (point) needs to use a spatial relational model which is not yet part of SharpMap. You'll need to use something like
NTS for this.



Hi codekaizen,
thank you very much for your tip. I took it to heart and had a look at NTS. the result is the following code, which returns the coordinate on a linestring (myPseudoCoord), which is closest do a certain point, I got by GPS (currentX, currentY). It's sort of
a map matching algorithm for a routing application.
Dim currentX = koordGK.getX_GKoord()
Dim currentY = koordGK.getY_GKoord()
Dim i As UInteger = 0
Dim myShape As SharpMap.Data.Providers.ShapeFile = New SharpMap.Data.Providers.ShapeFile(STRROADSHAPEPATH)
myShape.Open()
Dim iFeature As UInteger = myShape.GetFeatureCount()
Dim currentPoint As New SharpMap.Geometries.Point(currentX, currentY)
Dim myPt As TerraNova.NetTopologySuite.Geometries.Geometry = SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(currentPoint, New TerraNova.NetTopologySuite.Geometries.GeometryFactory())
Dim myArcs As TerraNova.NetTopologySuite.Geometries.Geometry = SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(myShape.GetFeature(i).Geometry, New TerraNova.NetTopologySuite.Geometries.GeometryFactory())
Dim myPseudoCoord As TerraNova.NetTopologySuite.Geometries.Coordinate()
myPseudoCoord = TerraNova.NetTopologySuite.Operation.Distance.DistanceOp.ClosestPoints(myPt, myArcs)
Cheers
Madison


Developer
Mar 17, 2007 at 4:09 PM

Looking at napespace names, you're using a old version of NTS.
The latest release is here:
http://sourceforge.net/project/showfiles.php?groupid=144924&packageid=159419&release_id=443988



I'm using the Pocket PC version http://sourceforge.net/project/showfiles.php?groupid=144924&packageid=159420&release_id=345851
That's probably why it's an older version.

