I have been reviewing the Google maps API, (specifically the Directions API), and in theory I know what I want but am having trouble finding the documentation for it;
I have a set of addresses that I would like the fastest route for;
maps.googleapis.com/maps/api/directions/json?origin=START_ADDRESS&destination=###1###&waypoints=###2###,###3###,###ETC###&key=MY_API_KEY
I have surrounded the params I will explain below with ###;
1; This is unknown as I want the furthest address to be the last point; At the moment this is done by getting all of the times distance and just doing it that way, but If I have 3 addresses and address 2 is closer than address 3, but its quicker to go to address 1 then address 3 then address 2 last then it's not good.
2&3; Google seems to just go through the addresses in the order I put them here, and what I actually want is to go in order of the fastest route, the order of addresses does not actually indicate this.
Just wondering what approach I could take, is there something I have missed in the API,
Thanks in advance,
Robert
NB: If something isn't clear please comment and I will try to clarify.
Found out there is an optimise parameter for way-points!:
maps.googleapis.com/maps/api/directions/json?origin=x&destination=x&waypoints=optimise:true|y|z&key=MY_API_KEY
Related
I am very new to the HM HEVC (and the JEM) reference software, and I am currently trying to understand the source code. I want to add some lines to display for each component: name of Algo (i.e. inter/intra Algos) + length of the bitstream+ position in output bin file.
To know which component cost more bits to code and how codec is working. I want to do same thing for the JEM also after that.
my problem first is that I am unable of understanding a lot of function there, the comment is not sufficient, so is there any references to understand the code??!! (I already read the Manuel ,doesn’t help).
2nd I don’t know where & how exactly to add these lines; is it in TEncGOP, TEncSlice or TEncCU. Ps: I don’t think in TEncGOP.compressGOP so maybe in the 2 other classes.
(I put the answer to comment that #Mourad put four hours ago here, becuase it will be long)
I assume that you could manage to find where the actual encoding after the RDO loop is implemented. As you correctly mentioned, xEncodeCU is the function you need to refer to make sure you are not still in the RDO.
Now you need to find the exact function in xEncodeCU that is responsible for your target codec tool.
For instance, if you want to count the number of bits for coefficient coding, you should be looking into the m_pcEntropyCoder->encodeCoeff() (It's a JEM function and may have different name in the HM). Once you find this line in the xEncodeCU, you may do this and get the number of bits written inside encodeCoeff() function:
UInt b_before = m_pcEntropyCoder->getNumberOfWrittenBits();
m_pcEntropyCoder->encodeCoeff( ... );
UInt b_after = m_pcEntropyCoder->getNumberOfWrittenBits();
UInt writtenBitsCoeff = b_after - b_before;
One important point: as you cas see, the function getNumberOfWrittenBits() gives you integer rates, which is obtained by rounding sum of fractional rates corresponding to all syntax elements coded inside the function encodeCoeff. This error might or might not be acceptable, depending on your problem. For example, if instead of coefficient coding rate, you wanted to know the rate of CBF, then this error would not be acceptable at all. Because, CBF rate is mostly less than one bit. If this is your case, then you would need to calculate the fractional bits one-by-one. It would be totally different and relatively more complicated than this.
Point 1: There is one rule of tumb that logging coding decisions (e.g. pred mode, MV, IPM, block size) is much easier at the decoder side than encoder. This is because of the fact that you have super complicated RDO process at the encoder side that can easily make you get lost in the loops. But at the decoder side, everything appears only once. However, if you insist on doing it at the encoder side, you may find some tips here: Get some information from HEVC reference software
Point 2: Unlike coding decisions, logging rate (i.e. number of written bits for different syntax elements) is more complicated at the decoder side than encoder. This is particularly true for fractional bits associated to anything that is encoded in non-EP mode (i.e. with CABAC contexts). So you may do this part at the ecoder side. But I am afraid it is not easy.
Point 3: I think the best way to understand the code is to read it line-by-line. It's very time-consuming but if you theoritically know the standard(s), you will probably be able to distiguish important parts and ignore the rest.
PS: I think there are too many questions, mostly too general, in your post. It makes it a bit difficult for me to answer them all together. So you I'll wait for you to take your next step and ask more precise questions.
I have a few variables and here they are, three variables "R1, R2 and R3" each have a size of [40 x 1].
I have a fourth variable U of the same dimension. For every U(i) I need to search for an optimum value within R1(i), R2(i) and R3(i) which would return a single value solution. I intend to plot the optimum value against U9i).I have been trying to wrap my head around the knnsearch function but no luck.
Any one out there who could please help??
Thanks
Well when I can't wrap my head around something, I don't come here first.
A lot of people forget this one because we are online, but read a book on the topic. Have your code open so when you see something in the book, test it out.
Draw out any type of diagram. I call these "Napkin Diagrams", because I write it on anything, even a napkin.
I play with code until my keyboard has no letters left on it, then I keep plugging away until the keys fall off
Explore the language API's
Check for public repositories that you can play with
Google, is okay for a quick reference, but google will not teach you anything other than how to google
I talk my code over with myself all the time, people think I'm nuts, but so do I . . It actually works sometimes.
Then if I still can't get it, I come here with a list of things that I have tried, sample code that has not worked, etc.
I used to hate when people told me this, but that was the best thing anyone could have done for me so I tend to do the same now" Thinking about coding is a big part, but u have to get done wht u can. Then we all know what level u are at. Plus it being the end of semester a lot of these types of questions are homework...
Thinking is good, now turn those thoughts into a conceptual design . It's okay to be wrong in this stage, its all just conceptual
If I understood correctly, this might be what you need:
RR = [R1(:) R2(:) R3(:)];
d = bsxfun(#minus,RR, U(:));
[m mi] = min(abs(d),[],2);
answer = RR(:,mi);
first - put the three vectors into a single matrix:
RR = [R1(:) R2(:) R3(:)];
next, take the difference with U: bsxfun is ideal for this kind of thing
d = bsxfun(#minus,RR, U(:));
Now find the minimum absolute difference for each row:
[m mi] = min(abs(d),[],2);
The corresponding indices should allow you to find the "best fit"
answer = RR(:,mi);
I had to do some mind reading to get to this 'answer', so feel free to correct my misunderstanding of your problem!
update if you just need the highest of the three values, then
val = max([R1(:) R2(:) R3(:)]');
plot(U, val);
should be all you need...
i am sending the following data to the arduino over serial:
c1:255c2:0c3:0c4:255c5:0
i need to separate this into 5 variables, so it will eventually become
val1=255
val2=0
val3=0
val4=255
val5=0
so my first step would be to separate the incoming serial data into
c1:255
c2:0
c3:0
c4:255
c5:0
then to parse the data so that it drops the correct integer into the correct variable so the int in c1 becomes val1 etc.
This will eventually let me set a value and so i need to be able to recall the value easily.
i understand i need to use an array but i have spent hours looking at how to do this and got nowhere, can someone show me how to do each of these steps, i am a NOOB so be kind! thanks
Not to give it all way, in basket, the following links of my projects have similar features that you are looking for. From there code you will find the pieces of the puzzles of how to build the array and dissect it looking for the desired components you are looking for:
http://mpflaga.github.io/Sparkfun-MP3-Player-Shield-Arduino-Library/_file_player_8ino_source.html#l00132
https://gist.github.com/mpflaga/5350562#file-trackplayer-ino-L131
https://gist.github.com/mpflaga/5351285#file-filenameplayer-ino-L123
Not to say there are better ways.
This is a similar question to this one (which was answered for ggplot2), this one (which was answered for R) and is a follow up question to this one (which is still looking for an answer).
How could I use this recent Constrained Zoom plot by Mike Bostock (http://bl.ocks.org/mbostock/4987520) but have the starting position with the pacific in the center rather than Africa?
Like this...
Obviously just adjusting the .translate([0, 0]) values in the code moves the map, but there is no 'wrapping' that would allow the map to be presented as above.
I am convinced that there must be a simple way to accomplish this, as it seems like a fundamental capability, I just can't see or find a solution.
OK, The answers was pretty obvious in the end and many thanks to the guys at Hashbang whose post set me on the right path.
The problem I was having was assuming that I needed to use the .translate() function to shift the map to the correct location, when in fact the .translate() function just moves the points on the returned map. So in other words it literally translates what you have to another location (duh!).
What I should have done is use the .rotate function to rotate the map about its longitude by using the function like so;
var projection = d3.geo.mercator()
.translate([0, 0])
.scale(width)
.rotate([-180,0]);
This simply wraps the map around and gives full control as desired.
A fully functioning example is here.
I have been asked in an interview how one can return more than one value from function. I have answered saying by using pointers we can achieve(call by reference) this in C. Then he told me he is looking for some other way of returning more than one value. I said we can return a struct object but here also he didn't seem to be impressed.
I would like to know others ways to return more than one value from a function.
I have seen this questions being asked here on SO, but could not find anything C specific.
The tricky problem is that the interviewer has some solution they are particularly happy with in mind and they are likely grading you by whether you have the same clever trick as them or not.
You could just name a few ways such as you did, and still not fall upon their secret trick. And if you knew their secret trick, you could well not be impressed with it.
So in these situations, its to turn it from interview into conversation. Once you detect you're not moving towards their ego, you can avoid heading towards the intimidating "I don't know" "I give up" and instead try out the "so do you have any clever solution? Is there an in-house recipe for this at Xyz Inc?" etc.
Any glimpse at their obviously self-impressed solution and you are back on firm ground where you can talk about it and ask them if they have thought about various factors that come to mind and basically interview them.
Everyone loves a good listener, and getting them to talk about their tricks is a good way to get them to leave the interview throughly impressed with you! ;)
There are a few ways:
Return value using the return statement (as you already know)
Return via references.
Return values via the heap.
Return values via global variables.
That depends on what you consider a value. If a value is a piece of information for you, more values could be a struct of values. More values could be also passed via pointers or arrays, even a char* containing a list of (non-zero alphanumerical) values. If you consider a value to be a bit of information a single returned uint32_t may hold 32 values. You could even mess around with signals or sockets or pipes or files.
But for you do not even know the use case and the requirements it imposes on the solution, it's indeed a rather hard task to come up with the right solution (and you actually did come up with some proper solutions ...).
Return a pointer to a structure, or pack several small datatypes into one large datatype, or use global variables.
The first is probably the cleanest way to do it, the other two might have their uses in certain situations.
If we pass the address instead of the true value of the parameters.
Then whenever we refer those parameters we do it with the address.
returning a pointer to structure is the suitable answer.(Obviously, the objective of the program can decide what's the best that can be done). The interviewer might have wanted you to say 'I don't know' which would have shown your lack of confidence in the field. I think you provided good solutions, though not what he had in his mind. You could have asked him about a typical scenario where he wanted multiple values to be returned and then discuss how struct-pointer is a reasonable alternative.