SELECT
*
FROM
customers
WHERE
location.STIntersects(geography::STGeomFromText('POLYGON((139.781225 35.686380, 139.782368 35.683731, 139.777267 35.683319, 139.781225 35.686380))', 4326)) = 1
下記は右回りの座標でポリゴンを作成しています エラーにはなりませんが、空間検索ができません
SELECT
*
FROM
customers
WHERE
location.STIntersects(geography::STGeomFromText('POLYGON((139.781225 35.686380, 139.777267 35.683319, 139.782368 35.683731, 139.781225 35.686380))', 4326)) = 1
NetTopologySuite.Geometries.Polygonを使う
nugetでNetTopologySuiteをインストールします
あわせて読みたい
NetTopologySuite 2.5.0The NTS Topology Suite is an API for modelling and manipulating 2-dimensional linear geometry. It provides numerous geometric predicates and functions. NTS conf...
// 右回りの座標
var coordinates = new[] {
new Coordinate(139.781225, 35.686380),
new Coordinate(139.777267, 35.683319),
new Coordinate(139.782368, 235.683731),
new Coordinate(139.781225, 35.686380)
};
var polygon = new Polygon(new LinearRing(coordinates));
if(!polygon.Shell.IsCCW){
// 右回りなら座標を逆転させる
coordinates = coordinates.Reverse().ToArray();
}