Foxtable(狐表)用户栏目专家坐堂 → 这段代码在狐表要怎么执行,需要引入什么?


  共有1537人关注过本帖树形打印复制链接

主题:这段代码在狐表要怎么执行,需要引入什么?

帅哥哟,离线,有人找我吗?
zhenghangbo
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:477 积分:4569 威望:0 精华:0 注册:2018/2/7 14:30:00
这段代码在狐表要怎么执行,需要引入什么?  发帖心情 Post By:2024/7/25 13:49:00 [显示全部帖子]

Imports System.Numerics

Module Module1

Sub Main()
' 定义多边形的顶点
Dim polygonPoints As New List(Of PointLatLng) From {
New PointLatLng(40.7128, -74.0060),
New PointLatLng(40.7128, -74.0050),
New PointLatLng(40.7118, -74.0050),
New PointLatLng(40.7118, -74.0060),
New PointLatLng(40.7128, -74.0060)
}

' 待检测的点
Dim testPoint As New PointLatLng(40.7125, -74.0055)

' 检查点是否在多边形内
Dim isInside As Boolean = IsPointInPolygon(testPoint, polygonPoints)

Console.WriteLine($"The point ({testPoint.Latitude}, {testPoint.Longitude}) is inside the polygon? {isInside}")
Console.ReadLine()
End Sub

Public Class PointLatLng
Public Property Latitude As Double
Public Property Longitude As Double

Public Sub New(latitude As Double, longitude As Double)
Me.Latitude = latitude
Me.Longitude = longitude
End Sub
End Class

Public Function IsPointInPolygon(ByVal point As PointLatLng, ByVal polygon As List(Of PointLatLng)) As Boolean
Dim x As Double = point.Longitude
Dim y As Double = point.Latitude
Dim inside As Boolean = False

For i As Integer = 0, j = polygon.Count - 1 To polygon.Count - 1
Dim xi As Double = polygon(i).Longitude
Dim yi As Double = polygon(i).Latitude
Dim xj As Double = polygon(j).Longitude
Dim yj As Double = polygon(j).Latitude

If ((yi > y) <> (yj > y)) AndAlso (x < (xj - xi) * (y - yi) / (yj - yi) + xi) Then
inside = Not inside
End If

j = i
Next

Return inside
End Function

End Module

 回到顶部
帅哥哟,离线,有人找我吗?
zhenghangbo
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:477 积分:4569 威望:0 精华:0 注册:2018/2/7 14:30:00
  发帖心情 Post By:2024/7/25 14:27:00 [显示全部帖子]

For i As Integer = 0, j = polygon.Count - 1 To polygon.Count - 1
这句代码语法错误

 回到顶部