TXT

Google-CellID-Location

By Scott Snyder,2014-07-06 00:30
16 views 0
Google-CellID-Location

/**

     *

    ?ñÈ??ù?ÝcellidµÃµ???Î??È( http://code.google.com/p/gears/wiki/GeolocationAPI)ÇëÇóµÄURL

     *

     * @param id

     * String Cell-id (hexadecimal value)

     * @param lac

     * String Location Area Code (hexadecimal value)

     * @param mcc

     * String Mobile Country Code

     * @param mnc

     * String Mobile Network Code

     * @return ?ù?ÝcellidµÃµ???Î??ÈÇëÇóµÄURL

     */

     private static String getURL(String id, String lac, String mcc, String mnc) {

     return new StringBuffer().append("{\n").append(" \"version\": \"1.1.0\",\n").append(" \"host\":

    \"maps.google.com\",\n").append(" \"cell_towers\": [\n").append(" {\n").append(" \"cell_id\": " + id + ",\n").append(" \"location_area_code\": " + lac + ",\n").append(" \"mobile_country_code\": " + mcc + ",\n").append(" \"mobile_network_code\": " + mnc +

    "\n").append(" }\n").append(" ]\n").append("}").toString();

     // return new StringBuffer().append("{\n").append(" \"version\": \"1.1.0\",\n").append(" \"host\":

    \"maps.google.com\",\n").append(" \"cell_towers\": [\n").append(" {\n").append(" \"cell_id\": " + id + ",\n").append(" \"location_area_code\": " + lac + ",\n").append("

    \"mobile_country_code\": " + mcc + ",\n").append("

    \"mobile_network_code\": " + mnc + ",\n").append(" \"age\": " + 0 + ",\n").append(" \"signal_strength\": " + -60 + ",\n").append(" \"timing_advance\": " + 6666 +

    "\n").append(" }\n").append(" ]\n").append("}").toString();

     // return new StringBuffer().append("{\n").append(" \"version\": \"1.1.0\",\n").append(" \"host\":

    \"maps.google.com\",\n").append(" \"request_address\": true,\n").append(" \"address_language\": \"zh-cn\",\n").append(" \"cell_towers\": [\n").append(" {\n").append(" \"cell_id\": " + id + ",\n").append(" \"location_area_code\": " + lac + ",\n").append(" \"mobile_country_code\": " + mcc + ",\n").append("

    \"mobile_network_code\": " + mnc +

    "\n").append(" }\n").append(" ]\n").append("}").toString();

     //

    {"location":{"latitude":28.172484,"longitude":112.949441,"address":{"country":"ÖÐ?ú","country_code":"CN","region":"ºþÄÏÊ?","city":"??É?ÊÐ","street":"äìÏæÖÐÂ?","street_number":"225ºÅ"},"accuracy":910.0},"access_token":"2:pgbNlMkVh8cr67ZI:oaj7QRN5sWBsiXVo"}

     }

     /**

     * ?ù?ÝcellidµÃµ???Î??È???âÊÔÓÃÀý×Ó??getLatLon("23092366", "10352", "466", "92")??

     *

     * @param id

     * String Cell-id (hexadecimal value)

     * @param lac

     * String Location Area Code (hexadecimal value) Î?ÖÃÇøÓòÂë,Ê??ðÒ??öGSMPLMNÍøÖеÄÎ?ÖÃÇø??LACµÄ×î?ó???ÈΪ16bits,Ò??öGSMPLMNÖÐ?ÉÒÔ??Òå65536?ö??Í?µÄÎ?ÖÃÇø

     * @param mcc

     * String Mobile Country Code

    ÒÆ??ÓÃ??ËùÊô?ú?Ò?úºÅ,ÖÐ?úµÄÊÇ460( http://en.wikipedia.org/wiki/List_of_mobile_country_codes)

     * @param mnc

     * String Mobile Network Code

    ÒÆ??ÍøºÅÂë,ÖÐ?úÒÆ??ÊÇ00?ò02( http://en.wikipedia.org/wiki/Mobile_Network_Code)

     * @return ??Î??È(24.821281,121.020065)

     */

     public static String getLatLon(String id, String lac, String mcc, String mnc) {

     String jsonStr = ServiceTools.getTextFromGoogleGears(" http://www.google.com/loc/json", getURL(id, lac, mcc, mnc));

     if (jsonStr != null) {

     ServiceLog.logMsg(jsonStr);

     int latIndex = jsonStr.indexOf("lati");

     int lonIndex = jsonStr.indexOf("long");

     if (latIndex != -1 && lonIndex != -1) {

     int end = jsonStr.substring(lonIndex).indexOf(",");

     if (end != -1) {

     return jsonStr.substring(latIndex + 10, lonIndex - 2) + "," + jsonStr.substring(lonIndex + 11, lonIndex + end);

     }

     }

     }

     return null;

     }

Report this document

For any questions or suggestions please email
cust-service@docsford.com