标签: maps

计算两个纬度 - 经度点之间的距离?(Haversine配方)

如何计算纬度和经度指定的两点之间的距离?

为了澄清,我想要以公里为单位的距离; 这些要点使用WGS84系统,我想了解可用方法的相对准确性.

algorithm math maps latitude-longitude haversine

852
推荐指数
19
解决办法
72万
查看次数

在MySQL数据库中存储纬度/经度时使用的理想数据类型是什么?

请记住,我将在lat/long对上执行计算,哪种数据类型最适合与MySQL数据库一起使用?

mysql mapping maps database-design latitude-longitude

420
推荐指数
14
解决办法
29万
查看次数

获取两个地理点之间的距离

我想制作一个应用程序来检查用户所在的最近的地方.我可以很容易地获得用户的位置,我已经有了纬度和经度的地方列表.

知道列表最近的位置与当前用户位置的最佳方法是什么.

我在谷歌API中找不到任何东西.

maps android geolocation

107
推荐指数
4
解决办法
14万
查看次数

rgdal包安装

这里的问题并不完全是如何通过R绘制地图,因为我已经发现这里有一个非常好的例子,而是如何让它工作.实际上,我无法加载库rgdal:

library(rgdal)
Error in library(rgdal) : there is no package called ‘rgdal’
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试手动安装上面的包时,我收到以下错误:

....
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/eualin/R/i686-pc-linux-gnu-library/2.15/rgdal’
Warning in install.packages : installation of package ‘/home/eualin/Downloads/rgdal_0.8-5.tar.gz’ had non-zero exit status
Run Code Online (Sandbox Code Playgroud)

欢迎任何投入!

maps r

107
推荐指数
7
解决办法
7万
查看次数

C++ map访问丢弃限定符(const)

以下代码表示将map传递constoperator[]方法会丢弃限定符:

#include <iostream>
#include <map>
#include <string>

using namespace std;

class MapWrapper {
public:
    const int &get_value(const int &key) const {
        return _map[key];
    }

private:
    map<int, int> _map;
};

int main() {
    MapWrapper mw;
    cout << mw.get_value(42) << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是因为地图访问中可能出现的分配吗?没有地图访问的函数可以声明为const吗?

MapWrapper.cpp:10: error: passing ‘const std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int> > >’ as ‘this’ argument of ‘_Tp& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = int, _Tp = int, _Compare = std::less<int>, _Alloc …

c++ maps stl const

106
推荐指数
4
解决办法
4万
查看次数

迭代打字稿地图

我正在尝试迭代打字稿地图,但我一直收到错误,我找不到任何解决方案,因为这样一个微不足道的问题.

我的代码是:

myMap : Map<string, boolean>;
for(let key of myMap.keys()) {
   console.log(key);
}
Run Code Online (Sandbox Code Playgroud)

我得到错误:

类型'IterableIteratorShim <[string,boolean]>'不是数组类型或字符串类型.

完整堆栈跟踪:

错误:Typescript发现以下错误:/home/project/tmp/broccoli_type_script_compiler-input_base_path-q4GtzHgb.tmp/0/src/app/project/project-data.service.ts(21,20):输入'IterableIteratorShim <[string ,boolean]>'不是数组类型或字符串类型.在BroccoliTypeScriptCompiler._doIncrementalBuild(/home/project/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:115:19)BroccoliTypeScriptCompiler.build(/ home/project/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:43:10)在/home/project/node_modules/broccoli-caching-writer/index.js:152:21在lib $ rsvp $$ internal $$ tryCatch(/ home/project/node_modules/rsvp) /dist/rsvp.js:1036:16)lib $ rsvp $$内部$$ invokeCallback(/home/project/node_modules/rsvp/dist/rsvp.js:1048:17)在lib $ rsvp $$ internal $$发布(/home/project/node_modules/rsvp/dist/rsvp.js:1019:11)在lib $ rsvp $ asap $$ flush(/home/project/node_modules/rsvp/dist/rsvp.js:1198:9) at_combinedTickCallback(internal/process/next_tick.js:67:7)at process._tickCallback(internal/process/next_tick.js:98:9)

我正在使用angular-cli beta5和typescript 1.8.10,我的目标是es5.有没有人有这个问题?

maps iterator typescript

95
推荐指数
10
解决办法
15万
查看次数

Openstreetmap:在网页中嵌入地图(如谷歌地图)

有没有办法在页面中嵌入/混搭OpenStreetMap(就像Google Maps API的工作方式一样)?

我需要在页面内部显示带有一些标记的地图,并允许拖动/缩放,可能是路由.我怀疑会有一些Javascript API,但我似乎无法找到它.

搜索为我提供了访问原始地图数据API,但这似乎更适合地图编辑; 此外,使用它对AJAX来说是一项繁重的任务.

javascript api maps openstreetmap

78
推荐指数
7
解决办法
10万
查看次数

谷歌地图Android API v2 - 检测地图上的触摸

我无法找到有关如何拦截新版Google Maps API v2上的地图触摸的示例.

我需要知道用户何时触摸地图以停止线程(地图围绕我当前位置的居中).

maps android google-maps touch google-maps-api-2

70
推荐指数
6
解决办法
7万
查看次数

测试地图的等效性

我有一个像这样的表驱动测试用例:

func CountWords(s string) map[string]int

func TestCountWords(t *testing.T) {
  var tests = []struct {
    input string
    want map[string]int
  }{
    {"foo", map[string]int{"foo":1}},
    {"foo bar foo", map[string]int{"foo":2,"bar":1}},
  }
  for i, c := range tests {
    got := CountWords(c.input)
    // TODO test whether c.want == got
  }
}
Run Code Online (Sandbox Code Playgroud)

我可以检查长度是否相同,并编写一个循环来检查每个键值对是否相同.但是当我想将它用于另一种类型的地图时(例如map[string]string),我必须再次编写此检查.

我最终做的是,我将地图转换为字符串并比较字符串:

func checkAsStrings(a,b interface{}) bool {
  return fmt.Sprintf("%v", a) != fmt.Sprintf("%v", b) 
}

//...
if checkAsStrings(got, c.want) {
  t.Errorf("Case #%v: Wanted: %v, got: %v", i, c.want, got)
}
Run Code Online (Sandbox Code Playgroud)

这假设等效映射的字符串表示是相同的,在这种情况下似乎是正确的(如果键是相同的,那么它们散列到相同的值,因此它们的顺序将是相同的).有一个更好的方法吗?在表驱动测试中比较两个映射的惯用方法是什么?

testing maps table-driven go equivalence

70
推荐指数
6
解决办法
4万
查看次数

将纬度/经度点转换为墨卡托投影上的像素(x,y)

我正在尝试将纬度/长点转换为2d点,以便我可以将它显示在世界的图像上 - 这是一个墨卡托投影.

我已经看到了各种方法来做这个以及关于堆栈溢出的几个问题 - 我已经尝试了不同的代码片段,虽然我得到了像素的正确经度,但纬度总是偏离 - 似乎越来越合理了.

我需要公式来考虑图像大小,宽度等.

我试过这段代码:

double minLat = -85.05112878;
double minLong = -180;
double maxLat = 85.05112878;
double maxLong = 180;

// Map image size (in points)
double mapHeight = 768.0;
double mapWidth = 991.0;

// Determine the map scale (points per degree)
double xScale = mapWidth/ (maxLong - minLong);
double yScale = mapHeight / (maxLat - minLat);

// position of map image for point
double x = (lon - minLong) * xScale;
double y …
Run Code Online (Sandbox Code Playgroud)

java math maps 2d mercator

65
推荐指数
3
解决办法
9万
查看次数