计算用户点击谷歌地图/谷歌地球的边界网格坐标

发布于 2024-08-03 18:21:45 字数 1165 浏览 10 评论 0原文

我需要计算的质心或测地线中点 当用户在纬度/经度网格交叉点之间单击时。 交叉口在 GE 的大部分地区形成正方形,有时 拉长的矩形。这当然是由于地球的形状造成的。 我正在寻找一个有效的数学公式,允许用户 单击该网格之间的任意位置,然后单击一个准确的函数 (在 Javascript 或服务器端代码中)将采用假设的网格 分辨率(在本次讨论中假设间隔为 1 公里)和输入 应该返回该坐标系内的质心坐标的坐标 标线网格。

为了澄清这一点,请查看我的 Google 群组帖子中所附的图片:

http://google-earth-api.googlegroups.com/web/Picture+5.png?gda=h5oFPz8AAAD315KpovipQeBwdfGpmW3ZhBc9PTADwYa-n193hZ 6AItFmHuno63c7phcEXYVuRA6ccyFKn-rNKC-d1pM_IdV0&gsc= sz6bbAsAAABBKF7YXWYyc4GmXg-QruHj

我需要做的是,如果用户单击此网格中的任意位置 正方形,我需要找到该网格的质心或中心点 交集/正方形或至少边界网格坐标(构成正方形)。

如果我们假设网格是 UTM 标准并且最大分辨率为 1km(或者将其设为参数),我需要检测其他四个点 附近然后计算质心就不那么困难了。 我欢迎大家提出任何反馈意见,并表示感谢。

我没有一种简单的方法可以让用户单击网格上的任何位置并找到网格边界坐标(形成 4 个坐标的正方形)或必要的经纬网网格正方形的质心/中点。

一种想法是使用 UTM 坐标参考等参考尽可能多地使用假设。

如果我假设网格是 X 度宽,我们可以让一个纯 JavaScript 函数接受任何输入坐标并为我返回十进制的边界网格坐标吗?

我的另一个想法是在地理空间层中创建网格以获取任何输入坐标并返回最近的经纬网质心?

这有道理吗?

谢谢!

奥马尔

I have a requirement to calculate the centroid or geodesic midpoint of
when a user clicks in between the lat/long grid crossing.
The crossing forms a square in most parts of GE and sometimes
elongated rectangles. This is due to the shape of the earth of course.
I'm looking for a valid mathematical formula that would allow a user
to click anywhere in between this grid and then an accurate function
(in Javascript or server side code) that would take an assumed grid
resolution (say 1km intervals for this discussion) and the input
coordinates that should return a centroid coordinate within that
graticule grid.

To clarify please take a look at the attached image to my google group post:

http://google-earth-api.googlegroups.com/web/Picture+5.png?gda=h5oFPz8AAAD315KpovipQeBwdfGpmW3ZhBc9PTADwYa-n193hZ6AItFmHuno63c7phcEXYVuRA6ccyFKn-rNKC-d1pM_IdV0&gsc=sz6bbAsAAABBKF7YXWYyc4GmXg-QruHj

What I need to be able to do is if a user clicks anywhere in this grid
square, I need to find the centroid or center point of that grid
intersection/square or at least the bounding grid coordinates (that make the square).

If we assume that the grid is UTM standard and has a max resolution of
1km (or make this a parameter), I need to detect the four other points
nearby and then calculating the centroid is not as difficult.
I welcome any feedback you all may have and appreciate it.

I don't have a simple way of letting a user click anywhere on the grid and finding the grid bounding coordinates (making a square of 4 coordinates) or the centroid / midpoint of the graticule grid square necessary.

One thought is to use assumptions as much as possible using a reference such as UTM coordinate reference.

If I assume that the grid is X degrees wide, can we have a pure javascript function take any input coordinate and return for me the bounding graticule coordinates in Decimal Degrees?

Another thought I had was to create the grid in a geo-spatial layer to take any input coordinate and return the nearest centroid of the graticule?

Does this make sense?

Thanks!

Omar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最笨的告白 2024-08-10 18:21:45

这似乎是一个舍入问题

1) 您的用户单击地图上的任意位置

2) 您想要捕获单击以读出actualLat/actualLon 值

3) 并将其向下舍入到最近的离散网格值 minLat/minLon

4) 然后您想以某种方式计算并返回网格的中点作为

 midLat = minLat + deltaGridLat/2;
 midLon = minLon + deltaGridLon/2;

广告 2)在我的 中查找 .js 文件Maidenhead 定位器查看器 - 您当然可以重用代码来初始化 GE 事件处理程序和鼠标单击处理程序(注意我捕获右键单击)

事件处理程序本质上获取用户选择的位置,将其传递给函数 CoordToLoc (),其中坐标被转换为 Maidenhead 定位符字符串,然后显示在网页上的 inpLocator 字段中。

ad 3)这取决于您的网格 - 如果它绑定到离散的纬度/经度值(如我的情况),那么它就像舍入一样简单。如果网格点被定义为距参考点的距离偏移(以公里为单位),简单的方法是将您的参数除以单位长度并忽略小数位

希望这有帮助
祝你好运
迈克·D

this seems to be a rounding problem

1) your users click anywhere on the map

2) you want to trap the click to read out the actualLat/actualLon values

3) and round it down to the nearest discrete grid values minLat/minLon

4) then you want to calculate and return in some way the midpoint of the grid as

 midLat = minLat + deltaGridLat/2;
 midLon = minLon + deltaGridLon/2;

ad 2) look up the .js file in my Maidenhead locator viewer - you can surely reuse code for initializing the GE event handler and the handler for a mouse click (note I am trapping a RIGHT click)

The event handler essentially takes the user chosen location, passes it to function CoordToLoc() where the coordinates are converted to a Maidenhead locator string, which then is displayed in field inpLocator on the web page.

ad 3) this depends on your grid - if it is bound to discrete Lat/Lon values (as in my case) it's as simple as rounding. If the grid points are defined as distance offsets in km from a reference point, the simple approach would be to divide your argument by the unity length and disregard the decimal places

Hope this helps
Good luck
MikeD

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文