/* Places & Geo Resources
429610
@Override
    public void getGeoDetails(final String id) {
        getDispatcher().invokeLater(new AsyncTask(GEO_DETAILS, listeners) {
            @Override
            public void invoke(List<TwitterListener> listeners) throws TwitterException {
                Place place = twitter.getGeoDetails(id);
                for (TwitterListener listener : listeners) {
                    try {
                        listener.gotGeoDetails(place);
                    } catch (Exception e) {
                        logger.warn("Exception at getGeoDetails", e);
                    }
                }
            }
        });
    }
889383
function buildResourceMap(resourceDefinitions, start) {
    var map = {};
    if(resourceDefinitions) {
      for(var i = 0, len = resourceDefinitions.length; i < len; i++) {
        addResourceToMap(map, resourceDefinitions[i], start);
      }
    }

    return map;
  }
889956
public function index() {
        
        $controller = new PageController();
        $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion'));
        
        $data = new ViewBag();
        $data->set('title', $controller->getPageTitle());
        $data->set('has_analysis', false);
        
        $ga_id = Filter::getInteger('ga_id');        
        
        if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) {
            $data->set('has_analysis', true);
            $data->set('geoanalysis', $ga);
            
            $controller
                ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL())
                ->addInlineJavascript('
                jQuery("#geodispersion-tabs").tabs();
                jQuery("#geodispersion-tabs").css("visibility", "visible");
                
                jQuery.get(
					"module.php",
					{
                        "mod" : "'. $this->module->getName() .'",  
                        "mod_action": "GeoAnalysis@dataTabs",
                        "ga_id" : "'.$ga_id.'"
                    },
					function(data){
						if(data){	    
							jQuery("#geodisp-data-general").html(data.generaltab);
							jQuery("#geodisp-data-generations").html(data.generationstab);
					    }
					    jQuery(".loading-image").hide();				    		
					},
					"json"
				);
            ');
        }
        
        ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render();
    }
925245
function Resource(url, params, actions, options$$1) {

    var self = this || {}, resource = {};

    actions = assign({},
        Resource.actions,
        actions
    );

    each(actions, function (action, name) {

        action = merge({url: url, params: assign({}, params)}, options$$1, action);

        resource[name] = function () {
            return (self.$http || Http)(opts(action, arguments));
        };
    });

    return resource;
}
914137
function SetGeoAnchor ( $attrlat, $attrlong, $lat, $long )
    {
        assert ( is_string($attrlat) );
        assert ( is_string($attrlong) );
        assert ( is_float($lat) );
        assert ( is_float($long) );

        $this->_anchor = array ( "attrlat"=>$attrlat, "attrlong"=>$attrlong, "lat"=>$lat, "long"=>$long );
    }
951867
function findStoresInRangeLocation(location, range, callback) {
  range = range || 3;

  geo.reverseGeocode(location, function(err, georesult) {
    if (err) return callback(err);
    findStoresInRange(georesult, range, callback);
  });
}
50979
def resolved_row(objs, geomatcher):
    """"""
    def get_locations(lst):
        for elem in lst:
            try:
                yield elem['location']
            except TypeError:
                yield elem

    geomatcher['RoW'] = geomatcher.faces.difference(
        reduce(
            set.union,
            [geomatcher[obj] for obj in get_locations(objs)]
        )
    )
    yield geomatcher
    del geomatcher['RoW']
802856
function mapSources (sourceMap, mapCallback) {
  let chain = Promise.resolve()
  function pushChain (path, index, arr) {
    chain = chain
      .then(() => mapCallback(path))
      .then(replacement => {
        arr[index] = replacement || path
      })
  }
  if (sourceMap.sources) {
    sourceMap.sources.forEach(pushChain)
  }
  if (sourceMap.sections) {
    sourceMap.sections.forEach(section => {
      if (section.map && section.map.sources) {
        section.map.sources.forEach(pushChain)
      }
    })
  }
  return chain.then(() => sourceMap)
}
1088820
def geo(*params):
    
    api = 'http://www.gpsspg.com/apis/maps/geo/'
    headers = {
        'Accept':'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
        'Accept-Encoding':'gzip, deflate',
        'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
        'Cookie':'ARRAffinity=7996acd7385beb55da51ad553ab9df60d6b742a8d0840faa612d0bd27f840017; Hm_lvt_15b1a40a8d25f43208adae1c1e12a514=1507564728; Hm_lpvt_15b1a40a8d25f43208adae1c1e12a514=1507564728; AJSTAT_ok_pages=1; AJSTAT_ok_times=1',
        'Host':'www.gpsspg.com',
        'Referer':'http://www.gpsspg.com/iframe/maps/qq_161128.htm?mapi=2',
        'User-Agent': random_user_agent(),
        'X-Requested-With':'XMLHttpRequest',
    }
    query_params = {
        'output': 'jsonp',
        'lat': params[0],
        'lng': params[1],
        'type': '0',
        'callback': 'jQuery110207091189337888508_1507564728439',
        '_': int(get_current_timestamp()),
    }
    http = HTTP()
    t, h, c, hi, s = http.get(api, headers=headers, params=query_params)
    rp = ReParser()
    real_data = rp.compute(r'address":".*","rids', t).replace('address":"', '').replace('","rids', '')
    return real_data
233656
function writeLocationFile(location) {
  console.log('Writing location.js file')
  if (getTargetPlatform() === 'win32') {
    location = location.replace(/\\/g, '\\\\')
  }

  var platform = getTargetPlatform()
  var arch = getTargetArch()

  var contents = 'module.exports.location = "' + location + '"\n'

  if (/^[a-zA-Z0-9]*$/.test(platform) && /^[a-zA-Z0-9]*$/.test(arch)) {
    contents +=
        'module.exports.platform = "' + getTargetPlatform() + '"\n' +
        'module.exports.arch = "' + getTargetArch() + '"\n'
  }

  fs.writeFileSync(path.join(libPath, 'location.js'), contents)
}
1098142
function mapResources (resources) {
    var result = {};

    resources.forEach(function (r) {
      result[r.urn] = r;
    });

    var categorisations = resources.filter(function (r) { return r.class === 'Categorisation'; });
    var dataflows = resources.filter(function (r) { return r.class === 'Dataflow'; });
    var categoryschemes = resources.filter(function (r) { return r.class === 'CategoryScheme'; });
    var categories = [];

    function getCategories (c) {
      if (c.items === undefined) return;
      c.items.forEach(getCategories);
      categories = categories.concat(c.items);
    }

    categoryschemes.forEach(getCategories);

    var categoryMap = {};
    categories.forEach(function (c) { categoryMap[c.urn] = c; });

    categorisations.forEach(function (c) {
      var source = result[c.source.href];
      var target = categoryMap[c.target.href];
      if (target === undefined) return;
      if (target.children === undefined) target.children = [];
      target.children.push(source);
    });

    return result;
  }
1000559
function() {

      var location = this.options.location, latLng;

      if (!location) { return; }

      if (typeof location == 'string') {
        this.find(location);
        return;
      }

      if (location instanceof Array) {
        latLng = new google.maps.LatLng(location[0], location[1]);
      }

      if (location instanceof google.maps.LatLng){
        latLng = location;
      }

      if (latLng){
        if (this.map){ this.map.setCenter(latLng); }
        if (this.marker){ this.marker.setPosition(latLng); }
      }
    }
835140
function buildGeom(item, params) {
    var geom = {},
        attr;

    for(var gtype in params.geom) {
      var val = params.geom[gtype];

      // Geometry parameter specified as: {Point: 'coords'}
      if(typeof val === 'string' && item.hasOwnProperty(val)) {
        if(gtype === 'GeoJSON') {
          geom = item[val];
        } else {
          geom.type = gtype;
          geom.coordinates = item[val];
        }
      }

      /* Handle things like:
      Polygon: {
        northeast: ['lat', 'lng'],
        southwest: ['lat', 'lng']
      }
      */
      else if(typeof val === 'object' && !Array.isArray(val)) {
        /*jshint loopfunc: true */
        var points = Object.keys(val).map(function(key){
          var order = val[key];
          var newItem = item[key];
          return buildGeom(newItem, {geom:{ Point: order}});
        });
        geom.type = gtype;
        /*jshint loopfunc: true */
        geom.coordinates = [].concat(points.map(function(p){
          return p.coordinates;
        }));
      }

      // Geometry parameter specified as: {Point: ['lat', 'lng', 'alt']}
      else if(Array.isArray(val) && item.hasOwnProperty(val[0]) && item.hasOwnProperty(val[1]) && item.hasOwnProperty(val[2])){
        geom.type = gtype;
        geom.coordinates = [Number(item[val[1]]), Number(item[val[0]]),  Number(item[val[2]])];
      }

      // Geometry parameter specified as: {Point: ['lat', 'lng']}
      else if(Array.isArray(val) && item.hasOwnProperty(val[0]) && item.hasOwnProperty(val[1])){
        geom.type = gtype;
        geom.coordinates = [Number(item[val[1]]), Number(item[val[0]])];
      }

      // Geometry parameter specified as: {Point: ['container.lat', 'container.lng', 'container.alt']}
      else if(Array.isArray(val) && isNested(val[0]) && isNested(val[1]) && isNested(val[2])){
        var coordinates = [];
        for (var i = 0; i < val.length; i++) {	// i.e. 0 and 1
          var paths = val[i].split('.');
          var itemClone = item;
          for (var j = 0; j < paths.length; j++) {
            if (!itemClone.hasOwnProperty(paths[j])) {
              return false;
            }
            itemClone = itemClone[paths[j]];	// Iterate deeper into the object
          }
          coordinates[i] = itemClone;
        }
        geom.type = gtype;
        geom.coordinates = [Number(coordinates[1]), Number(coordinates[0]), Number(coordinates[2])];
      }

      // Geometry parameter specified as: {Point: ['container.lat', 'container.lng']}
      else if(Array.isArray(val) && isNested(val[0]) && isNested(val[1])){
        var coordinates = [];
        for (var i = 0; i < val.length; i++) {	// i.e. 0 and 1
          var paths = val[i].split('.');
          var itemClone = item;
          for (var j = 0; j < paths.length; j++) {
            if (!itemClone.hasOwnProperty(paths[j])) {
              return false;
            }
            itemClone = itemClone[paths[j]];	// Iterate deeper into the object
          }
          coordinates[i] = itemClone;
        }
        geom.type = gtype;
        geom.coordinates = [Number(coordinates[1]), Number(coordinates[0])];
      }

      // Geometry parameter specified as: {Point: [{coordinates: [lat, lng]}]}
      else if (Array.isArray(val) && val[0].constructor.name === 'Object' && Object.keys(val[0])[0] === 'coordinates'){
        geom.type = gtype;
        geom.coordinates = [Number(item.coordinates[(val[0].coordinates).indexOf('lng')]), Number(item.coordinates[(val[0].coordinates).indexOf('lat')])];
      }
    }

    if(params.doThrows && params.doThrows.invalidGeometry && !GeoJSON.isGeometryValid(geom)){
      throw new InvalidGeometryError(item, params);
    }

    return geom;
  }
