Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps lat和长精度问题,取决于位置_Google Maps_Wt - Fatal编程技术网

Google maps lat和长精度问题,取决于位置

Google maps lat和长精度问题,取决于位置,google-maps,wt,Google Maps,Wt,我问你是因为我挣扎了几天;我在网上搜索了一下,没有找到任何东西 我需要在地图上精确地放置标记/圆圈/任何东西。 然而,我似乎只能在网格上绘制它们,网格的精度取决于我所在的位置。因此,它们的位置不够准确 我使用的是Wt(C++),但它似乎不是问题的一部分。 我写了一段代码,画了一个20*20的圆数组,它的坐标是等距的。无论是在巴黎还是在纽约,我都得不到同样的结果 在巴黎: (无法发布图像,因为这是我的第一个问题) 在纽约: 在巴黎,我得到的是准确的经度,但不是纬度。 在纽约,无论是纬度还是经度

我问你是因为我挣扎了几天;我在网上搜索了一下,没有找到任何东西

我需要在地图上精确地放置标记/圆圈/任何东西。 然而,我似乎只能在网格上绘制它们,网格的精度取决于我所在的位置。因此,它们的位置不够准确

我使用的是Wt(C++),但它似乎不是问题的一部分。 我写了一段代码,画了一个20*20的圆数组,它的坐标是等距的。无论是在巴黎还是在纽约,我都得不到同样的结果

在巴黎: (无法发布图像,因为这是我的第一个问题)

在纽约:

在巴黎,我得到的是准确的经度,但不是纬度。 在纽约,无论是纬度还是经度,我都无法获得准确度

以下是我使用的代码:

    /*Choose between both*/
    double centerLat = 40.714468; double centerLng = -74.005966;//New-York
    //double centerLat = 48.854607; double centerLng = 2.347126;//Paris

    /*Other parameters*/
    double lngMargin = 0.000400;
    double latMargin = 0.000400;
    int granularity = 20;

    int i,j;
    WVBoxLayout* layout = new WVBoxLayout();
    WColor::WColor myBlue = WColor::WColor(0,0,255,255);
    WColor::WColor myRed  = WColor::WColor(255,0,0,255);
    WColor::WColor myTransparent = WColor::WColor(0,0,0,0);
    WGoogleMap::Coordinate coordArray[granularity][granularity];

    /* Creating and configuring the map */
    WGoogleMap *map = new WGoogleMap(WGoogleMap::Version3);
    WGoogleMap::Coordinate centerCoord = WGoogleMap::Coordinate(centerLat,centerLng);
    setLayout(layout);
    resize(height,width);
    map->setCenter(centerCoord,19);
    map->setMapTypeControl(WGoogleMap::DefaultControl);
    map->enableScrollWheelZoom();
    map->addCircle(centerCoord,2,myBlue,2,myTransparent);

    /* Here is the loop that draws the circles */
    for(i=0 ; i<=granularity-1 ; i++){
            for(j=0 ; j<=granularity-1 ; j++){

                    coordArray[i][j] = WGoogleMap::Coordinate(centerLat + beforeOrAfterTheCenter_Lat * (latMargin/granularity) * i,
                                    centerLng + beforeOrAfterTheCenter_Lng * (lngMargin/granularity) * j); 

                    map->addCircle(coordArray[i][j],1,myRed,2,myTransparent);
            }
    }
/*在两者之间进行选择*/
双中心线=40.714468;双中心LNG=-74.005966//纽约
//双中心线=48.854607;双中心LNG=2.347126//巴黎
/*其他参数*/
双lngMargin=0.000400;
双板条余量=0.000400;
int粒度=20;
int i,j;
WVBoxLayout*布局=新的WVBoxLayout();
WColor::WColor myBlue=WColor::WColor(0,0255255);
WColor::WColor myRed=WColor::WColor(255,0,0255);
WColor::WColor myTransparent=WColor::WColor(0,0,0,0);
WGoogleMap::坐标坐标坐标数组[粒度][粒度];
/*创建和配置映射*/
WGoogleMap*map=新的WGoogleMap(WGoogleMap::Version3);
WGoogleMap::坐标中心坐标=WGoogleMap::坐标(centerLat,centerLng);
设置布局(布局);
调整大小(高度、宽度);
地图->设置中心(centerCoord,19);
map->setMapTypeControl(WGoogleMap::DefaultControl);
映射->启用ScrollWheelZoom();
地图->添加圆圈(centerCoord,2,myBlue,2,myTransparent);
/*这是画圆圈的循环*/

例如(i=0;i经过几个小时的努力,我终于发现了问题所在

我使用的是Wt(C++),但它似乎不是问题的一部分

事实上是这样。 Wt使用std::stringstream生成JavaScript代码,当您给该对象一个双精度时,该对象没有默认的无限精度:它只需要6位数字。这意味着,如果点前有1位数字,则点后有5位,如果点前有2位数字,则点后有4位。 这就是为什么巴黎的经度精度很高,但纬度精度不高(lng为6,lat为45)。这就是为什么纽约的经度和纬度精度都很差(都在点前有2位数字)

为了解决这个问题,我用我的一个自定义函数重载了addCircle(以及addMarker和所有其他函数),并设置了与 std::stringstream::精度(int n) 我还不知道的方法

我正在Wt redmine上报告这个问题,它可能很快就会得到纠正

海托,我是阿尤达


再见,

我猜投影在纬度上的差异是相等的,在像素上的差异是不相等的。试着在(纬度,经度)和(-lat,经度)之间画网格,看看形状是相似的还是颠倒的。也许在赤道附近它可以工作?海托,你是对的。非常感谢。接近(0,0),我有一个完美的网格,但我离这一点越远,情况就越糟。我会尝试用mapCanvasProjectionObject找出一个解决方案,并随时通知你。你认为它可以工作吗?你会尝试其他方法吗?我相信有一些投影,它们的纬度和距离相等。距离似乎相等。然而,我认为要将谷歌地图投影下的LatLngs转换为等距投影下的新LatLngs是很棘手的。可能有公式。我不知道有什么方法可以改变谷歌地图中的投影。