OSRM Table API not returning distance - osrm

I am trying to get the distance matrix for my desired locations. As mentioned in the OSRM-Table Service docs, I have tried modifying the same as http://router.project-osrm.org/table/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219&annotations=distance.
Response is showing error as:
{
"message": "Coordinate is invalid: 13.397634,52.529407&annotations=distance,duration",
"code": "InvalidInput"
}
but, when I run it without annotations, then I am able to get the proper response.
{
"durations": [
[
0,
723.9,
711
],
[
419.8,
0,
541.6
],
[
565,
416,
0
]
],
"destinations": [
{
"hint": "g5HFiBCSxYgiAAAA6gIAAAAAAAAAAAAASjFaQU1xpUEAAAAAAAAAACIAAADqAgAAAAAAAAAAAADppQAA_kvMAKlYIQM8TMwArVghAwAA7wqVP7a9",
"distance": 4.231665624816857,
"name": "Friedrichstraße",
"location": [
13.388798,
52.517033
]
},
{
"hint": "0BgegNQVzIgMAAAADAAAAAAAAAACAQAAW7-PQOKcyEAAAAAApq6DQgwAAAAMAAAAAAAAAIoAAADppQAAf27MABiJIQOCbswA_4ghAwAAXwWVP7a9",
"distance": 2.7893928415656375,
"name": "Torstraße",
"location": [
13.397631,
52.529432
]
},
{
"hint": "xRcegP___38kAAAAyAAAAC0AAABKAAAAsowKQkpQX0Lx6yZCvsQGQiQAAABkAAAALQAAACUAAADppQAASufMAOdwIQNL58wA03AhAwMAvxCVP7a9",
"distance": 2.2265954222656257,
"name": "Platz der Vereinten Nationen",
"location": [
13.428554,
52.523239
]
}
],
"sources": [
{
"hint": "g5HFiBCSxYgiAAAA6gIAAAAAAAAAAAAASjFaQU1xpUEAAAAAAAAAACIAAADqAgAAAAAAAAAAAADppQAA_kvMAKlYIQM8TMwArVghAwAA7wqVP7a9",
"distance": 4.231665624816857,
"name": "Friedrichstraße",
"location": [
13.388798,
52.517033
]
},
{
"hint": "0BgegNQVzIgMAAAADAAAAAAAAAACAQAAW7-PQOKcyEAAAAAApq6DQgwAAAAMAAAAAAAAAIoAAADppQAAf27MABiJIQOCbswA_4ghAwAAXwWVP7a9",
"distance": 2.7893928415656375,
"name": "Torstraße",
"location": [
13.397631,
52.529432
]
},
{
"hint": "xRcegP___38kAAAAyAAAAC0AAABKAAAAsowKQkpQX0Lx6yZCvsQGQiQAAABkAAAALQAAACUAAADppQAASufMAOdwIQNL58wA03AhAwMAvxCVP7a9",
"distance": 2.2265954222656257,
"name": "Platz der Vereinten Nationen",
"location": [
13.428554,
52.523239
]
}
],
"code": "Ok"
}
The problem here is I don't have distance matrix in it. Can anyone please suggest the cause or how to solve it?

It seems there is currently a problem with the osrm demo service. Check the issues below:
OSRM Github issue #5541
OSRM Github issue #5517

Related

How to take the most newest part of all reports and merge into one main report?

