how can I select ways as nodes with way center coords as node coords?
currently my query looks like this:
[out:json];
way
[amenity=drinking_water]
({{bbox}});
out center;
and my data looks like this:
{
"type": "way",
"id": 123,
"center": {
"lat": 1.23,
"lon": 4.56
},
"nodes": [
...
],
"tags": {
"name": "test"
}
}
but I need the data formatted like this:
{
"type": "node",
"id": 123,
"lat": 1.23,
"lon": 4.56,
"tags": {
"name": "test"
}
}
any idea how to convert the data with overpass?
Background:
I like to convert the overpass data to gpi but it seams that gpsbabel can not convert osm ways to waypoints for gpi.
I just get errors like this: osm: Way reference id "123" wasn't listed under nodes!
I guess the problem here is that gpsbabel doesn't understand center in your response. Instead it tries to read all nodes and their coordinates. But your response doesn't include any nodes, just references to them.
You could modify your query to return all necessary nodes, too, instead of only the way's center:
[out:json];
way
[amenity=drinking_water]
({{bbox}});
(._;>;);
out;
This response should then be parsable by gpsbabel but I'm not sure if it is the response you are looking for.
Related
I want to get all streets in NYC using http://overpass-turbo.eu/. I tried this:
[out:json]; area[name = "New York"]; (node(area)[highway=street]; ); out;
However it returns
{
"version": 0.6,
"generator": "Overpass API 0.7.55.1009 5e627b63",
"osm3s": {
"timestamp_osm_base": "2019-11-13T19:26:03Z",
"timestamp_areas_base": "2019-11-13T18:05:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
]
}
No elements. However this query:
[out:json]; area[name = "New York"]; ( node(area)[amenity=cinema]; node(area)[highway=street]; ); out;
for getting streets and cinemas, works:
{
"version": 0.6,
"generator": "Overpass API 0.7.55.1009 5e627b63",
"osm3s": {
"timestamp_osm_base": "2019-11-13T19:29:02Z",
"timestamp_areas_base": "2019-11-13T18:05:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "node",
"id": 344994897,
"lat": 41.7680892,
"lon": -73.9291000,
"tags": {
"amenity": "cinema",
"created_by": "Potlatch 0.10f",
"name": "Roosevelt Theater"
}
},
...
How should I modify the initial query to get the streets?
There are two errors in your query.
Error 1: highway=street
Where does this tag come from? street is not a valid value for the highway key. In fact, since you want to obtain all streets you have to omit the value completely and just query for highway.
Error 2: node()
A road is not a node but a way. So you have to query for way(area)[...] instead. This also requires a recurse-up step (>;) to retrieve all nodes of these ways.
Corrected query
[out:json]; area[name = "New York"]; (way(area)[highway]; ); (._;>;); out;
I use this query to get the latitude and longitude from node id in overpass API:
[out:json]; (
node(2314028892);
node(30223035);
node(268195434);
node(30223039);
); (._;>;); out;
I get this answer:
{
"version": 0.6,
"generator": "Overpass API 0.7.55.3 9da5e7ae",
"osm3s": {
"timestamp_osm_base": "2018-06-28T07:47:01Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "node",
"id": 30223035,
"lat": 52.2917680,
"lon": 10.5265481
},
{
"type": "node",
"id": 30223039,
"lat": 52.2894248,
"lon": 10.5268394
},
{
"type": "node",
"id": 268195434,
"lat": 52.2897618,
"lon": 10.5267852
},
{
"type": "node",
"id": 2314028892,
"lat": 52.2919739,
"lon": 10.5265271,
"tags": {
"bus": "yes",
"name": "Rühmer Weg",
"network": "VRB",
"operator": "Braunschweiger Verkehrs-GmbH",
"public_transport": "stop_position",
"ref": "464"
}
}
]
}
It seems that the elements in the answer have another order. I would like to now if I can get the answer in the same order as in the query. (First the node 2314028892, then 30223035, ... )
Anybody has any idea how could I get this done?
Use "out" after each query statement:
[out:json];
node(2314028892);out
node(30223035);out
node(268195434);out;
node(30223039);out;
For performance reasons, I would recommend to do this as post processing step on your end. You already know the correct sequence, so you can easily apply this to the query result. Also, you can specify multiple node id values in a single query:
[out:json]; node(id:2314028892, 30223035, 268195434, 30223039);out;
Side note: you can also leave out (._;>;); in your query. It's not needed in case of nodes.
I am trying to use Mapbox to calculate the duration between two locations however the examples here are incomplete (at least with my limited experience). I would like to connect to this API using server-side Java, however I can't even get a basic example working in javaScript, Python or simply in the address bar in my browser.
I can get an example working in my browser using this url and substituting in my API key:
https://api.mapbox.com/geocoding/v5/mapbox.places/Chester.json?country=us&access_token=pk.my-token-value
However I can't get a similar example working with the distance API. The best I can manage is something like this:
https://api.mapbox.com/distances/v1/driving/[13.41894,52.50055],[14.10293,52.50055]&access_token=pk.my-token-value.
But I have no idea how to format my coordinates as I can't find a single example.
Has anyone been able to get this working. Ideally in Java, but client-side JavaScript or a valid url would be a great start.
I should also add that I can't get the JavaScript or Python ones working as they rely on external librarys that aren't referenced anywhere in the documentation!.
Thanks in advance.
Looks like you can provide a list of 2 or more semi-colon separated coordinates:
https://api.mapbox.com/optimized-trips/v1/mapbox/driving/13.41894,52.50055;14.10293,52.50055?access_token=pk.your_token
returns:
{
"code":"Ok",
"waypoints":[
{"distance":9.0352511932471,"name":"","location":[13.418991,52.500625],"waypoint_index":0,"trips_index":0},
{"distance":91.0575241567836,"name":"Berliner Chaussee","location":[14.103096,52.499738],"waypoint_index":1,"trips_index":0}
],
"trips":
[
{"geometry":"}_m_Iu{{pA}ZuQ}Iad#}cAk^jr#etOdE_iGtTqoAxBkoGnOkiCjR_s#wJ_v#b#}aN|aBogRyVucBiEw_C~r#_eB`Fc`NtP_bAshBorHa#}dCkOe~AmPmrGlPlrGjOd~A`#|dCrhBnrHuP~aAaFb`N_s#~dBhEv_CxVtcBkbBbeRo#l`NzJ`z#mRpr#qOpjCwBpnGoT~lAeEdkGsr#jtOtp#dQ~UjTtDfZf]jS",
"legs":[
{"summary":"","weight":4198.3,"duration":3426.4,"steps":[],"distance":49487},
{"summary":"","weight":7577.8,"duration":3501.3,"steps":[],"distance":49479.7}
],
"weight_name":"routability",
"weight":11776.1,
"duration":6927.700000000001,
"distance":98966.7}
]
}
I don't know if this is better now, but I had to work through it right now and can give you this example
curl "https://api.mapbox.com/directions-matrix/v1/mapbox/driving/9.51416,54.47004;13.5096410,50.0716190;6.8614070,48.5206360;14.1304840,51.0856060?sources=0&access_token={token}"`
This will return the following json for driving durations. I made use of the sources attribute, which is my search lng/lat and all other points are places in my database.
{
"code": "Ok",
"durations": [
[0.0, 29407.9, 34504.7, 24163.5]
],
"destinations": [{
"distance": 131.946157371,
"name": "",
"location": [9.514914, 54.468939]
}, {
"distance": 34.636975593,
"name": "",
"location": [13.509868, 50.071344]
}, {
"distance": 295.206928933,
"name": "",
"location": [6.863566, 48.52287]
}, {
"distance": 1186.975749670,
"name": "",
"location": [14.115694, 51.080408]
}],
"sources": [{
"distance": 131.946157371,
"name": "",
"location": [9.514914, 54.468939]
}]
}
Adding the annotations=distance parameter to the url will return the distances instead of the durations if you need that.
{
"code": "Ok",
"distances": [
[0.0, 738127.3, 902547.6, 616060.8] // distances in meters
],
"destinations": [{ // destinations including the source
"distance": 131.946157371, // result 0
"name": "",
"location": [9.514914, 54.468939]
}, {
"distance": 34.636975593, // result 1
"name": "",
"location": [13.509868, 50.071344]
}, {
"distance": 295.206928933, // result 2
"name": "",
"location": [6.863566, 48.52287]
}, {
"distance": 1186.975749670, // result 3
"name": "",
"location": [14.115694, 51.080408]
}],
"sources": [{ // source where we start from
"distance": 131.946157371,
"name": "",
"location": [9.514914, 54.468939]
}]
}
Technology Stack:
Tinkerpop Stack 2.4 (Rexster HTTP REST Server)
Titan 0.5.4
DynamoDB (AWS)
NodeJS
Goal:
I would like to utilize the Rexster RESTful based API for querying and traversals of my graph database. I am trying to understand the _properties query parameter for filtering results based on Vertex Query syntax.
Result of Vertices Query:
http://localhost:8182/graphs/mygraph/vertices
{
"version": "2.5.0",
"results": [
{
"name": "Frank Stein",
"_id": 25600768,
"_type": "vertex"
},
{
"name": "John Doe",
"_id": 25600512,
"_type": "vertex"
}
],
"totalSize": 2,
"queryTime": 219.86688
}
Result of Edge Query:
http://localhost:8182/graphs/mygraph/vertices
{
"version": "2.5.0",
"results": [
{
"_id": "f8q68-f8phc-4is5-f8pog",
"_type": "edge",
"_outV": 25600512,
"_inV": 25600768,
"_label": "friends"
}
],
"totalSize": 1,
"queryTime": 164.384768
}
Problem:
These URI's do not return what I am assuming I would get returned, always return an empty set.:
Requests:
_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,"John Doe"]]
_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,John Doe]]
_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,(s,"John Doe")]]
_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,(s,John Doe)]]
Response:
{
"version": "2.5.0",
"results": [],
"totalSize": 0,
"queryTime": 22.641152
}
Additional Information:
The following URI does return a resulting set of adjacent vertices if I just switch the = (equal operator) to the <> (not equal) operator:
Request:
_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,<>,"John Doe"]]
Response:
{
"version": "2.5.0",
"results": [
{
"name": "John Doe",
"_id": 25600512,
"_type": "vertex"
}
],
"totalSize": 1,
"queryTime": 17.451008
}
Anyone have any clue where I may be going wrong?
References:
https://github.com/tinkerpop/rexster/wiki/Basic-REST-API
https://github.com/tinkerpop/rexster/wiki/Property-Data-Types (Shows NO EXAMPLES of string use for data type Vertex Queries.)
https://github.com/tinkerpop/blueprints/wiki/Vertex-Query
Thanks Friends!
Tom
In the link you provided, note this section explicitly:
https://github.com/tinkerpop/blueprints/wiki/Vertex-Query#query-use-cases
Note that all the use cases involved "edges". You are trying to do a vertex query over property values on the adjacent vertex of an edge. If you want your query to work that way, you would have to denormalize your data to include the "name" property on the edges.
Note that in my curl request against the default graph below, things work as expected when I build my vertex query against "weight" (and edge property):
$ curl -g "http://localhost:8182/graphs/tinkergraph/vertices/1/out?_properties=[[weight,=,(f,0.4)]]"
{"version":"2.5.0","results":[{"name":"lop","lang":"java","_id":"3","_type":"vertex"}],"totalSize":1,"queryTime":1.070072}
I'd like to know whether there is a way to directly get the latitude/longitude fields via the Facebook Graph API.
The background is that I want to reduce the amount of data which is returned by the Graph API by getting rid of fields which are not of interest for my application.
I know there's something like this working in the Graph API Explorer:
me/?fields=id,checkins.fields(id,place.fields(id,location),created_time)
It returns the following:
{
"id": "12345",
"checkins": {
"data": [
{
"id": "101511234546244",
"place": {
"id": "170048419682121",
"location": {
"street": "",
"city": "Frankfurt",
"state": "",
"country": "Germany",
"zip": "",
"latitude": 50.108641831527,
"longitude": 8.6654729704433
}
},
"created_time": "2012-11-08T08:30:48+0000"
}
]
}
As I don't need the address parts of the location, I'd really like to get rid of them as well. If I try this the follwoing way, it doesn't work:
me?fields=id,checkins.fields(id,place.fields(id,location.fields(latitude,longitude)),created_time)
The result is
{
"id": "12345",
"checkins": {
"data": [
{
"id": "101511234546244",
"place": null,
"created_time": "2012-11-08T08:30:48+0000"
}
]
}
Did somebody have success in doing something similar? If so, I'd be great if you could let me know. Thanks!
According to the API documentation and the Graph API explorer, Subfields are not supported by location so you are unable to extract just latitude and longitude from the location object.