Skip to content

Instantly share code, notes, and snippets.

@amay077
Last active December 31, 2015 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amay077/8015841 to your computer and use it in GitHub Desktop.
Save amay077/8015841 to your computer and use it in GitHub Desktop.
using System;
using GeoAPI.Geometries;
using NetTopologySuite;
namespace TopologyTest
{
class MainClass
{
public static void Main(string[] args)
{
var service = NtsGeometryServices.Instance;
var gf = service.CreateGeometryFactory();
var polygonA = gf.CreatePolygon(new Coordinate[]
{
new Coordinate(34.0, 136.0),
new Coordinate(34.0, 138.0),
new Coordinate(37.0, 138.0),
new Coordinate(37.0, 136.0),
new Coordinate(34.0, 136.0)
});
var polygonB = gf.CreatePolygon(new Coordinate[]
{
new Coordinate(36.0, 137.0),
new Coordinate(35.0, 137.0),
new Coordinate(35.0, 140.0),
new Coordinate(36.0, 137.0)
});
polygonA.Intersection(polygonB).ToConsole("Intersection");
polygonA.Union(polygonB).ToConsole("Union");
polygonA.SymmetricDifference(polygonB).ToConsole("SymmetricDifference");
polygonA.Difference(polygonB).ToConsole("Difference");
polygonB.Buffer(0.5).ToConsole("Buffer");
}
}
public static class GeomExtensions
{
public static void ToConsole(this IGeometry geom, string tag) {
Console.WriteLine(tag + " - " + geom.ToString());
}
}
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment