<small id='e6JIV'></small><noframes id='e6JIV'>

      <tfoot id='e6JIV'></tfoot>
      <legend id='e6JIV'><style id='e6JIV'><dir id='e6JIV'><q id='e6JIV'></q></dir></style></legend>
        <bdo id='e6JIV'></bdo><ul id='e6JIV'></ul>
      1. <i id='e6JIV'><tr id='e6JIV'><dt id='e6JIV'><q id='e6JIV'><span id='e6JIV'><b id='e6JIV'><form id='e6JIV'><ins id='e6JIV'></ins><ul id='e6JIV'></ul><sub id='e6JIV'></sub></form><legend id='e6JIV'></legend><bdo id='e6JIV'><pre id='e6JIV'><center id='e6JIV'></center></pre></bdo></b><th id='e6JIV'></th></span></q></dt></tr></i><div id='e6JIV'><tfoot id='e6JIV'></tfoot><dl id='e6JIV'><fieldset id='e6JIV'></fieldset></dl></div>

        地理位置 API 和在半径内查找用户

        时间:2023-09-30
      2. <i id='XEzrF'><tr id='XEzrF'><dt id='XEzrF'><q id='XEzrF'><span id='XEzrF'><b id='XEzrF'><form id='XEzrF'><ins id='XEzrF'></ins><ul id='XEzrF'></ul><sub id='XEzrF'></sub></form><legend id='XEzrF'></legend><bdo id='XEzrF'><pre id='XEzrF'><center id='XEzrF'></center></pre></bdo></b><th id='XEzrF'></th></span></q></dt></tr></i><div id='XEzrF'><tfoot id='XEzrF'></tfoot><dl id='XEzrF'><fieldset id='XEzrF'></fieldset></dl></div>

              <bdo id='XEzrF'></bdo><ul id='XEzrF'></ul>
                  <legend id='XEzrF'><style id='XEzrF'><dir id='XEzrF'><q id='XEzrF'></q></dir></style></legend>

                  <tfoot id='XEzrF'></tfoot>
                    <tbody id='XEzrF'></tbody>

                  <small id='XEzrF'></small><noframes id='XEzrF'>

                  本文介绍了地理位置 API 和在半径内查找用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个 Java 应用程序,我想找出访问者的位置.API 会给我一个访客的邮政编码,然后基于该邮政编码,我会找到一个查询并在我的应用程序中获取 25/50 英里半径内的用户.或者,访问者可以输入他们感兴趣的邮政编码,应用程序应该返回半径为 x 英里的用户.对于在系统中注册的用户,我们只有他们的邮政编码.我查看了一些选项,但没有找到确切的解决方案.我不想下载邮政编码数据库并维护它们.我不认为 Google API 支持这种东西.

                  I have a Java application and I would like to find out the location of a visitor. The API would give me a the zip code of visitor and then based on that zip code, I will find fire a query and get users in my application within 25/50 mile radius. Alternatively visitor can type in the zip code of their interest and application should return users withing x mile of radius. For the users who are registered in the system, we have only their zip code. I have looked around some options but not found the exact solution. I do not want to download the database of zip code and maintain them. I do not think Google API support this kind of stuff.

                  推荐答案

                  我找不到任何提供 API 的服务.经过大量研究,我发现您必须将邮政编码及其纬度和经度位置下载到表格中.然后计算要搜索的半径内的坐标.这是对我帮助很大的网站.http://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/

                  I could not find any service which offers API . After much research i found that you will have to download zip codes along with their latitude and longitude positions into a table. Then calculate co ordinates within the radius you want to search. This is the website which helped me a lot. http://www.dougv.com/2009/03/27/getting-all-zip-codes-in-a-given-radius-from-a-known-point-zip-code-via-php-and-mysql/

                  如果你真的不想使用 php,这里是 java 中的计算

                  Here is the calculation in java if you really if you do not want to work with php

                  //这您将通过根据邮政编码查询数据库来获得双纬度 = Double.parseDouble(zipCode.getLatitude());双经度 = Double.parseDouble(zipCode.getLongitude());

                  //this you will get by querying the database against the zip code Double latitude = Double.parseDouble(zipCode.getLatitude()); Double longitude = Double.parseDouble(zipCode.getLongitude());

                      Double latN =Math.asin(
                              Math.sin(Math.toRadians(latitude)) * Math.cos(distance/radius) + 
                              Math.cos(Math.toRadians(latitude)) * Math.sin(distance/radius) * Math.cos(Math.toRadians(0)));
                  
                  
                      Double latS =Math.asin(
                              Math.sin(Math.toRadians(latitude)) * Math.cos(distance/radius) + 
                              Math.cos(Math.toRadians(latitude)) * Math.sin(distance/radius) * Math.cos(Math.toRadians(180)));
                  
                  
                      Double longE = Math.toRadians(longitude) + 
                                      Math.atan2(
                                              Math.sin(Math.toRadians(90)) * Math.sin(distance/radius)* Math.cos(Math.toRadians(latitude)) 
                              , Math.cos(Math.toRadians(distance/radius)) - Math.sin(Math.toRadians(latitude))* Math.sin(Math.toRadians(latN)) );
                  
                      Double longW = Math.toRadians(longitude) + 
                      Math.atan2(
                                      Math.sin(Math.toRadians(270)) * Math.sin(distance/radius)* Math.cos(Math.toRadians(latitude)) 
                                  , Math.cos(Math.toRadians(distance/radius)) - Math.sin(Math.toRadians(latitude))* Math.sin(Math.toRadians(latN)) );
                  
                      System.out.println("Latutude N "+Math.toDegrees(latN) +" Latitide S "+Math.toDegrees(latS) +">>> Longitude E "+Math.toDegrees(longE) +" Longitude W "+Math.toDegrees(longW));
                  

                  这篇关于地理位置 API 和在半径内查找用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在Android中获得气压高度? 下一篇:如何使用 MaxMind 的 GeoIP 数据库来确定位置?

                  相关文章

                  最新文章

                  <small id='bt8UK'></small><noframes id='bt8UK'>

                  • <bdo id='bt8UK'></bdo><ul id='bt8UK'></ul>

                    <legend id='bt8UK'><style id='bt8UK'><dir id='bt8UK'><q id='bt8UK'></q></dir></style></legend>
                  1. <tfoot id='bt8UK'></tfoot>
                  2. <i id='bt8UK'><tr id='bt8UK'><dt id='bt8UK'><q id='bt8UK'><span id='bt8UK'><b id='bt8UK'><form id='bt8UK'><ins id='bt8UK'></ins><ul id='bt8UK'></ul><sub id='bt8UK'></sub></form><legend id='bt8UK'></legend><bdo id='bt8UK'><pre id='bt8UK'><center id='bt8UK'></center></pre></bdo></b><th id='bt8UK'></th></span></q></dt></tr></i><div id='bt8UK'><tfoot id='bt8UK'></tfoot><dl id='bt8UK'><fieldset id='bt8UK'></fieldset></dl></div>