Open sagarpreet-chadha opened 6 years ago
Hi @jywarren ...do we have an API to get questions with tag = map ? or leaflet ? or layer ? and have lat/lon tags ?
I think so - @stefannibrasil may know more about this!
On Thu, Jul 12, 2018 at 1:54 PM Sagarpreet Chadha notifications@github.com wrote:
Hi @jywarren https://github.com/jywarren ...do we have an API to get questions with tag = map ? or leaflet ? or layer ? and have lat/lon tags ?
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-environmental-layers/issues/30#issuecomment-404596305, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJz9ltqGnUh5lHlkYZ9Sf8ysCu3j7ks5uF405gaJpZM4VKhq6 .
Hi, everyone!
yeah, can you try using this?
https://publiclab.org/api/srch/taglocations?srchString=lat,lon&tagName=tag
This page may be a good example of how to add such a layer: https://github.com/publiclab/leaflet-environmental-layers/blob/master/src/mapKnitterLayer.js
In addition to this guide: https://github.com/publiclab/leaflet-environmental-layers/issues/50
Hmm, this may not be right anymore - i think it was changed to:
https://publiclab.org/api/srch/taglocations?query=lat,lon&tagName=tag
However, we want to show all tagged with question:*
-- is this possible, @stefannibrasil ? or is there another relatively easy way to get only questions?
Thank you!
This was added to the GCI dashboard!
Hi, I am a GCI participant.
I have been trying to solve this issue, but I have been having a hard time accessing the api.
I haven't touched the mapping part yet... I am just trying to query the information from the API. But I can not seem to have it return any questions. When I search:
https://publiclab.org/api/srch/taglocations?query=18.00,-66.00
(this is directly from the documentation)
Nothing shows up, even if I change the numbers.
I have tried using https://publiclab.org/api/srch/all?query=[question title]
and I am not even able to find the question I was looking for.
Maybe the API has to be set up first so that it includes information needed to create this map? (I could be very wrong and just don't know how to use the API).
Could anybody help? @jywarren or @sagarpreet-chadha do you have any suggestions?
Hmm, we may have just changed this according to https://github.com/publiclab/plots2/pull/3700 -- let's see!
Hmm, i'm also not seeing anything for https://publiclab.org/api/srch/taglocations?query=42.00,-71.00&tag=balloon-mapping ... looking...
@milaaraujo do you know why this might not be returning results? Thank you!
This test is supposed to demonstrate this API call functioning:
I tried doing a test of the API myself (queried the API with the same command as used in the test file) and I am not getting any result despite the test saying that it is supposed to give a result.
This is the command I ran: https://publiclab.org/api/srch/taglocations?query=71.00,52.00
(gave no results)
This are the inputs used in the test query: /api/srch/taglocations?query=71.00,52.00
(should give at least 1 result)
Am I doing something wrong? How can I fix this?
@jywarren - Thanks for all the help. I really appreciate it!
@nonas-hunter, the test is using data from plots2/test/fixtures/
, so by calling https://publiclab.org/api/srch/taglocations?query=71.00,52.00
, you will not retrieve the same example.
@jywarren, I think the problem here is the range of the search... For example, I have this question here with 'lat:1.010689' and 'lon:9.997558'. I can retrieve this question by calling:
But it does not work with: 'https://publiclab.org/api/srch/taglocations?query=1.0,8.9'
The "problem" is probably here:
items = Node.includes(:tag)
.references(:node, :term_data)
where('node.nid IN (?) AND term_data.name LIKE ?', nids, 'lon:' + lon[0..lon.length - 2] + '%')
.order('node.nid DESC')
.limit(limit)
This part of the code is a legacy from the first version of the API. Stefannni and I didn't work on this query that is why I'm not really sure about it!
And it is not possible to search with the wildcard, for example: "tag=question:*".
I guess we should make a new API to get :
@sagarpreet-chadha, do you mean a new endpoint in the search API? Or a new API?
Perhaps we could modify this one in stages. If 4 coordinates are offered, it could do bounding box, instead of "nearby".
If no coordinates are offered, it could just show all questions (sorted/filtered by time, say).
What do you think?
On Thu, Nov 15, 2018 at 1:52 PM Camila AraΓΊjo notifications@github.com wrote:
@sagarpreet-chadha https://github.com/sagarpreet-chadha, do you mean a new endpoint in the search API? Or a new API?
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/leaflet-environmental-layers/issues/30#issuecomment-439149892, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ0tlxoVyb07hqc1_DjuX6SuZz8BYks5uvbfUgaJpZM4VKhq6 .
Hmm, ok, so this page used to show results using this API call:
https://publiclab.org/wiki/inline-maps
It uses: $.getJSON("/api/srch/taglocations?query="+s , function(data){
The call is getting an error, and is: https://publiclab.org/api/srch/taglocations?query=43,-71
As @milaaraujo pointed out, this does work: https://publiclab.org/api/srch/taglocations?query=1.9,9.9
Ah! So the fix I'd added that pads zeroes doesn't work - they get stripped back out because it's not a string. This works: https://publiclab.org/api/srch/taglocations?query=43.0,-71.0
It also works with a tag: https://publiclab.org/api/srch/taglocations?query=29.9,-90.0&tag=mapknitter
I'll fix the padding issue: https://github.com/publiclab/plots2/blob/52ca105d7e89d7640a95110b2c947990bbc5618b/app/views/map/_leaflet.html.erb#L34
What's left is what @milaaraujo and @sagarpreet-chadha pointed out, 2 parts:
question:*
via the APIOther follow-ups we ought to look into:
This is a lot, but broken into small parts! How does it sound?
Thanks everyone for untangling this complex web! πΈ π
@milaaraujo pointed out some... creative coding (i can probably take credit π ) -- the existing code just truncates the last two digits, and matches any node that has those same initial digits. So it can fail easily if you're looking "near" 10.00
but the point you're looking for is at 9.99
, even though they're very close! Because 10.
and 9.
don't match.
However, since we don't actually store the lat/lon in full decimal form, but only as strings, we have to get creative. We could potentially manually detect if we need to expand the search criteria, but that sounds messy. Alternatively we could start storing latitudes and longitudes in tag records, as decimals... @sagarpreet-chadha @milaaraujo what do you think?
@jywarren, I think storing latitudes and longitudes as decimals would be a great improvement! With numbers would be much more easy to control the range of the search.
But first we should work on the points you listed:
1- get the API query in this code to accept a wildcard, like in this code so we can query question:* via the API 2- potentially allow setting the bounding box of that API call by two coordinate pairs instead of the more ambiguous "nearby"
Awesome π π !
OK, @sagarpreet-chadha would you be able to open issues for these two? They could potentially be GCI issues as we have a number of GCI folks who are ready for bigger projects!
@liz wants to know whether we can show the questions asked on publiclab.org on map .