<div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/110508277?s=20&v=4" /><strong>YyJyyy</strong> left a comment <a href="https://github.com/openstreetmap/openstreetmap-website/issues/6099#issuecomment-2974912595">(openstreetmap/openstreetmap-website#6099)</a></div>
<blockquote>
<p dir="auto">顺便说一下,调用原始 Rails 代码将返回以下结果:</p>
<pre class="notranslate"><code class="notranslate">QuadTile.tile_for_point(35.2000381, 114.6629926)
=> 3875963095
</code></pre>
<p dir="auto">这匹配:</p>
<pre class="notranslate"><code class="notranslate"> id | latitude | longitude | changeset_id | visible | timestamp | tile | version
-------------+-----------+------------+--------------+---------+----------------------------+------------+---------
12394725448 | 352000381 | 1146629926 | 159556585 | t | 2025-06-14 18:37:20.996467 | 3875963095 | 1
</code></pre>
</blockquote>
<p dir="auto">您好,我自己在window上装的ruby,但是我写的公式:require_relative 'quad_tile'</p>
<h1 dir="auto">支持命令行输入整数经纬度和 zoom,自动转为度</h1>
<p dir="auto">print '请输入纬度 (整数): '<br>
lat_int = gets.strip.to_i<br>
print '请输入经度 (整数): '<br>
lon_int = gets.strip.to_i<br>
print '请输入缩放级别 (zoom): '<br>
zoom = gets.strip.to_i</p>
<p dir="auto">lat = lat_int / 10_000_000.0<br>
lon = lon_int / 10_000_000.0</p>
<p dir="auto">tile_id = QuadTile.tile_for_point(lat, lon, zoom)<br>
puts "tile_id: #{tile_id}"</p>
<h1 dir="auto">反查中心经纬度</h1>
<p dir="auto">center = QuadTile.tile_center_latlon(tile_id, zoom)<br>
puts "tile center lat/lon: #{center.inspect}"</p>
<p dir="auto">结果算出来的结果是这样的:<br>
C:\Users\Administrator\Desktop\test\lib>ruby quad_tile_test.rb<br>
请输入纬度 (整数): 351704956<br>
请输入经度 (整数): 1130668539<br>
请输入缩放级别 (zoom): 17<br>
tile_id: 6795010254<br>
tile center lat/lon: [35.170440629756364, 113.06716918945312]</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/6099#issuecomment-2974912595">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLI3KAERVD7KNXB7YNT3DYSINAVCNFSM6AAAAAB7JYJNXGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNZUHEYTENJZGU">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJZ46UNJ3ZUXUTLK4L3DYSINA5CNFSM6AAAAAB7JYJNXGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTVRKGIFG.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/6099/2974912595</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/6099#issuecomment-2974912595",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/6099#issuecomment-2974912595",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>