EDIT: I have found out that mongo does not allow to use special characters such as dots and the dollar sign as a key in the report so I had to rechange the structure of the JSON a bit. But, my question remains the same (I removed the old stuff so it will be more readable but you can still see it in the edit history section). The new structure looks as follows:
{
"name": "test1",
"main": [
{
"subs": [
{
"data": [
{
"group": "ABC",
"values": [
"tcsh"
]
},
{
"group": "AA",
"values": [
"6.13.00"
]
}
]
},
{
"data": [
{
"group": "xyz",
"values": [
"tcsh"
]
},
{
"group": "SADA",
"values": [
"6.13.00"
]
}
]
}
],
"main_name": "MAIN",
"main_path": "play_ground/MAIN"
},
{
"subs": [
{
"data": [
{
"group": "BAB",
"values": [
"tcsh"
]
},
{
"group": "GO",
"values": [
"6.13.00"
]
}
]
}
],
"main_name": "MAIN2",
"main_path": "play_ground/MAIN2"
}
],
"user": "easdasa",
"timestamp": "1564437533"
}
I want to get all reports that have a name test1 and a user easdasa. Then, I would like to take the latest block of data of each block of subs. This is done with the help of the timestamp.
For example in the following array I have two reports:
[{
"name": "test1",
"main": [
{
"subs": [
{
"data": [
{
"group": "xyz",
"values": [
"tcsh"
]
},
{
"group": "SADA",
"values": [
"6.13.00"
]
}
]
}
],
"main_name": "MAIN",
"main_path": "play_ground/MAIN"
}
],
"timestamp": "1564437533"
},
{
"name": "test1",
"main": [
{
"subs": [
{
"data": [
{
"group": "ABC",
"values": [
"tcsh"
]
},
{
"group": "AA",
"values": [
"6.13.00"
]
}
]
},
{
"data": [
{
"group": "xyz",
"values": [
"tcsh"
]
},
{
"group": "SADA",
"values": [
"5.0.1",
"12312"
]
}
]
}
],
"main_name": "MAIN",
"main_path": "play_ground/MAIN"
}
],
"timestamp": "1564437522"
}]
The first report is was created after the second report (due to the timestamp). I can see that there is a block that located in the second report but not in the first report:
{
"data": [
{
"group": "ABC",
"values": [
"tcsh"
]
},
{
"group": "AA",
"values": [
"6.13.00"
]
}
]
},
So I want the final report to heve it (besides all the blocks from the first report). Also, you can see that the values of the SADA group are diffrenet. So we want to take the first's report block. The final report should be:
{
"name": "test1",
"main": [
{
"subs": [
{
"data": [
{
"group": "ABC",
"values": [
"tcsh"
]
},
{
"group": "AA",
"values": [
"6.13.00"
]
}
]
},
{
"data": [
{
"group": "xyz",
"values": [
"tcsh"
]
},
{
"group": "SADA",
"values": [
"6.13.00"
]
}
]
}
],
"main_name": "MAIN",
"main_path": "play_ground/MAIN"
}
],
"timestamp": "1564437533"
}
In other words, in the (json) values of the data level I want to get the latest report and in the (json) values of the subs level I want to get all existing subs. So it will be more clear, in the (json) values of the data level I want to get all the groups and values of the latest report and for the (json) values of the subs level I want to have all the subs.
If I could specify steps:
Get all reports by user and name.
Theoritcly merge all report into one main report (the implmenetation could be diffrent). The merge will use be done by main_name.
Remove all old subs values by timestamp that already exists in the latest report so the final report will have in the subs level only the newest objects and object from the old reports that were not in the newer reports.
Which query I should be in order to get the wanted report?
Please use the below query and check on stats, I can really say performance can be improved by having proper indexing as per your requirements(querying), Please use $explain (enter link description here)
to check on query performance. I've considered your array exists in a field with key as values , Please let me know if this works or if it doesn't provide sample data, we can check on that:
db.getCollection('yourcollection').aggregate([{$unwind: '$values'},{$match : {'values.name': 'test1', 'values.user': 'galih'}},
{$sort: {'values.timestamp' : -1}},
{$limit: 1}
])

Elasticsearch indexing of Twitter bounding box not recognized as a geo_shape

