<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to convert sqlgeometry to esri geometry in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211154#M5258</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would it work for either of you to create a QueryLayer in a MXD and publish that as a Map Service?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the doc for a Query Layer in v10 - &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000000n000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000000n000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Apr 2011 17:04:03 GMT</pubDate>
    <dc:creator>TerryGiles</dc:creator>
    <dc:date>2011-04-19T17:04:03Z</dc:date>
    <item>
      <title>how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211148#M5252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;do we have any method to convert sqlgeometry to esri geometry? anyone pls help me&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jan 2011 13:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211148#M5252</guid>
      <dc:creator>SolidSmoke</dc:creator>
      <dc:date>2011-01-31T13:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211149#M5253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What I had to do in a previous project was :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Query the desired geometries in SQL, using&amp;nbsp; a function that returns the geometry as&amp;nbsp; Well-Known Text (WKT). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In MSSQL the function is &lt;/SPAN&gt;&lt;STRONG&gt;STAsText&lt;/STRONG&gt;&lt;SPAN&gt; function. &lt;/SPAN&gt;&lt;STRONG&gt;"Select STAsText(geometryColumn) as geometry from geometrydatabase;"&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Use a WKT parser to create an object from the query results. Then convert the WKT parsed object to an ESRI.Arcgis.Client.Geometry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used a WKT parser that is part of the &lt;/SPAN&gt;&lt;A href="http://sharpmap.codeplex.com/" rel="nofollow noopener noreferrer" target="_blank"&gt;SharpMap&lt;/A&gt;&lt;SPAN&gt; Framework. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ObservableCollection&amp;lt;ESRI.ArcGIS.Client.Geometry.Geometry&amp;gt; geometryList= new ObservableCollection&amp;lt;ESRI.ArcGIS.Client.Geometry.Geometry&amp;gt;();


foreach(string polygon in sqlStringPolygons) 
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SharpMap.Geometries.Geometry wktGeom = SharpMap.Converters.WellKnownText.GeometryFromWKT.Parse(polygon); 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Esri.ArcGIS.Client.Geometry.Geometry geom = sharp2esriGeometry(wktGeom);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geomtryList.Add(geom);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sharp2esriGeometry would be where the actual conversion takes place, points in the WKT converter would be converted to ESRI MapPoints. Also make sure everything is in the right projection for display purposes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alot of overhead, and I'm sure there are other (better?) ways to do this, but it has worked for me in the past.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211149#M5253</guid>
      <dc:creator>DaveRabrun</dc:creator>
      <dc:date>2021-12-11T10:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211150#M5254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would recommend against using WKT. Parsing it is a huge overhead. It's MUCH faster to parse WKB, not to mention building a parser for it is much simpler. First converting from SqlGeometry, to String, back to numbers, populate a SharpMap geometry, then re-create the geometry as ESRI geometry is quite an overhead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The simplest approach is to use the SqlGeometry classes directly in your project, and parse those directly into ESRI geometry. That way you only will have one conversion., don't have to mess with Well-known-* or other geometry libraries.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Worst case, SharpMap is open source, so you could just take the SharpMap.Converters.WellKnownText.GeometryFromWKT and tweak it to return ESRI geometry instead (or even better use it's WKB classes). That shouldn't be much work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Still I recommend using SqlGeometry directly, instead of converting to WKT/B).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jan 2011 16:41:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211150#M5254</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2011-01-31T16:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211151#M5255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;actually i'm new to these stuff and need your help to parse SqlGeometry directly into ESRI geometry. if you can give me a sample code, that wud be very helpfull. thanx in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Feb 2011 03:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211151#M5255</guid>
      <dc:creator>SolidSmoke</dc:creator>
      <dc:date>2011-02-01T03:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211152#M5256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry I don't have anything at hand here. I just know it can be done. The best you can do is first get your head around how SqlGeometry works and how it represents points, lines and polygons (MSDN has lots of doc on this). Then do the same for ESRI Geometry. When you got your head around those two things, it should be fairly straightforward for you to do.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Feb 2011 16:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211152#M5256</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2011-02-01T16:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211153#M5257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How can I use SQL geometries directly in a silverlight app? Didn't think Microsoft.SqlServer.Types was supported in SL.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Apr 2011 13:53:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211153#M5257</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2011-04-19T13:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211154#M5258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would it work for either of you to create a QueryLayer in a MXD and publish that as a Map Service?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's the doc for a Query Layer in v10 - &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000000n000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000000n000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Apr 2011 17:04:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211154#M5258</guid>
      <dc:creator>TerryGiles</dc:creator>
      <dc:date>2011-04-19T17:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert sqlgeometry to esri geometry</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211155#M5259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This might not have been available in 2011, but in case anyone else runs across this thread... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SqlGeometry sqlGeo = (SqlGeometry)myReader["SHAPE"];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IGeometryFactory factory = new GeometryEnvironmentClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IGeometry geom = new PolygonClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;int countout;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;factory.CreateGeometryFromWkbVariant(sqlGeo.STAsBinary().Value, out geom, out countout);&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 13:13:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-convert-sqlgeometry-to-esri-geometry/m-p/211155#M5259</guid>
      <dc:creator>NickG</dc:creator>
      <dc:date>2014-06-25T13:13:01Z</dc:date>
    </item>
  </channel>
</rss>

