Giannis
Giannis

Reputation: 31

Get the exact point in which a Polygon Intersects with a polyline

I would like to ask you something regarding Intersection on SQL Server. I am running a project in which I am using a gmap. I have a polygon through which some polylines are passing through and some are not. I am using the STIntersection in order to get the exactly part of polyline which is in the polygon. Below is the t-sql that I am using to achieve this.

The issue now is that I want to find the exactly point in which each polyline touches the polygon through passing out. Do you have any workaround concerning this?

DECLARE @polygon geography;

DECLARE @polyline geography;

SET @g = (select Polygon from Polygons where id = @polygonID)

SET @h = (select GeogPolyline from Polylines where ID = @polylineId)
SET     @intersectedpart = (SELECT @g.STIntersection(@h).STAsText() )

Upvotes: 2

Views: 816

Answers (1)

Giannis
Giannis

Reputation: 31

I manage to resolve this using the below :

SET @result = (SELECT @g.STIntersection(@h).STStartPoint())

Using this you are geting the first point of intersection between the polyline and polygon

Upvotes: 1

Related Questions