-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add opensensemap layer #142
Conversation
A new layer has been added that gets data from opensensemap.org. fixes publiclab#58
|
||
(function () { | ||
var $ = window.jQuery; | ||
var url = "https://api.opensensemap.org/boxes"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! This looks great, just a small question --
Are we requesting only one region's worth of data at a time, and how are we submitting the lat/lon coordinates? Thanks!!
Also, this PR would make a great example for #136 -- thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jywarren . I implemented the layer in this manner owing to the api of opensensemap. The current implementation has used two endpoints of the api :-
/boxes
- Gets data of all the boxes./boxes/:boxId
- Gets data of a particular box.
Looking at the previously implemented layers, hitting the /boxes
endpoint seemed sufficient to create the markers and their popups, but the problem was that it didn't return the values recorded by the sensors. So /boxes/:boxId
had to be hit to get the values.
So whenever an user opens the Opensense layer
, the /boxes
endpoint is first hit which provides the coordinates and the boxID, using which the markers are created. Whenever a marker is clicked, the popup is populated at that point only by making a get request to boxes/:boxId
that returns the values recorded by the sensors for that particular region. That is why we can see a loading text before the data is loaded.
Please let me know if it requires changes. Thanks :)
Thanks for the explanation -- sorry, just another question -- what defines
a box, and how do we generate a box id? Does it map to a lat/lon coordinate
region?
…On Mon, Mar 11, 2019 at 5:45 PM Ramakrishna Pattnaik < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/openSenseLayer.js
<#142 (comment)>
:
> + }
+ }
+ if (data.lastMeasurementAt) {
+ popUpContent += "<br><small>Measured at <i>" + data.lastMeasurementAt + "</i>";
+ }
+ popup.setContent(popUpContent)
+ });
+ }
+ },
+
+ requestRegionData: function () {
+ var self = this;
+
+ (function () {
+ var $ = window.jQuery;
+ var url = "https://api.opensensemap.org/boxes";
Thank you @jywarren <https://github.com/jywarren> . I implemented the
layer in this manner owing to the api of opensensemap
<https://api.opensensemap.org/>. The current implementation has used two
endpoints of the api :-
- /boxes - Gets data of all the boxes.
- /boxes/:boxId - Gets data of a particular box.
Looking at the previously implemented layers, hitting the /boxes endpoint
seemed sufficient to create the markers and their popups, but the problem
was that it didn't return the values recorded by the sensors. So
/boxes/:boxId had to be hit to get the values.
So whenever an user opens the Opensense layer, the /boxes endpoint is
first hit which provides the coordinates and the boxID, using which the
markers are created. Whenever a marker is clicked, the popup is populated
at that point only by making a get request to boxes/:boxId that returns
the values recorded by the sensors for that particular region. That is why
we can see a loading text before the data is loaded.
Please let me know if it requires changes. Thanks :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#142 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ2SjBsIYGSIgIKg92wBCKzJcFJiHks5vVs49gaJpZM4bpUx2>
.
|
@jywarren a
I hope this answers all the queries. Please let me know if anything is still unclear. Thanks :). |
OK, thanks! Does the code request all boxes, or are we restricting to only request boxes for the currently viewed region (and if so, could you point me at that section of code?) Thank you! |
@jywarren The code requests all the boxes when we select the layer. It had to be done cause there is no API endpoint that can fetch the boxes region-wise. |
Great, thank you so much!!!! 👍 We'd love some help with some of the organizational issues in #134 if you're interested! |
@jywarren thank you :). I will be working on it soon. |
A new layer has been added that gets data from opensensemap.org.
fixes #58