see FOSS4G 開発者の為の、図形演算ライブラリガイド - Qiita [キータ]
注)gist/github で図形演算ができるわけではないので、あしからず
see FOSS4G 開発者の為の、図形演算ライブラリガイド - Qiita [キータ]
注)gist/github で図形演算ができるわけではないので、あしからず
| 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()); | |
| } | |
| } | |
| } |
| { | |
| "crs": { | |
| "properties": { | |
| "name": "urn:ogc:def:crs:OGC:1.3:CRS84" | |
| }, | |
| "type": "name" | |
| }, | |
| "features": [ | |
| { | |
| "geometry": { | |
| "coordinates": [ | |
| [ | |
| [137.0, 36.0], | |
| [137.0, 35.0], | |
| [140.0, 35.0], | |
| [137.0, 36.0] | |
| ] | |
| ], | |
| "type": "Polygon" | |
| }, | |
| "type": "Feature" | |
| }, | |
| { | |
| "geometry": { | |
| "coordinates": [ | |
| [135.0, 33.0], | |
| [140.0, 33.0], | |
| [140.0, 38.0], | |
| [135.0, 38.0], | |
| [135.0, 33.0] | |
| ], | |
| "type": "LineString" | |
| }, | |
| "type": "Feature" | |
| } | |
| ], | |
| "type": "FeatureCollection" | |
| } |