Grateful 7 speech thanking everyone that has helped.pdf
SQL Server 2008 Spatial Geography with VE
1. SQL Server 2008 Spatial Geography Implemented in ASP.net and Virtual Earth Michael Stark StarkNetwork.com Michael@starknetwork.com blog.starknetwork.com
2. Outline Background Overview Spatial in SQL 2008 Creating a spatial Query in SSMS Spatial Query in ListView control Spatial Query wired up to Virtual Earth 21 Other ideas for mapping Implementation Issues This session is … a quick tour of the spatial features of SQL Server 2008. This session is NOT … An in-depth study of the spatial features of SQL Server 2008 An in-depth explanation of ListView Control An in-depth explanation of Virtual Earth
3. Overview Tyler’s Article SQL Server Magazine SQLMAG.com Instant Doc ID 100528 Tyler Chessman's article in SQL Server Magazine's December 2008 issue is my primary source of information to implement my spatial solutions. Visit sqlmag.com and search for instant doc ID 100528. I have a link on my blog to the article.
4. Overview What is Spatial Data? Example of Spatial Data SQL Server’s answer Spatial data represents the shape and physical location of an object. The object can be a house, business, sub-division, or a county. SQL Server 2008 has two new data types GEOMETRY and GEOGRAPHY. GEOMETRY works with flat objects. GEOGRAPHY considers the shape of the earth.
5. GEOMETRYGEOGRAPHY CLR Data Types No need to enable CLR Many Methods Open Geospatial Consortium GEOGRAPHY and GEOMETRY are CLR data types. You do not need to have CLR enabled on the SQL Server instance. Microsoft has provided a long list of OGC methods. These are methods that are part of the independent Open Geospatial Consortium list of specifications.
6. OGC Methods OGC Open Geospatial Consortium SQL Server 2008 supports the Open Geospatial Consortium (OGC) methods on geometry instances. These methods make it very easy to perform geospatial tasks that were once very difficult. STArea STAsText STBoundary STBuffer STCentroid STContains STConvexHull STCrosses STDifference
7. OGC Methods OGC Open Geospatial Consortium SQL Server 2008 supports the Open Geospatial Consortium (OGC) methods on geometry instances. These methods make it very easy to perform geospatial tasks that were once very difficult. STDimension STDisJoint STDistance STEndPoint STEnvelope STEquals STExteriorRing STGeometryN STGeometryType
8. OGC Methods OGC Open Geospatial Consortium SQL Server 2008 supports the Open Geospatial Consortium (OGC) methods on geometry instances. These methods make it very easy to perform geospatial tasks that were once very difficult. STInteriorRing STIntersection STIntersects STIsClosed STIsEmpty STIsRing STIsSimple STIsValid STLength
9. OGC Methods OGC Open Geospatial Consortium SQL Server 2008 supports the Open Geospatial Consortium (OGC) methods on geometry instances. These methods make it very easy to perform geospatial tasks that were once very difficult. STNumGeometries STNumInteriorRing STNumPoints STOverlaps STPointN STPointOnSurface STIsSimple STRelate STSrid
10. OGC Methods OGC Open Geospatial Consortium SQL Server 2008 supports the Open Geospatial Consortium (OGC) methods on geometry instances. These methods make it very easy to perform geospatial tasks that were once very difficult. STStartPoint STSymDifference STTouches STUnion STWithin STX STY
11. DEMONSTRATION List of functions to demonstrate I will demonstrate STGeomFromText STDistance AsGML STasText STGeometryType STNumPoints. The demonstration will return a list of stores within a provided distance of a given point.
12. STDistance STDistance( Point , SRID ) The STDistance function requires an argument of the SQLgeometrytype Convert the latitude and longitude to SQLgeometrytype. Declare a variable of the geography type. Set the variable togeography::STGeomFromText('point(lon lat)',4326). Notice that the point is a string. Notice there is no comma between lat and lon 4326 is an SRID and is used to tell the function what method to use to calculate distance on a not-so-round planet.
13. SQL Statement Declare @CodeGEOG geography = geography::STGeomFromText('Point(-95.3410 29.7070)',4326); Select top(5) addr.AddressID as id , addr.addressline1,addr.city, addr.SpatialLocation, -- Will show the raw data addr.SpatialLocation.AsGml() as SpationalGML, addr.SpatialLocation.STAsText() as SpatialText, addr.SpatialLocation.STGeometryType() as GeoType, addr.SpatialLocation.STNumPoints() as Points, addr.SpatialLocation.STDistance(@CodeGEOG) as distance_in_meters, addr.SpatialLocation.STDistance(@CodeGEOG)/1609.344 as distance_in_miles from dbo.Addressaddr Where addr.SpatialLocation.STDistance(@CodeGEOG)/1609.344 < 50 order by distance_in_miles
21. An in-depth explanation of Virtual EarthBackground Overview Spatial in SQL 2008 Creating a spatial Query in SSMS Spatial Query in ListView control Spatial Query wired up to Virtual Earth 21 Ways to implement VE Deployment Issues
22. SQL Server 2008 Spatial Geography Implemented in ASP.net and Virtual Earth Michael Stark StarkNetwork.com Michael@starknetwork.com http://blog.starknetwork.com