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

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

      • <bdo id='mxeeq'></bdo><ul id='mxeeq'></ul>
    1. <tfoot id='mxeeq'></tfoot>
        <legend id='mxeeq'><style id='mxeeq'><dir id='mxeeq'><q id='mxeeq'></q></dir></style></legend>

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

        时间:2023-05-27

        <legend id='O5vMk'><style id='O5vMk'><dir id='O5vMk'><q id='O5vMk'></q></dir></style></legend>
          <tbody id='O5vMk'></tbody>

        1. <tfoot id='O5vMk'></tfoot>

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

            • <i id='O5vMk'><tr id='O5vMk'><dt id='O5vMk'><q id='O5vMk'><span id='O5vMk'><b id='O5vMk'><form id='O5vMk'><ins id='O5vMk'></ins><ul id='O5vMk'></ul><sub id='O5vMk'></sub></form><legend id='O5vMk'></legend><bdo id='O5vMk'><pre id='O5vMk'><center id='O5vMk'></center></pre></bdo></b><th id='O5vMk'></th></span></q></dt></tr></i><div id='O5vMk'><tfoot id='O5vMk'></tfoot><dl id='O5vMk'><fieldset id='O5vMk'></fieldset></dl></div>

              • <small id='O5vMk'></small><noframes id='O5vMk'>

                  本文介绍了地理位置 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 和在半径内查找用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

                  <legend id='50AA7'><style id='50AA7'><dir id='50AA7'><q id='50AA7'></q></dir></style></legend>
                1. <small id='50AA7'></small><noframes id='50AA7'>

                  <tfoot id='50AA7'></tfoot>

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