Ifta calculation - way points - mileage by state - web-services

We are developing Trucking Management Software web app
for ifta calculation and reporting purposes, I need to calculate a route with 60-120 way points
no directions, just total mileage and mileage by state.
I tried researching but im not sure i can find it,
Can google handle so many way points without directions, can I get a mileage breakdown by state...
Please help

The Distance Matrix API fits your need best. Each request can take up to 25 destinations so you'd have to split up the route into batches of 25 or fewer. Note that the pricing is different if you want simple distances and traffic-independent travel times vs. if you want travel times that take into account traffic information. The API does not split up a leg that crosses state lines, so you'd need to insert waypoints for state borders if you want to divide your mileage tallies by state.
You could also use the Directions API (handles up to 25 waypoints between the origin and destination) but its pricing charges the higher price for any request that includes more than 10 waypoints, so it won't be as cost-effective as the Distance Matrix API.

Related

Training dataset generator in OpenCV

I'm working on my bachaleor theses called "Traffic sign detection in image and video" and I'm using neural network called YOLO (You Only Look Once). I think its name is pretty self-explaining, but paper may be found here.
This network is learning from not-cropped annotated images (Regular networks use to train on cropped images). To be able to learn this network, i need not-cropped annotated european traffic signs dataset. I wasn't able to find any, even not here, so i decided to generate my own dataset.
First, I load many images of road taken from static camera on the car.
I've got few TRANSPARENT traffic (stop) signs like this
Then I'm doing few operations to make the traffic sign look "real" and copy it to random positions (where traffic signs usually are located). The size of traffic sign is adjusted due to its position in image -- closer to the middle sign is, the smaller sign is.
Operations I'm performing on traffic sign are:
Blur sign with kernel of random size from 1x1 to 31x31.
Rotate image left/right in X axis, random angle 0 to 20.
Rotate image left/right in Z axis, random angle 0 to 30.
Increase luminescence by adding/subtracting random value from 0 to 50
Here you may see few result examples (the better ones i guess): click.
Here is the source code: click.
Question:
Is there anything i could do to make the signs look more real and let the neural network train better ?
If the question would suit better for different kind of site, please, let me know.

How to determine sunset/sunrise including terrain shadows.

In Google Earth you can use the "Sunlight" layer to view shadows cast by the terrain at any given DateTime: http://i.stack.imgur.com/YFGMj.png
However, I have not been able to find any way to access the sunlight/luminosity/shadow/etc values from the API.
I'm looking for a way to supply Lat, Long and DateTime to determine if an area is in sunlight (taking terrain shadows in to account, there are countless services that will provide simple Sunrise and Sunset times, but these do not consider terrain). This can be done manually with Google Earth, but I'm looking for a programatic method.
Thanks for any thoughts, ideas, leads...
I realise that this is an old question, but it surfaced in a google search I just did, and I liked the focus.
Since you're looking for a programmatic way of determining if a point on earth given by a longitude and latitude tuple is exposed to sun at a given time, I can't help you right now. However, I'm in a position to be able to set up such an API quite easily if we see that this is a feature that many people need. At suncurves.com we calculate sunrise and sunset times accounting for terrain. The solution we've set up so far is a web interface where a user can search for an address or drag and drop the icon on a map to get sunrise and sunset times through the year for that exact spot accounting for terrain. We want to create an API to our data, but we do not have a clear specification of the scope of this API yet. What you ask for requires that we need to:
Calculate the apparent horizon from the viewing point of the
longitude and latitude. This means scanning the terrain data in a
search radius of 30-50 km around your point.
Calculate the sun's position at the specified time.
Calculate the sun's position at the specified time. Determine if the
sun is under or over the horizon as given by the terrain surrounding
your point accounting for atmospheric refraction.
Here's an example from Chamonix, France where the common flat terrain versions of sunrise, sunset times are pretty worthless.
http://suncurves.com/v/7/
I am not sure about determining whether an AOI in in the sun or shade at a certain time, however you can set the SUN to be on or off in the API by using
GESun.setVisibility
Edit:
Using the GE-plugin, create a LookAt with your desired AOI lat/long where the view is directly above looking straight down. Depending on the size of you actual AOI I would keep the view as low to the ground as possible.
Then capture a screenshot/image - I do not think this is possible through GE (if anyone knows a way I would like to find out), so maybe use javascript to take it - I found this Q on SO that provides some insight.
Take a screenshot with GESun.setVisibility set ON and then another with it OFF
Compare the two images for darkness/lightness or something and determine if your AOI is in the shade or not. You might find it better to surround your AOI in a Polygon of some sort in order to help your program distinguish it from the rest of the image - depending on the height the LookAt was taken from etc etc....
I do not have any ideas on how to compare the images, but yet again another search on SO resulted in this (I would presume finding the values of COLOR_BLACK in PHP ImageMagick) and this (Color Buckets idea).
Depending on your method of choice, it might help to alter your images to black/white before doing the comparing.

When calculating a distance from a city, how can I factor in the approximate size (physical area) of the city?