I'm trying to create an Elasticsearch mapping for Twitter's Place geo bounding_box array and I can't get Elasticsearch to index it as a geo bounding box. In my app, I will be getting the raw JSON from Twitter4j, however the bounding box does not close the bounding box, so for the purpose of this test, I edited the json and closed it. I'm using Elastic cloud (ES v5) and the Rest API and then visualizing with Kibana.
Here is the mapping I'm trying to use. I've tried several variations with and without a "properties" block and it doesn't work. With this mapping, I am successfully able to PUT the mapping, but when I POST the document, Kibana recognizes the array as an unknown field type.
The Point coordinates field is indexed as a geopoint just fine, it's the bounding box that does not.
Here is my mapping:
PUT /testgeo
{
"mappings": {
"tweet": {
"_all": {
"enabled": false
},
"properties": {
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z YYYY||strict_date_optional_time||epoch_millis"
},
"coordinates": {
"properties": {
"coordinates": {
"type": "geo_point",
"ignore_malformed": true
}
}
},
"place": {
"properties": {
"bounding_box": {
"type": "geo_shape",
"tree": "quadtree",
"precision": "1m"
}
}
}
}
}
}
}
Here is the snippet of the document I am trying to POST (NOTE: I manually added the 5th array element to close the bounding box).
POST /testgeo/tweet/1
{
...
"coordinates": {
"type": "point",
"coordinates": [
0.78055556,
51.97222222
]
},
"place": {
"id": "0c31a1a5b970086e",
"url": "https:\/\/api.twitter.com\/1.1\/geo\/id\/0c31a1a5b970086e.json",
"place_type": "city",
"name": "Bures",
"full_name": "Bures, England",
"country_code": "GB",
"country": "United Kingdom",
"bounding_box": {
"type": "polygon",
"coordinates": [
[
[
0.773779,
51.96971
],
[
0.773779,
51.976437
],
[
0.781794,
51.976437
],
[
0.781794,
51.96971
],
[
0.773779,
51.96971
]
]
]
},
"attributes": {
}
},
If anyone can identify the reason for this and correct it, I would be most appreciative.
NOTE 1:: I tried using the mapping and document examples from Elastic's geo_shape documentation page and Kibana again showed the location field as unknown type.
PUT /testgeo
{
"mappings": {
"tweet": {
"_all": {
"enabled": false
},
"properties": {
"location": {
"type": "geo_shape",
"tree": "quadtree",
"precision": "1m"
}
}
}
}
}
POST /testgeo/tweet/1
{
"location" : {
"type" : "polygon",
"coordinates" : [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
}
Turns out that Kibana simply does reflect the type for GeoShape's. When doing a geo query, however, Elasticsearch returns correct results.
For example:
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_shape": {
"place.bounding_box": {
"shape": {
"type": "polygon",
"coordinates": [
[
[
0.773779,
51.96971
],
[
0.773779,
51.976437
],
[
0.781794,
51.976437
],
[
0.781794,
51.96971
],
[
0.773779,
51.96971
]
]
]
},
"relation": "within"
}
}
}
}
}
}
Even though you seem to have found a solution to your problem I just wanted to say there is a fix now for this issue by using the coerce option in the mapping for geo_shape like so:
"properties": {
"bounding_box": {
"type": "geo_shape",
"tree": "quadtree",
"precision": "1m",
"coerce": true
}
}
Also see:
https://github.com/elastic/elasticsearch/pull/11161

POST : get_responses API not giving required data

Ideally the call to this API - https://api.surveymonkey.net/v2/surveys/get_responses
should give a json response like this :
{
"data": [
{
"questions": [
{
"answers": [
{
"col": "3024965133",
"row": "3024965139"
},
{
"col": "3024965134",
"row": "3024965140"
},
{
"col": "3024965135",
"row": "3024965141"
},
{
"row": "0",
"text": "Other!"
}
],
"question_id": "316084770"
},
{
"answers": [
{
"col": "3024965125",
"row": "3024965122"
},
{
"col": "3024965124",
"row": "3024965123"
}
],
"question_id": "316084761"
},
{
"answers": [
{
"row": "3024959616"
}
],
"question_id": "316083321"
},
{
"answers": [
{
"row": "0",
"text": "This is an open answer"
}
],
"question_id": "316083320"
},
{
"answers": [
{
"col": "3024962639",
"row": "3024962638"
},
{
"col": "3024962640",
"row": "3024962637"
},
{
"col": "3024962639",
"row": "3024962636"
}
],
"question_id": "316084090"
},
{
"answers": [
{
"row": "3024964761",
"text": "9"
},
{
"row": "3024964762",
"text": "1"
}
],
"question_id": "316084724"
}
],
"respondent_id": "2500019027"
}
],
"status": 0
}
But when I am requesting the API for responses to my survey by specific respondents, I am getting a blank array.
Note : I am able to see the proper responses via SurveyMonkey UI console.
If you use API v3, you may get a better error message:
https://developer.surveymonkey.com/api/v3/#surveys-id-responses
It seems your issue could be that you have more than 100 responses for that survey and you can only access the first 100 on a basic plan from what I see from the logs.
If that's the case the solution would be to
Upgrade your plan
Delete some old responses
Duplicate the survey maybe?
Again I would recommend moving to V3 of the API for a better experience.

MongoDB geointersect fail to find big polygons

