I want to let my user input a range of degrees in a nice UI. i.e. something like 45-135 (which, in my app, actually means NE-SE wind direction...). Found jQuery Knob, but not sure how to use it to allow the value to be a range.
Any idea?
You could put a min and max values of 0 and 360.
Like this:
$(".dial").knob({min':0,'max':360});
You could even use some steps to limit possible values to some thing corresponding to N-NE-E-SE-S-SO-O-NO
I hope this helps, sorry if not.
Related
I've been using Mathemathica in order to collect wind speed data in a certain location. Mathematica gives me a TimeSeries from which I would like to know what is the maximum value and the minimum one. I've used "FindPeaks" function, but as it is not a regularly sampled time series the function does not work. Is there a way to get the maximum value?
The following is the data:
data = WindSpeedData[{19.416258, -99.719266}, {DateObject[{2016, 1,
1}], DateObject[{2017, 1, 2}]}]
This
Normal[data]
will undo part of the layer of Timeseries that your actual wind speeds are wrapped up inside of.
In that you can see that what you probably want is part of the second item in each list, that appears to be the actual speed. So
Max[Map[#[[2, 1]] &, Normal[data]]]
will look at the beginning of the second part, which is your speed, and then try to find the maximum value.
For your example data that shows Max[29.0802, "NotAvailable"] and that 29.0802 is the maximum wind speed.
That trailing "NotAvailable" is still some part of their wrapping the actual data up inside layers. It is possible that there is one missing wind speed in there and Max doesn't know what to make of that.
Thanks #Bill,I used
Max[data]
It threw me ["Not available", 46.8 km/h]
I just used your code and gave me the same result but in different order [46.8 km/h, "Not available"]. I double checked the datum (46.8) by displaying the data in a grid. Thank you very much, I will use the normal function further on.
I receive coordinate of a vehicle and I need to find out the speed limit of that road at which this vehicle is at?. I know you can find maxspeed for a certain bounded box like this
www.overpass-api.de/api/xapi?[maxspeed=][bbox=5.6283473,50.5348043,5.6285261,50.534884]
but that is if this bounded box area has ONLY one speed limit. So say suppose there was an area which had two speed limit within the bounded box?
My second concern is how should i make the bounded box since I am just getting one co-ordinate at a time?
Please don't ask more than a single question at once.
Your first question is not clear to me. The query will return all speed limits in the given bounding box, not just the first one.
Regarding your second question: You should use the around query instead of a bounding box. With around you can retrieve all elements within a certain radius around a given coordinate. Example query:
<query type="way">
<around lat="5.6283473" lon="50.5348043" radius="25"/>
<has-kv k="highway" v=""/>
<has-kv k="maxspeed" v=""/>
</query>
<print/>
Also see the language guide as well as overpass turbo for testing your queries.
How can i do something like this? (Ofc, use highcharts)
http://img59.imageshack.us/img59/3439/temp1a.png
I have 2 (may be better use 3) axis with data and some scale that calculates the efficiency of the some parameters.
Your best bet is to play around with the gauge type.
You can probably get a good deal of info on how to proceed from the VU meter example:
http://highcharts.com/demo/gauge-vu-meter
I'd like to calculate the closest country (as viewed on a world map) in a given direction (provided in degrees) from a user's current location.
I realize one way of doing this is to use the formula provided here to step in, for example, 5-mile increments from point to point until I finally reach a country that is not the user's starting country. However, that seems horribly inefficient with regard to use of geocoding resources.
Do any of you know of a better algorithm I could use for this?
Thanks in advance.
One way to reduce the amount of reverse geocoding operations is to treat this problem as a search for the border. If you use a binary search algorithm, and reverse geocode each point, you find where the country changes from your current country to the adjacent country with a minimum number of reverse geocode operations.
In the binary search, your heading is constant, and you have a minimum range (5 miles) and a maximum range (12,000 miles), you are searching for the range at which the border lies. Then you reverse geocode a position just beyond the border to find out what country is there. One problem is that just beyond the border might be ocean.
I would use MKReverseGeocoding. Check this SO question for code examples.
I would like to use acts_as_list in an app that was originally written in php and is being moved to rails. We used a 'position' value that was a float such that if a user wanted to put something between position 1 and 2, they would just enter 1.5 in the form. It looks like acts_as_list just uses integers. Is there a way in acts_as_list to make it use floats rather than integers? Or possibly convert a set of floats to an integer for insert?
thx
You could modify it, but it's easier to user integers and just reorder all the items in the list that appear after the one you're moving.
Using floats you're forced to split numbers into higher and higher precision every time you move a list around, and if a list gets enough reordering in it, you're likely to eventually run into problems related to how floating point numbers are stored, and then you'll have a list whose ordering breaks in subtle ways that won't be immediately obvious. The other issue with using floats really has to do with storing position (which is inherently a whole number) as a floating point number. When you're standing in a line, you don't think of yourself as being in position 1.5 - you're either in position 1 or 2. The only case where a measurement like 1.5 makes sense in something like people standing in a line is if you're measuring distance (like physical distance in feet/meters) from, say, the front of the line. However, at that point the 1.5 measurement has a very different meaning - it's no longer position, it's distance.
If you're trying to save the on the number of queries/DB changes that are required (floats would allow you to update just one column on one record instead of one column on multiple records), then you're probably missing out on the convenience of the gem doing it for you, and you might want to roll your own if there's some reason you really need to support floats.
However, given the points above about position inherently being a whole number, I'd recommend against doing floats just to save on DB time. How often are people really going to re-sort a list, and how much real load would it put on your app?
If instead, you have to support floats because of some integration point with the old system, then please tell us more about that.