for GeoIP City only
513863
public Location getLocation(String str) {
        InetAddress addr;
        try {
            addr = InetAddress.getByName(str);
        } catch (UnknownHostException e) {
            return null;
        }

        return getLocation(addr);
    }
754089
function geoGetCoords($address,$depth=0) {
	    $_coords = false;
        switch($this->lookup_service) {
            case 'GOOGLE':
                $_url = sprintf('http://%s/maps/api/geocode/json?sensor=%s&address=%s',$this->lookup_server['GOOGLE'], $this->mobile==true?"true":"false", rawurlencode($address));
                if($_result = $this->fetchURL($_url)) {
                    $_result_parts = json_decode($_result);
                    if($_result_parts->status!="OK"){
                    	return false;
                    }
                    $_coords['lat'] = $_result_parts->results[0]->geometry->location->lat;
                    $_coords['lon'] = $_result_parts->results[0]->geometry->location->lng;
                }
                break;
            case 'YAHOO':
            default:        
                $_url = sprintf('http://%s/MapsService/V1/geocode?appid=%s&location=%s',$this->lookup_server['YAHOO'],$this->app_id,rawurlencode($address));
                if($_result = $this->fetchURL($_url)) {
                    preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U', $_result, $_match);
                    $_coords['lon'] = $_match[2];
                    $_coords['lat'] = $_match[1];
                }
                break;
        }         
        return $_coords;       
    }
356259
@Override
    public InstagramPaginatingResponse<InstagramFeedItem> getRecentMediaByGeographynId(String accessToken,
                                                                                       String geoId) throws InstagramError {
        return instagramEndpoints.getRecentMediaByGeographynId(accessToken, geoId);
    }
263832
public boolean isLocalSipURI(SipURI uri) {
		checkState();
		// XXX: InetAddress api is
		// crude.....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		ListeningPoint lp = this.provider.getListeningPoint(uri
				.getTransportParam());
		if (lp != null && lp.getIPAddress().equals(uri.getHost())
				&& lp.getPort() == uri.getPort()) {
			return true;
		} else {
			if (tracer.isFineEnabled()) {
				tracer.fine("Passed uri not local? Passed URI[" + uri
						+ "] doesnt match lp[" + lp + "]");
			}

			return false;
		}
	}
265621
function reverseGeocode(location, callback) {
  var latlng = util.format("%s,%s", location.lat, location.lng)
    , query = qs.stringify({ latlng: latlng, sensor: false })
    , reqtmpl = "http://maps.googleapis.com/maps/api/geocode/json?%s"
    , req = util.format(reqtmpl, query)
    , geo
    ;
  
  request(req, function(err, res, body) {
    if (err) {
      console.log('ERROR: ' + err);
      return callback(err);
    }

    console.log(body);

    geo = parseGoogleGeocodes(JSON.parse(body));

    if (!geo) {
      return callback("can't determine address");
    } else {
      return callback(null, geo);
    }
  });
}
680478
function _useBrowserGeolocation(options) {
    return (options && options.geolocation !== undefined)?
      options.geolocation : EVT.settings.geolocation;
  }
902078
def mapper_metro(self, _, data):
        
        # OSM POI record
        if 'tags' in data:
            type_tag = 1
            lonlat = data['coordinates']
            payload = data['tags']
        # Tweet with coordinates from Streaming API
        elif 'user_id' in data:
            type_tag = 2
            # only allow tweets from the listed domains to try and filter out
            # noise such as HR tweets, Weather reports and news updates
            accept = [
                "twitter\.com",
                "foursquare\.com",
                "instagram\.com",
                "untappd\.com"
            ]
            expr = "|".join(accept)
            if not re.findall(expr, data['source']):
                return
            lonlat = data['lonlat']
            payload = None
        # spatial lookup using Rtree with cached results
        metro = self.lookup.get(lonlat, METRO_DISTANCE)
        if not metro:
            return
        yield metro, (type_tag, lonlat, payload)
475803
function ( loc, cbk, opts ) {

    if ( ! loc ) {
        return cbk( new Error( "Geocoder.geocode requires a location.") );
    }

    return this.providerObj.geocode(this.providerOpts, loc, cbk, opts);

  }
