小编the*_*oid的帖子

matplotlib 底图绘制的纬度/经度坐标不正确

我正在尝试学习 matplotlib 和映射函数 Basemap,并尝试在地图上绘制一个简单的经纬度坐标列表。但是,将底图坐标转换为简单的 x/y 坐标会在地图上疯狂地绘制点,我不知道为什么。我的代码如下:

locationData = parseFile(locationFile)

fig = plt.figure(figsize=(8,8))
m = Basemap(projection='merc', resolution='h',
            llcrnrlat=49, llcrnrlon=-13.5,
            urcrnrlat=59.5, urcrnrlon=4)
m.drawcoastlines()
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='green', lake_color='aqua')

index=0
for entry in locationData:
    lat = entry["latitudeE7"]/1E7
    long = entry["longitudeE7"]/1E7
    x,y = m(lat, long)
    print("Plotting {} {} to x{} y{}".format(lat,long,x,y))
    plt.plot(x,y, 'ok', markersize=20)
    # break at 30 points for testing
    if index>30: break
    index+=1
plt.show()
Run Code Online (Sandbox Code Playgroud)

这是我从打印语句中得到的输出:

Plotting 52.------- 1.------- to x79364--.------- y-31476--.-------
Plotting 52.------- 1.------- to x79368--.------- y-31475--.-------
Plotting 52.------- 1.------- to x79362--.------- y-31471--.-------
Plotting …
Run Code Online (Sandbox Code Playgroud)

python matplotlib matplotlib-basemap

3
推荐指数
1
解决办法
1538
查看次数

Google OAuth API 令牌请求出现 404 错误

我正在尝试从 Google OAuth api 获取令牌。我已经成功获得临时授权码。

但是,我的请求返回 404 错误,并显示正常的 Google“这是一个错误”404 页面。这是我的Python代码:

data = {
    "code":auth_code,
    "client_id":client_id,
    "client_secret":client_secret,
    "redirect_uri":redirect_uri,
    "grant_type":"authorization_code"
    }
headers = {"Content-Type":"application/x-www-form-urlencoded"}
r = requests.post("https://googleapis.com/oauth/v4/token",data=data,headers=headers)
Run Code Online (Sandbox Code Playgroud)

无论我是否对参数进行 url 编码,我都会遇到相同的错误(我认为 requests 库无论如何都会这样做)。

这是我发送的更详细的数据(当然经过审查)

'client_id':'2-------------------------------------------0.apps.googleusercontent.com',
'client_secret': '5----------------------p',
'code': '4/A-------------------------- ... ------------------------------------fGE#',
'grant_type': 'authorization_code',
'redirect_uri': 'https://localhost'
Run Code Online (Sandbox Code Playgroud)

我知道这里的问题与我的非常相似,但提供的所有解决方案要么不起作用(url 编码),要么不适用(其他所有内容)。

我使用这个官方文档作为参考。

这可能是非常明显的,就像我在这里提出的大多数问题一样。

编辑-我试过了

data = "code="+auth_code+"&client_id="+client_id+"&client_secret="+client_secret+"&redirect_uri="+redirect_uri+"&grant_type=authorization_code"
Run Code Online (Sandbox Code Playgroud)

...返回 400。有或没有 url 编码。

python oauth google-api google-oauth

3
推荐指数
1
解决办法
9926
查看次数

将 SOIL.lib 与 GCC 一起使用 - 添加符号时出错:无法识别文件格式

我最近一直在尝试将我的 Visual Studio OpenGL 项目转移到 VS Code,在 Windows 10 上通过 mingw-x64 使用 GCC。由于我对 C++ 编程相当陌生,因此我在这一切方面取得了稳步进展,并且我'遇到了一个我无法解决的错误。

使用以下命令构建时:

C:\Lib\mingw-w64\mingw64\bin\g++.exe -LC:/Lib/lib -IC:/Lib/include -g main.cpp -lglew32 -lglfw3 -lSOIL -lopengl32 -o build.exe
Run Code Online (Sandbox Code Playgroud)

我一直收到这个错误:

C:/Lib/lib/SOIL.lib: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我使用的 SOIL.lib 在 Visual Studio 中运行良好,并且 GCC 似乎对我使用的其他 .lib 文件没有任何抱怨。

似乎没有太多关于正在发生的事情的信息,我发现很多不同的人对不同的事情有相同的错误,而且我无法弄清楚这个神秘的错误消息实际上出了什么问题。有人可以帮忙吗?

c++ opengl gcc soil

2
推荐指数
1
解决办法
9047
查看次数