I'm asking this question in a different way, another user let me know what I need to ask for, I'm basically looking to convert to "decimal degrees". The conversion of course must be accurate. I see javascript solutions out there like this javascript example. I need ruby. Maybe someone could write the javascript in Ruby and I can try that, if that's easy of course and if it's right that is?
Basically I have this in my DB.
<coordinates_east>6'01.4</coordinates_east>
<coordinates_north>45'05.5</coordinates_north>
I need a routine written in Ruby to convert these to decimal degrees for use with the google maps API, possible?
you want like this? not understand your question well though.
puts "6'01.4".scan(/(\d+)'(\d+)\.(\d+)/).map{|x,y,z|x.to_f+y.to_f/60+z.to_f/3600}
6.01777777777778
puts "36'57.9".scan(/(\d+)'(\d+)\.(\d+)/).map{|x,y,z|x.to_f+y.to_f/60+z.to_f/3600}
36.9525
Related
I want to use package:intl to make multi lang html page.
I have seen example/basic_example.dart but don't find document of message_lookup_by_library.dart, intl_helpers.
Is there a simple example use package:intl.
Parts of that are still work in progress, e.g. there should be an update so that plurals and genders work in the next few days. To see the basic workflow, take a look at the intl/test/message_extraction directory and specifically message_extraction_test.dart That does a round-trip extraction, translation, code generation, and running the result. The end result is roughly what you see in basic_example.dart, but it actually does the intermediate steps to produce that.
That test uses a trivial JSON format for output and the translations are hard-coded. You could manually translate things using that format, but for real usage you would probably want to use a real translation tool and a format that it understood. There is a little bit of documentation at http://api.dartlang.org/docs/releases/latest/intl/Intl.html but for the time being you're probably stuck looking at the code and/or asking questions.
I am using DDMathParser in my app, and have recently come across the need to get occurrences of any group of numbers within a () parentheses bracket thingy (very highly technical!). For example, I would need to get (6+5) out of 6+7/8(6+5). Specifically, I would like to be able to do this so that I can make (56+9)sqrt compile just as well as sqrt(56+9). Any help?
P.S. I know that the maker of DDMathParser is often sighted in this neck of the woods. I am secretly hoping that he will come to the rescue and either fix my problem so I can implement it myself or him make it part of DDMathParser! :)
So, I've thought a lot about this question since you posted it a month ago. From what I understand, you're constructing a string as the user clicks/taps buttons.
I think this is your problem.
As the user taps buttons, you should be constructing (or modifying) DDExpression objects. This is the "pure" format of a math expression, whereas a string is lossy and difficult to manipulate. The string you show to the user should be generated from the DDExpression tree you're building.
This is a complex problem, and I'm still not entirely sure how I would go about implementing this, but this is the root of how I'd do it. I would not just construct a string based on what the user types.
I was looking for some good options for fuzzy comparison in Rails.
Essentially, I have a set of strings that I'd like to compare against some strings in my database and I'd like to get the closest one if applicable. In this particular case, I'm not so interested in detecting letters out of order/mis-spellings, but rather the ability to ignore extraneous words (extra information, punctuation, words like: the, and, it etc) and pick out the best match. These strings will usually be somewhere between 2-7 words long.
What would you suggest is the best gem/method of doing that? I've looked at amatch (http://flori.github.com/amatch/doc/index.html) but I was wondering what else was out there.
Thanks!
Have a look and a play with Thinking Sphinx http://freelancing-god.github.com/ts/en/
I can heartily recommend it
There is also a superb Railscast on how to use it here
http://railscasts.com/episodes/120-thinking-sphinx
Otherwise use ARel - but you are going to have to implement your own fuzzy logic (Not something I'd recommend)
Have a look on this FuzzyMatch gem
It may help you.
I have a requirement to handle custom date formats in an existing app. The idea is that the users have to do with multiple formats from outside sources they have very little control over. We will need to be able to take the format and both validate Dates against it, as well as parse strings specifically in that format. The other thing is that these can be completely arbitrary, like JA == January, FE == February, etc...
to my understanding, chronic only handles parsing (and does it in a more magical way then I can use), and enter code here DateTime#strptime comes close, but doesn't really handle the whole two character month scenario, even with custom formatters. The 'nuclear' option is to write in custom support for edge cases like this, but I would prefer to use a library if something like this exists.
I don't think something that handles all these problems exists if the format is really very arbitrary. It would probably be easiest to "mold" your input into a form that can be handled by Date.parse, Date.strptime, or another existing tool, even though that could mean quite a bit of work.
How many different formats are we talking about? Do any of them conflict? It seems like you could just gsub like so: input_string.gsub(/\bJA\b/i, 'January'). Is this part of an import routine, or are the users going to be typing in dates in different formats?
There's a related question here: Parse Italian Date with Ruby
I have a complex problem, I am getting formulas form the database and I need to evaluate them. I choose to convert them to post fix...and evaluate them the problem is that..
my formulas are like
roundoff(vd,2);
udV=lookup(uv*dse,erd);
ude=if(er>es)?sr:ss;
Can anyone find a solution for these type of conversions and evaluations...
No, not without some more clarification from you. Perhaps you could tell us what sort of technology you are using and what some, at least, of your functions mean. As it stands I recommend that you use Mathematica because it's probably powerful enough to tackle this type of problem. If you don't have access to Mathematica, perhaps you could hook in to Wolfram Alpha for evaluations.