Get geo-locations from cities - asp.net-mvc-4

I am trying to display a list of closest restaurants of a given city within a radius. In order to do this, I'll have to convert the city to a longitude/latitude.
When the user fills in his/her restaurant information, he/she will fill in the address. Based on that address i need to get a longitude/latitude and save that to the database.
I don't need to point this on a map. I'll be just displaying a list of all closest restaurants within the given radius to the user.
How can I do this with ASP.NET-MVC4?
Also, this project is based on Code First. And for address I have DbGeography as datatype set.
The project is kind of based on this tutorial
Edit
To avoid anyone else telling me this is not possible with ASP.NET on it's own, I am aware of that. an example with Google maps / .NET wrapper would be great.

This query itself is typically done in the database back-end because the program is the consumer of the data not the keeper of the data. You will have a table of restaurants, possibly for many cities, each restaurant having a latitude and longitude. You create a geospatial index on the table, which performs a tesselation for performance; you configure the tesselation parameters. You must determine the latitude/longitude of your restaurant-seeker's location. Your command object would feed that data to a stored procedure, along with the desired radius. The stored procedure would return an enumerable set of rows to your client program.

I found this .NET wrapper which fulfills my need.

Related

Gooddata Report Showing Weather by Store

I do have in my project model 3 datasets showing stores (DS_SITE), cities (Cidades) and weather (DS_DADOS_CLIMA) like in the image below:
datasets
And I want to see the name of the store with it's respectively weather information, but when I try select the store name to the report, it's not permitted:
report
how
There is some way to show the weather with the store name in the same report? I've changed the model and the metric several times trying to do it, but it didn't work.
Here is the metric I used in the example above (DS_DC_TEMP_MAX = weather fact):
metric
The direction of the arrow between City and Weather is what's preventing you from slicing temperature by Store.
Are you're sure about it? (as modeled, each city can have multiple weathers, each weather belongs to at most one city)?
If the direction is correct (you're probably tracking history of weathers), you'll need to lift weather to city, see explicit lifting:
https://help.gooddata.com/display/doc/Explicit+Lifting.
If you don't need to track history, just reverse the direction of the arrow between city & weather and you should be able to slice temperature by store (show them side by side).
Hope that helps.

How to access weather data from all the stations in one country using openweathermap?

I am using Alteryx to extract weather data for a handful of cities and it works great. I'd like to expand this to able to download data for all weather stations in the UK. At the moment I am specifying which cities I want, e.g. London / Manchester.
Is there a way of specifying in the api call to download all stations in 'GB' or 'UK'?
Ideally I'd like to do this in one call rather than listing all locations which will be very laborious
Get a list of stations or cities that you want to retrieve weather data from. I found some good sources from openweather here: http://bulk.openweathermap.org/sample/
Then build a url request using the list of id's above that retrieves specific weather information. Using an id for the weather station in Cairns, id=2172797, the url ends up looking like:
http://api.openweathermap.org/data/2.5/weather?id=2172797&appid=843798874aac0ef138e6f77c72f3af80
Note that this url will return an error because this isn't a real appid. If you replace the appid with your own, this url will give you data for that station.
Putting this process into Alteryx lets you put the list of station id's together with the url and the appid to make many calls into openweather and then process all of the data together. I could not find information from the API on rate limits, so be conscious of how many requests you are posting to the service.
There is an example of this process here: https://www.dropbox.com/s/yoppbx3bw0p4rug/Get%20individual%20stations.yxzp?dl=0
Keep in mind that you have to update the Appid in the text input tool within this sample as well.

Advice to create a little script to associate near shipping address in the next 3 weeks

Hi guys I'm searching an advice on how to proceed to create a script that can calculate the distance between all shipping address in the next 3 weeks and if the distance between some of these locations is under 50 km it must send an email to make that thing notice to the operator. I'm starting from sql 2005 to take location and make all combination. Then I was thinking if there is some online service that, with a link structure where I can put the two location name, can retrieve the distance between those two point, then store it in different variable to use to make comparisons. I'll wait for some advice.thank you guys
Your script will probably take in 2 locations as parameters and you can determine the distance using Google Maps Matrix to get your distances from one place to another. Using that info you should be able to send an email using the script.
I'm not really sure what a database has to do with this so I recommend being more specific on your SQL implementation.

Google Places API: Using Multiple Name Parameters in the Places Search

I've been reading the documentation at: http://code.google.com/intl/nl/apis/maps/documentation/places/#PlaceSearches
But How do I modify the Place Search Request (shown below) so that I can limit the results to specific businesses only.
https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyAiFpFd85eMtfbvmVNEYuNds5TEF9FjIPI
For example in the above code it hastypes=food&name=harbour as two of the parameters. How can I include just "bakery" and "cafe" (both are supported list types) as the types parameter and then include multiple name parameters as well.
In bigger cities it may come back with 20 or so results, but I want to limit it to a handful of businesses that I have agreements with and just show their names on the map. I don't want Starbucks to come back so I want to restrict it to just the 8-10 businesses that I have the agreements with. Their names will be stored in a database so I can easily retrieve them and pass them into the HTTP URL, but I don't know how to do multiple names and get them all to show up on the map at the same time.
Any links to tutorials that can help or your ideas and suggestions would greatly help!
You can include types "bakery" and "cafe" by modifying your request parameter types=food|bakery|cafe add more types separate by "|" operator
for supported type list refer Link

WCF data services - Limiting related objects returned based on critera

I have an object graph consisting of a base employee object, and a set of related message objects.
I am able to return the employee objects based on search criteria on the employee properties (eg team) etc. However, if I expand on the messages, I get the full collection of messages back. I would like to be able to either take the top n messages (i.e. restrict to 10 most recent) or ideally use a date range on the message objects to limit how many are brought back.
So far I have not been able to figure out a way of doing this:
I get an error if I attempt to filter on properties on the message (&$filter=employee/message/StartDate gives an error ">No property 'StartDate' exists in type 'System.Data.Objects.DataClasses.EntityCollection`1).
Attempting to use Top on the message related object doesn't work either.
I have also tried using a WebGet extension that takes a string list of employee IDs. That works until the list gets too long, and then fails due to the URL getting too long (it might be possible to setup a paging mechanism on this approach)...
Unfortunately the UI control I am using requires the data to be in a fairly specific hierarchical shape, so I can't easily come at this from starting on the message side and working backwards.
Outside of making multiple calls does anyone know of a method to accomplish this with wcf data services?
Thanks!
M.
Looks like the only real way of doing this is in fact to reverse the direction of the query.
So instead of starting from the Employee, I go from the message side. You can filter back on the employee properties, and restrict on the Messages collection. Its not ideal, as it means iterating the collection on return to re-center it on the employee for what I am attempting to do, but it will work. The async nature of silverlight and rich client at least means while an extra iteration is required, it still appears to be reasonably fast.
Another interesting thing to note: the current version of odata/wcf data services does not support querying on properties of inherited classes, so I had to move the start/end date properties up to the base class in order to be able to restrict my search on them.
http://Site/Service.svc/Messages()?&$filter=Employee/OfficeName eq 'Toronto' and (year(StartDate) eq 2010 and month(StartDate) ge 9 )