{"id":723,"date":"2008-02-13T23:53:00","date_gmt":"2008-02-13T23:53:00","guid":{"rendered":"\/blogs\/bobb\/post\/Using-SQL-Server-2008-spatial-and-the-Virtual-Earth-map-control-2.aspx"},"modified":"2008-02-13T23:53:00","modified_gmt":"2008-02-13T23:53:00","slug":"using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/","title":{"rendered":"Using SQL Server 2008 spatial and the Virtual Earth map control &#8211; 2"},"content":{"rendered":"<p>\nThis entry is a continuation of the previous posting on how to use SQL Server 2008 spatial data and Virtual Earth. This entry discusses your web service and SQL Server code&nbsp;choices.\n<\/p>\n<p>\nThe point of the web service is to translate one of the output formats of SQL Server 2008 spatial to a format this Virtual Earth can use. The spatial data types can be output in:<br \/>\n1. Well-known text format<br \/>\n2. &quot;Native&quot; format &#8211; that is, return a Geometry\/Geography type to a .NET client as the SqlGeometry\/SqlGeography native .NET types<br \/>\n3. GML &#8211; Geography markup language\n<\/p>\n<p>\nRemember that Virtual Earth needs:<br \/>\n1. GEORSS or<br \/>\n2. KML<br \/>\n3. Custom XML-based format (and custom Javascript code to process it)<br \/>\n4. Javascript strings (to pass to eval())\n<\/p>\n<p>\nThere is not a one-to-one correspondence between any of these methods, so there is going to be a need for a transformation somewhere. In addition, a SQL Server Geometry or Geography type can contain a collection of points, linestrings, or polygons. There may also need to be a one-to-many translation. This is facilitated by methods STNumGeometries\/STGeometryN and STNumPoints\/STPointN.\n<\/p>\n<p>\nFinally, there could be a pushpin (point) associated with the center of a polygon and\/or text associated with the pushpin. Where the text comes from will be application-dependent.\n<\/p>\n<p>\nBecause there are many ways to process XML in SQL Server and in web services, that&#39;s lots of choices. Some that come to mind are:<br \/>\n1. Transforming a SqlGeometry\/SqlGeography from a SqlDataReader to a custom XML format<br \/>\n&nbsp;&nbsp; Javascript code in the web page processes the custom format.<br \/>\n2. Using SQL Server&#39;s XQuery to transform GML into GEORSS or KML<br \/>\n&nbsp;&nbsp; This is returned to the web service as a SqlXml data type.<br \/>\n&nbsp;&nbsp; Consumed directly as a layer in Virtual Earth.<br \/>\n3. Using an XSLT transform (or LINQ to XML) to transform GML to GEORSS or KML. This can occur in the web service or even a SQLCLR procedure, although this type of processing should really be accomplished in the web service.<br \/>\n4. Using SELECT &#8230; FOR XML PATH to construct GEORSS or KML directly.<br \/>\n&nbsp;&nbsp; Similar processing to choice #2 above.<br \/>\n5. Transforming a SqlGeometry\/SqlGeography from a SqlDataReader to Javascript strings.<br \/>\n&nbsp;&nbsp; Web page simply calls eval()\n<\/p>\n<p>\nHopefully this posting will elucidate the choices you have for this rendering. Depending on which method you choose, there could be quite a few &quot;moving parts&quot; (a la Rube Goldberg) in the solution.<br \/>\n&#8211; Web pages with custom Javascript code<br \/>\n&#8211; Web service to supply the data<br \/>\n&#8211; HTTP Handler to allow Virtual Earth to use remote GEORSS\/KML<br \/>\n&#8211; Data access code in SQL Server<br \/>\n&#8211; Transformation code in web service or SQL Server\n<\/p>\n<p>\nSo&#8230;..what&#39;s your favorite method for using SQL Server 2008 spatial data with Virtual Earth?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This entry is a continuation of the previous posting on how to use SQL Server 2008 spatial data and Virtual Earth. This entry discusses your web service and SQL Server code&nbsp;choices. The point of the web service is to translate one of the output formats of SQL Server 2008 spatial to a format this Virtual [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,36],"tags":[],"class_list":["post-723","post","type-post","status-publish","format-standard","hentry","category-sql-server-2008","category-sql-server-spatial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using SQL Server 2008 spatial and the Virtual Earth map control - 2 - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using SQL Server 2008 spatial and the Virtual Earth map control - 2 - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"This entry is a continuation of the previous posting on how to use SQL Server 2008 spatial data and Virtual Earth. This entry discusses your web service and SQL Server code&nbsp;choices. The point of the web service is to translate one of the output formats of SQL Server 2008 spatial to a format this Virtual [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2008-02-13T23:53:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/\",\"name\":\"Using SQL Server 2008 spatial and the Virtual Earth map control - 2 - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2008-02-13T23:53:00+00:00\",\"dateModified\":\"2008-02-13T23:53:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2008\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2008\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using SQL Server 2008 spatial and the Virtual Earth map control &#8211; 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using SQL Server 2008 spatial and the Virtual Earth map control - 2 - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/","og_locale":"en_US","og_type":"article","og_title":"Using SQL Server 2008 spatial and the Virtual Earth map control - 2 - Bob Beauchemin","og_description":"This entry is a continuation of the previous posting on how to use SQL Server 2008 spatial data and Virtual Earth. This entry discusses your web service and SQL Server code&nbsp;choices. The point of the web service is to translate one of the output formats of SQL Server 2008 spatial to a format this Virtual [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/","og_site_name":"Bob Beauchemin","article_published_time":"2008-02-13T23:53:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/","name":"Using SQL Server 2008 spatial and the Virtual Earth map control - 2 - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2008-02-13T23:53:00+00:00","dateModified":"2008-02-13T23:53:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-sql-server-2008-spatial-and-the-virtual-earth-map-control-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2008","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2008\/"},{"@type":"ListItem","position":3,"name":"Using SQL Server 2008 spatial and the Virtual Earth map control &#8211; 2"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=723"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/723\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}