This project has moved and is read-only. For the latest updates, please go here.

NetTopologySuite Data Provider

by Diego Guidi

The NtsProvider enables you to feed any SharpMap datasource through NetTopologySuite using any of its geoprocessing operations. See the code summaries for an example on usage of the NtsProvider.
Extension updated August 24 2006


Here's an example of how one could get all features that TRULY intersect each other.

// this will return an ArrayList of object IDs for geometries
// that intersect the passed geometry. (C#)
public ArrayList TrueGeomsIntersect(SharpMap.Data.Providers.ShapeFile sf, 
		SharpMap.Geometries.Geometry isect)
	ArrayList retval = new ArrayList();
	// convert the test geometry to NTS.
	GisSharpBlog.NetTopologySuite.Geometries.Geometry isectPt = 
			new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory());
	//this will filter out all the unreasonable geometries
	//before we do more complex intersection testing.
	System.Collections.Generic.List ids = 
	// loop through all the candidate geometries (a reduced set, 
	// from the "filter" we just ran.),test intersection
	bool doesIntersect = false;
	foreach (uint id in ids)
		//convert the candidate geometry to NTS
		GisSharpBlog.NetTopologySuite.Geometries.Geometry geom = 
				new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory());
		if (geom.Contains(isectPt))
	return retval;

Last edited Aug 24, 2006 at 9:12 PM by SharpGIS, version 6