174017
def match(ctx, features, profile, gps_precision):
    
    access_token = (ctx.obj and ctx.obj.get('access_token')) or None

    features = list(features)
    if len(features) != 1:
        raise click.BadParameter(
            "Mapmatching requires a single LineString feature")

    service = mapbox.MapMatcher(access_token=access_token)
    try:
        res = service.match(
            features[0],
            profile=profile,
            gps_precision=gps_precision)
    except mapbox.errors.ValidationError as exc:
        raise click.BadParameter(str(exc))

    if res.status_code == 200:
        stdout = click.open_file('-', 'w')
        click.echo(res.text, file=stdout)
    else:
        raise MapboxCLIException(res.text.strip())
761291
public function isGeoIPWorking()
    {
        $provider = LocationProvider::getCurrentProvider();
        return $provider instanceof GeoIp
        && $provider->isAvailable() === true
        && $provider->isWorking() === true;
    }
364296
public function isWorking()
    {
        if (!function_exists('mb_internal_encoding')) {
            return Piwik::translate('UserCountry_GeoIPCannotFindMbstringExtension',
                array('mb_internal_encoding', 'mbstring'));
        }

        $geoIpError = false;
        $catchGeoIpError = function ($errno, $errstr, $errfile, $errline) use (&$geoIpError) {
            $filename = basename($errfile);
            if ($filename == 'geoip.inc'
                || $filename == 'geoipcity.inc'
            ) {
                $geoIpError = array($errno, $errstr, $errfile, $errline);
            } else {
                throw new \Exception("Error in PHP GeoIP provider: $errstr on line $errline of $errfile"); // unexpected
            }
        };

        // catch GeoIP errors
        set_error_handler($catchGeoIpError);
        $result = parent::isWorking();
        restore_error_handler();

        if ($geoIpError) {
            list($errno, $errstr, $errfile, $errline) = $geoIpError;
            Log::warning("Got GeoIP error when testing PHP GeoIP location provider: %s(%s): %s", $errfile, $errline, $errstr);

            return Piwik::translate('UserCountry_GeoIPIncorrectDatabaseFormat');
        }

        return $result;
    }
83450
def ips_to_geojson(ipaddresses):
    """"""

    features = []

    for ipaddress in ipaddresses:
        geo = gi.record_by_addr(ipaddress)

        features.append({
            "type": "Feature",
            "properties": {
                "name": ipaddress
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    geo["longitude"],
                    geo["latitude"]
                ]
            }
        })

    points = {
        "type": "FeatureCollection",
        "features": features
    }

    return points
41770
def geo_location(c1, c2 = nil , c3 = nil)
      if c1.class != GeoLocationSelector
        # TODO: raise wrong number of arguments if c2 or c3 are nil
        selector = GeoLocationSelector.new
        selector.address do
          address c1
          city c2
          country c3
        end
      else
        selector = c1
      end

      soap_message = service.geo_location.get(credentials, selector.to_xml)
      add_counters(soap_message.counters)
    end
649535
public static GeoLocationRequest getHttpServletRequestGeoLocation(final HttpServletRequest request) {
        val loc = new GeoLocationRequest();
        if (request != null) {
            val geoLocationParam = request.getParameter("geolocation");
            if (StringUtils.isNotBlank(geoLocationParam)) {
                val geoLocation = Splitter.on(",").splitToList(geoLocationParam);
                loc.setLatitude(geoLocation.get(GEO_LOC_LAT_INDEX));
                loc.setLongitude(geoLocation.get(GEO_LOC_LONG_INDEX));
                loc.setAccuracy(geoLocation.get(GEO_LOC_ACCURACY_INDEX));
                loc.setTimestamp(geoLocation.get(GEO_LOC_TIME_INDEX));
            }
        }
        return loc;
    }
272372
public function getIPCountryISO($ip){
        try{
            $search = $this->geoIP->country($ip);
            if(is_object($search)){
                return $search->country->isoCode;
            }
        }
        catch(\Exception $e){
            // Cache any IP that arn't found in the database
        }
        return false;
    }
977631
def geocode(address):
    
    geocoding = {'s': 'rsv3',
                 'key': key,
                 'city': '全国',
                 'address': address}
    res = requests.get(
        "http://restapi.amap.com/v3/geocode/geo", params=geocoding)
    if res.status_code == 200:
        json = res.json()
        status = json.get('status')
        count = json.get('count')
        if status == '1' and int(count) >= 1:
            geocodes = json.get('geocodes')[0]
            lng = float(geocodes.get('location').split(',')[0])
            lat = float(geocodes.get('location').split(',')[1])
            return [lng, lat]
        else:
            return None
    else:
        return None
644637
def preform(url, type, params = {}, &block)
      ActiveSupport::Notifications.instrument 'Geoip2', request: type, base_url: url, params: params do
        block.call
      end
    end