I'm building a store locator based on in-house geocoding data. Effectively I need to query stories near City X or Zip Y within a certain radius. The data sets I'm working with are relatively comprehensive and include things such as population.
One issue is that large cities (Los Angeles for example) are many miles in radius so you could be within the city but miles from the coordinate we have loaded.
Is there a rule of thumb, or a free data feed which would list an approximate radius of a city, or perhaps even outlines of the city points?
Also, assuming I have a shape defining the city what calculation would I use to say "stores within X miles of this area"?
Why don't you use the zip codes and latitude/longitude of the stores, instead of the cities? You know the addresses of the stores, so use its zip code, look up the coordinates, and calculate the distance from the origin zip code. Then it wouldn't matter how big the city is, because big cities have many zip codes, but each store has its own zip code.
It would only be a problem for states with big zip codes like Texas, but then there is likely not more than 1 store per zip code anyways so not a big deal.
Ultimately we didn't implement this feature, but before it was cancelled I had a fair amount of success using the below approach:
Finding coordinates for the city itself, as well as all zip codes of the city
"Connecting the dots" of all the above coordinates to create a polygon of the (very rough shape of the city)
Checking if the user's input coordinate was within the given range of the polygon
The above approach worked relatively well and may have ultimately developed into a sound solution with some more enhancements and tuning.

How many data can be mass data? How many dimensions can be high-dimension?

i'm going to be a master now, and my teacher's research direction is data-mining for high-dimension mass data.
but i still can't imagine what are mass data, and how many dimension can be called high-dimension.
tks~
Mass data? Well, you can consider that all Google's requests, considered as a stream, contitute a mass data.
Mass dimensions? Imagine a Google engineer considering a few topics like "five-legged dogs". He can think that every user represents a dimension, and compute some correlation stuff. And there i a lot of users.
Now, back to the point, there are no clear definitions of mass data, or of high dimensions. However, you can consider that :
If you have so much data that you cannot load all of it in memory (I'm talking about HDD, not just RAM), it's mass data
If your algorithms begin to fail because of the curse of dimensionality, it's high dimensionality. 1.000.000 dimensions is surely high-dimension. You can often consider that 1.000 is high dimension too.

How to exploit periodicity to reduce noise of a signal?

100 periods have been collected from a 3 dimensional periodic signal. The wavelength slightly varies. The noise of the wavelength follows Gaussian distribution with zero mean. A good estimate of the wavelength is known, that is not an issue here. The noise of the amplitude may not be Gaussian and may be contaminated with outliers.
How can I compute a single period that approximates 'best' all of the collected 100 periods?
Time-series, ARMA, ARIMA, Kalman Filter, autoregression and autocorrelation seem to be keywords here.
UPDATE 1: I have no idea how time-series models work. Are they prepared for varying wavelengths? Can they handle non-smooth true signals? If a time-series model is fitted, can I compute a 'best estimate' for a single period? How?
UPDATE 2: A related question is this. Speed is not an issue in my case. Processing is done off-line, after all periods have been collected.
Origin of the problem: I am measuring acceleration during human steps at 200 Hz. After that I am trying to double integrate the data to get the vertical displacement of the center of gravity. Of course the noise introduces a HUGE error when you integrate twice. I would like to exploit periodicity to reduce this noise. Here is a crude graph of the actual data (y: acceleration in g, x: time in second) of 6 steps corresponding to 3 periods (1 left and 1 right step is a period):
My interest is now purely theoretical, as http://jap.physiology.org/content/39/1/174.abstract gives a pretty good recipe what to do.
We have used wavelets for noise suppression with similar signal measured from cows during walking.
I'm don't think the noise is so much of a problem here and the biggest peaks represent actual changes in the acceleration during walking.
I suppose that the angle of the leg and thus accelerometer changes during your experiment and you need to account for that in order to calculate the distance i.e you need to know what is the orientation of the accelerometer in each time step. See e.g this technical note for one to account for angle.
If you need get accurate measures of the position the best solution would be to get an accelerometer with a magnetometer, which also measures orientation. Something like this should work: http://www.sparkfun.com/products/10321.
EDIT: I have looked into this a bit more in the last few days because a similar project is in my to do list as well... We have not used gyros in the past, but we are doing so in the next project.
The inaccuracy in the positioning doesn't come from the white noise, but from the inaccuracy and drift of the gyro. And the error then accumulates very quickly due to the double integration. Intersense has a product called Navshoe, that addresses this problem by zeroing the error after each step (see this paper). And this is a good introduction to inertial navigation.
Periodic signal without noise has the following property:
f(a) = f(a+k), where k is the wavelength.
Next bit of information that is needed is that your signal is composed of separate samples. Every bit of information you've collected are based on samples, which are values of f() function. From 100 samples, you can get the mean value:
1/n * sum(s_i), where i is in range [0..n-1] and n = 100.
This needs to be done for every dimension of your data. If you use 3d data, it will be applied 3 times. Result would be (x,y,z) points. You can find value of s_i from the periodic signal equation simply by doing
s_i(a).x = f(a+k*i).x
s_i(a).y = f(a+k*i).y
s_i(a).z = f(a+k*i).z
If the wavelength is not accurate, this will give you additional source of error or you'll need to adjust it to match the real wavelength of each period. Since
k*i = k+k+...+k
if the wavelength varies, you'll need to use
k_1+k_2+k_3+...+k_i
instead of k*i.
Unfortunately with errors in wavelength, there will be big problems keeping this k_1..k_i chain in sync with the actual data. You'd actually need to know how to regognize the starting position of each period from your actual data. Possibly need to mark them by hand.
Now, all the mean values you calculated would be functions like this:
m(a) :: R->(x,y,z)
Now this is a curve in 3d space. More complex error models will be left as an excersize for the reader.
If you have a copy of Curve Fitting Toolbox, localized regression might be a good choice.
Curve Fitting Toolbox supports both lowess and loess localized regression models for curve and curve fitting.
There is an option for robust localized regression
The following blog post shows how to use cross validation to estimate an optimzal spaning parameter for a localized regression model, as well as techniques to estimate confidence intervals using a bootstrap.
http://blogs.mathworks.com/loren/2011/01/13/data-driven-fitting/