680478
function _useBrowserGeolocation(options) {
    return (options && options.geolocation !== undefined)?
      options.geolocation : EVT.settings.geolocation;
  }
216644
function pointToQuery(url, requestFormatter, responseFormatter) {
	  return function (inputSource) {
	    return function outputSource(start, outputSink) {
	      if (start !== 0) return;
	      inputSource(0, function (t, d) {
	        if (t === 1) {
	          var queryUrl = requestFormatter(url, { x: d.latlng.lng, y: d.latlng.lat });
	          query(queryUrl).then(function (res) {
	            var output = {
	              queryResult: responseFormatter(res),
	              latlng: d.latlng
	            };
	            outputSink(1, output);
	          });
	        } else {
	          outputSink(t, d);
	        }
	      });
	    };
	  };
	}
57465
function(terria, url) {
  DataSourceCatalogItem.call(this, terria);

  this._dataSource = undefined;
  this._readyData = undefined;

  this.url = url;

  /**
   * Gets or sets the GeoJSON data, represented as a binary blob, object literal, or a Promise for one of those things.
   * If this property is set, {@link CatalogItem#url} is ignored.
   * This property is observable.
   * @type {Blob|Object|Promise}
   */
  this.data = undefined;

  /**
   * Gets or sets the URL from which the {@link GeoJsonCatalogItem#data} was obtained.  This will be used
   * to resolve any resources linked in the GeoJSON file, if any.
   * @type {String}
   */
  this.dataSourceUrl = undefined;

  /**
   * Gets or sets an object of style information which will be used instead of the default, but won't override
   * styles set on individual GeoJSON features. Styles follow the SimpleStyle spec: https://github.com/mapbox/simplestyle-spec/tree/master/1.1.0
   * `marker-opacity` and numeric values for `marker-size` are also supported.
   * @type {Object}
   */
  this.style = undefined;

  /**
   * Gets or sets a value indicating whether the features in this GeoJSON should be clamped to the terrain surface.
   * @type {Boolean}
   */
  this.clampToGround = undefined;

  knockout.track(this, ["data", "dataSourceUrl", "style", "clampToGround"]);
}
739296
function getSourceTrees(pathsToSearch) {
	return {
		read: function(readTree) {
			var promises = _.map(pathsToSearch, function(path) {
				return new Promise(function(resolve) {
					fs.exists(path, function(exists) {
						resolve((exists) ? path : null);
					});
				});
			});

			return Promise.all(promises)
				.then(function(paths) {
					paths = _.filter(paths);
					if (paths.length === 0) throw new Error('No source paths found');
					return paths;
				})
				.then(function(paths) {
					console.log('Found source paths: ' + paths.join(', '));

					var pathTrees = _.map(paths, function(path) {
						return new Funnel(path, { srcDir: '.', destDir: path });
					});

					return readTree(mergeTrees(pathTrees));
				});
		},

		cleanup: function() {}
	};
}