I'm using mongo to store some geolocalized data, with the goal of retriving them using $geointersect. Specifically I have this document stored in my db:
{
"loc": {
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-179.875,
-89.875
],
[
179.875,
-89.875
],
[
179.875,
89.875
],
[
-179.875,
89.875
],
[
-179.875,
-89.875
]
]
]
},
"crs": {
"type": "name",
"properties": {
"name": "urn:x-mongodb:crs:strictwinding:EPSG:4326"
}
},
"type": "Feature",
"properties": {}
},
"_id": "576af8e31d41c87fa1f1d04f"
}
Which as you may notice covers almost the entire World. Now it doesn't matter what coordinates I input for my $geointersect query, it will never be returned... Does anyone know why?
An example of the query I'm using could be:
[
{
"loc.geometry": {
"$geoIntersects": {
"$geometry": {
"type": "Polygon",
"coordinates": [
[
[
13.4307861328125,
41.599013054830216
],
[
13.9801025390625,
41.599013054830216
],
[
13.9801025390625,
41.80407814427234
],
[
13.4307861328125,
41.80407814427234
],
[
13.4307861328125,
41.599013054830216
]
]
]
}
}
}
},
{
"loc": 1
}
]
Of course the coordinates of the query are contained inside the polygon in the saved document (I mean... it's as big as the the world, duh!) but for some reason it doesn't find any match... I'm kinda lost.
Just looking into this now. If the polygon is solid and bigger than an earth's hemisphere, mongo returns everything outside of the area. check out their big poly and crs in the geoWithin documentation

MongoDB: "Malformed geo query" with $geoIntersect on a polygon

I have events in a collection, each containing a desired location, set a GeoJSON Polygon.
I also have service providers in another collection, also with a GeoJSON Polygon, indicating the area where they can deliver.
For a given service provider, I'm trying to list all the events that are in a compatible area.
However, I get this error:
Malformed geo query: { $geoIntersects: { $geometry: { type: "Polygon", coordinates: [ [ [ -31.59327575763251, 115.8574693000001 ], [ -31.59676306691357, 115.9162469300458 ], [ -31.60715789289806, 115.9738935747774 ], ...
My Polygons are closed (first and last coords are identical), so that's not coming from there.
Here are the events:
Events:
[
{
"_id": "5237d4bd9899e67c0e000004",
"area": "area",
"authtoken": "e3bf38ff9a1f132a7cc86ea045cf3951",
"budget": 1800,
"creation_date": {
"sec": 1379390653,
"usec": 0
},
"description": "Banana banana banana banana banana banana banana banana bananaaaaaaaaaaaaaaaaa!!!",
"ends": {
"sec": 1383343200,
"usec": 0
},
"geo": {
"type": "Polygon",
"coordinates": [
[
[
-33.740154878816,
150.9241267
],
[
-33.741901642057,
150.95422987078
],
[
-33.747108144055,
150.98375074498
],
[
-33.755673663135,
151.01211808166
],
[
-33.767432456928,
151.03878255704
],
[
-33.782156913661,
151.0632272399
],
[
-33.799561885809,
151.08497749366
],
[
-33.819310129033,
151.10361012448
],
[
-33.841018749004,
151.11876160464
],
[
-33.819310129033,
150.74464327552
],
[
-33.799561885809,
150.76327590634
],
[
-33.782156913661,
150.7850261601
],
[
-33.767432456928,
150.80947084296
],
[
-33.755673663135,
150.83613531834
],
[
-33.747108144055,
150.86450265502
],
[
-33.741901642057,
150.89402352922
],
[
-33.740154878816,
150.9241267
]
]
]
},
"guests": 180,
"loc": {
"city": "Liverpool",
"state": "NSW",
"country": "AU",
"lat": -33.9200192,
"lng": 150.9241267,
"timezone": "Australia\/Sydney"
},
"name": "Bananaaaaaaaa!",
"services": [
{
"creation_date": {
"sec": 1379390661,
"usec": 0
},
"data": {
"name": "Bananaaaaaaaaaaa!!!!!",
"request": "Banana!",
"description": " banana banana banana banana banana banana banana banana banana",
"budget": "1400"
},
"event": "aaca6751-75b2-4cd9-a76a-99d4ee56fb6a",
"service": "a9fe4bd0-d4f2-4f2c-8b81-4899ac19c44f",
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "15ceedd5-608b-48e4-8a05-b60ee4c4c5bb",
"type": "Food & Drinks"
}
],
"starts": {
"sec": 1383300000,
"usec": 0
},
"type": {
"_id": "521666701e6accf7afc1a0e3",
"icon": "uploads\/event-types\/icon-3891a6f4-760f-43f2-ab3a-a51c61fd8d0d.png?rnd=0.6323562911552134",
"name": "Meeting",
"uuid": "3891a6f4-760f-43f2-ab3a-a51c61fd8d0d"
},
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "aaca6751-75b2-4cd9-a76a-99d4ee56fb6a",
"within": {
"km": 20,
"addr": "liverpool, nsw"
}
},
{
"_id": "5237d50a9899e67c0e000005",
"area": "area",
"authtoken": "e3bf38ff9a1f132a7cc86ea045cf3951",
"budget": 1800,
"creation_date": {
"sec": 1379390730,
"usec": 0
},
"description": "Boo!!!",
"ends": {
"sec": 1383285600,
"usec": 0
},
"geo": {
"type": "Polygon",
"coordinates": [
[
[
-32.086853059112,
116.0081156
],
[
-32.088163946126,
116.03027505189
],
[
-32.092071203806,
116.05200507521
],
[
-32.098499107954,
116.07288445521
],
[
-32.1073230624,
116.09250825588
],
[
-32.118371984525,
116.11049558927
],
[
-32.131431584032,
116.12649694645
],
[
-32.146248475035,
116.14020095399
],
[
-32.330851613336,
116.10195418015
],
[
-32.289125251893,
115.86992020233
],
[
-32.2721989398,
115.86018847275
],
[
-32.254291845681,
115.85334073219
],
[
-32.235752983166,
115.84950870874
],
[
-32.098499107954,
115.94334674479
],
[
-32.092071203806,
115.96422612479
],
[
-32.088163946126,
115.98595614811
],
[
-32.086853059112,
116.0081156
]
]
]
},
"guests": 700,
"loc": {
"city": "Byford",
"state": "WA",
"country": "AU",
"zipcode": "6122",
"lat": -32.2217513,
"lng": 116.0081156,
"timezone": "Australia\/Perth"
},
"name": "Halloween",
"services": [
{
"creation_date": {
"sec": 1379390749,
"usec": 0
},
"data": {
"name": "Badass lighting",
"description": "Boom! I want that!",
"type": [
"Furniture",
"Lighting\/lasers",
"LED screens",
"Dancefloor"
],
"budget": "800"
},
"event": "a6c28e98-b647-4224-8bff-f0b7e5c453c3",
"service": "4d4f370e-5780-4794-b988-df9d7a9ed644",
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "217c4896-a986-4c0a-a6c7-46c9aa74cf27",
"type": "Equipment Hire"
}
],
"starts": {
"sec": 1383256800,
"usec": 0
},
"type": {
"_id": "521666701e6accf7afc1a0e3",
"icon": "uploads\/event-types\/icon-3891a6f4-760f-43f2-ab3a-a51c61fd8d0d.png?rnd=0.6323562911552134",
"name": "Meeting",
"uuid": "3891a6f4-760f-43f2-ab3a-a51c61fd8d0d"
},
"uid": "0d92f274-67a3-4d2f-b1c8-d771fd84c113",
"uuid": "a6c28e98-b647-4224-8bff-f0b7e5c453c3",
"within": {
"km": 15,
"addr": "byford"
}
}
]
And here is my query object:
db.events.find({
"geo": {
"$geoIntersects": {
"$geometry": {
"type": "Polygon",
"coordinates": [
[
[
-31.593275757633,
115.8574693
],
[
-31.596763066914,
115.91624693005
],
[
-32.087153956437,
116.25114123685
],
[
-32.13233852915,
116.22535569049
],
[
-32.174036124673,
116.19236795072
],
[
-32.304841443191,
115.76898154226
],
[
-32.290955790481,
115.7119268346
],
[
-31.841206471153,
115.45474133646
],
[
-31.794742552646,
115.4770638401
],
[
-31.751364552714,
115.50675244396
],
[
-31.711911850434,
115.5432228167
],
[
-31.677146863424,
115.58576206658
],
[
-31.607157892898,
115.74104502522
],
[
-31.596763066914,
115.79869166995
],
[
-31.593275757633,
115.8574693
]
]
]
}
}
}
})
What am I missing?
My query seems to be identical to the official mongodb doc for geo queries.
Thanks in advance!
Your coordinates are specified as [latitude, longitude]. MongoDB requires that you specify coordinates in the opposite order for 2dsphere geometry: [longitude, latitude].
Your query worked for me once I swapped the coordinate order.