Tuesday, 29 June 2010

Azure SQL 2008 - Bing Maps - Near Route Demo

Azure SQL 2008 - Bing Maps - Near Route Demo

After the announcement http://bingmapswatch.blogspot.com/2010/03/bing-maps-sql-azure-support-april-2010.html that Azure SQL 2008 was implmenting Spatial Support (Geography and Geometry) this now enabled.

This is an example of combining, Windows Azuew, SQL Azure, Silverlight and Bing Maps to produce a find along a route example

Windows Azure SQL 2008 Bing Maps Find Near a Route
Finding Petrol (Gas) Stations along a route (Boston to Chicago) within 1km (1000m) of the route.

The code inside Azure SQL 2008 doing this is

@myGEOM is the lat and lng (x1,y2)+(x2,y2) start and end points for the route
@myBuffer is the buffer distance (1000m default)
@myRoute is the (xy,xy,xy,xy) of the enitre route creating a polyline
This polyline is then buffered creating a polygon (area) around the route.
SQL 2008 Azure then uses Geoproccessing 'Buffer' and 'Intersect' to pull-out
any points (gas stations in this example) and then displays the points as markers
on bing maps

code:
 CREATE PROCEDURE [FindNearRoute] @myGEOM nvarchar(MAX), @myBuffer int
AS
--Create the Buffer
DECLARE @myRoute geography;
SET @myRoute = @myGEOM;

DECLARE @SearchArea geography;
SET @SearchArea = @myRoute.STBuffer(@myBuffer);

--Return all POI in the search area
SELECT Lat, Lon, Name
FROM PetrolStations
WHERE (@SearchArea.STIntersects(GEOM)) = 1


Live Example (Silverlight required)
http://talkingdonkey.cloudapp.net/BM-SL-FindNearRoute/Default.htm

There is also a zip file (BM-FindNearRoute.zip) with all the source code required to create your own find near a route example.

Source
http://johanneskebeck.spaces.live.com/blog/cns!42E1F70205EC8A96!12533.entry

16 comments:

  1. Really appreciate this post. It’s hard to sort the good from the bad sometimes, but I think you’ve nailed it!
    area codes

    ReplyDelete
  2. Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing.
    Furniture Manufacturer in India

    ReplyDelete
  3. I can’t remember the last time I enjoyed an article as a lot as this one. You have gone beyond my expectations on this subject and I agree together with your points. You’ve done nicely with this…. mens breeches

    ReplyDelete
  4. It is remarkable, it is rather valuable phrase

    Buy Saree Online

    ReplyDelete
  5. Apple now has Rhapsody as an app, which is a great start, but it is currently hampered by the inability to store locally on your iPod, and has a dismal 64kbps bit rate. Indian Mens traditional sherwani

    ReplyDelete
  6. Really appreciate this post. It’s hard to sort the good from the bad sometimes. Each & every tips of your post are awesome.
    Hard Disk Data Recovery

    ReplyDelete
  7. I enjoyed an article as a lot as this one. You have gone beyond my expectations on this subject and I agree together with your points. You’ve done nicely with this

    ReplyDelete
  8. I enjoyed an article It’s hard to sort the good from the bad sometimes.I agree together with your points. You’ve done nicely with this…
    Toshiba Hard Drive Data Recovery

    ReplyDelete
  9. Excellent tips. Really useful stuff .Never had an idea about this, will look for more of such informative posts from your side.. Good job...Keep it up Furniture Stores

    ReplyDelete
  10. Hi, Thanks for your great post, there are much nice information that I am sure a huge number of guys and gals don’t know. Commodity Tips

    ReplyDelete
  11. I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. I enjoyed every little bit part of it and I will be waiting for the new updates. Stock Tips

    ReplyDelete
  12. Very nice and helpful information has been given in this article. I like the way you explain the things. Keep posting. Thanks.. intraday tips

    ReplyDelete
  13. Thank you for such a fantastic blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently working on, and I have been on the lookout for such information. Forex tips

    ReplyDelete
  14. Excellent tips. Really useful stuff .Never had an idea about this, will look for more of such informative posts from your side.. Good job...Keep it up
    Safeguard your Important Data

    ReplyDelete
  15. I can’t remember the last time I enjoyed an article as a lot as this one. You have gone beyond my expectations on this subject and I agree together with your points. You’ve done nicely with this….
    data recovery software

    ReplyDelete