twitter4j geo流媒体纬度/经度新加坡及其他地区

时间:2016-07-05 21:56:15

标签: java twitter geolocation twitter4j bounding-box

虽然它可能与twitter4j geo streaming latitude/longitude for Hongkong看起来一样,但它不是。

我修改了twitter4j的流媒体示例代码并生成了这个代码:https://www.dropbox.com/s/gj75fghtqy5jajf/tweity.zip?dl=0

可以编译:

$ javac -classpath twitter4j-core-4.0.4.jar:twitter4j-media-support-4.0.4.jar:twitter4j-async-4.0.4.jar:twitter4j-examples-4.0.4.jar:twitter4j-stream-4.0.4.jar PrintFilterLocationStream.java

运行:

java -cp .:twitter4j-core-4.0.4.jar:twitter4j-media-support-4.0.4.jar:twitter4j-async-4.0.4.jar:twitter4j-examples-4.0.4.jar:twitter4j-stream-4.0.4.jar PrintFilterLocationStream "{{-126.562500,30.448674},{-61.171875,44.087585}}"

如果我得到正确的边界框,它的效果非常好,请参阅Can't get location filters to work using Twitter4J

但是对于新加坡,我已经从http://isithackday.com/geoplanet-explorer/index.php?woeid=24703045检查了位置,但不知怎的,它抱怨它无效。

[OUT]:

[Wed Jul 06 05:48:15 SGT 2016]Parameter not accepted with the role. 406:Returned by the Search API when an invalid format is specified in the request.
Returned by the Streaming API when one or more of the parameters are not suitable for the resource. The track parameter, for example, would throw this error if:
 The track keyword is too long or too short.
 The bounding box specified is invalid.
 No predicates defined for filtered resource, for example, neither track nor follow parameter defined.
 Follow userid cannot be read.
Latitude/longitude are not valid: 1.31, 103.75, 1.47, 103.87

406:Returned by the Search API when an invalid format is specified in the request.
Returned by the Streaming API when one or more of the parameters are not suitable for the resource. The track parameter, for example, would throw this error if:
 The track keyword is too long or too short.
 The bounding box specified is invalid.
 No predicates defined for filtered resource, for example, neither track nor follow parameter defined.
 Follow userid cannot be read.
Latitude/longitude are not valid: 1.31, 103.75, 1.47, 103.87

我也试过一个更大的盒子(新加坡"{{1,103},{2,104}}"),但它仍无效。

我已根据http://isithackday.com/geoplanet-explorer/index.php?start=malaysia尝试将"{{0.66364, 98.935059},{7.58378, 119.448433}}"用于Mlaysia,但它也无效。同样,印度尼西亚的"{{ -11.00485, 94.969833},{6.07573, 141.021805}}"也不起作用(http://isithackday.com/geoplanet-explorer/index.php?start=indonesia)。

  • 新加坡的纬度/经度值应该是多少?

  • 但马来西亚或印度尼西亚呢?

  • 是否有国家/城市的边界框列表?它看起来很容易成为静态列表?

1 个答案:

答案 0 :(得分:0)

twitter4j所需的坐标顺序与http://isithackday.com/geoplanet-explorer/index.php?start=singapore所示的相反...

对于新加坡,它是"{{103.618248,1.1158},{104.40847, 1.47062}}"

对于马来西亚,它是"{{98.935059,0.66364},{119.448433,7.58378}}"

对于印度尼西亚,它是"{{94.969833,-11.00485},{141.021805,6.07573}}"

除此之外,如果http://isithackday.com/geoplanet-explorer/index.php显示其他位置:

Bounding Box:
NE numA, numB
SW numC, numD

twitter4j FilterQuery.locations期望:

{{numD,numC},{numB,numA}}