<?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: Convert Polygon to DbGeography in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210985#M11321</link>
    <description>&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was checking the code but its for convert to Microsoft.Spatial and i dont know what more to do to convert to System.Data.Entity.Spatial.DbGeography. Please help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 23:20:07 GMT</pubDate>
    <dc:creator>AlexVelez</dc:creator>
    <dc:date>2022-09-08T23:20:07Z</dc:date>
    <item>
      <title>Convert Polygon to DbGeography</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210952#M11318</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I need to convert a polygon geometry to&amp;nbsp;System.Data.Entity.Spatial.DbGeography , I have been trying to do with something like that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; StringBuilder text = new StringBuilder();
                string firstPoint = string.Empty, textToAppend;
                var parts = ((Polygon)(geometry)).Parts;
                for (int i = 0; i &amp;lt; parts[0].Points.Count; i++)
                {
                    var normalizedPoint = GeometryEngine.NormalizeCentralMeridian(parts[0].Points[i]);
                    var projectedCenter = GeometryEngine.Project(normalizedPoint, SpatialReferences.Wgs84) as MapPoint;
                    textToAppend = $"{projectedCenter.X} {projectedCenter.Y}";
                    textToAppend= textToAppend.Replace(',', '.');
                    textToAppend = $"{textToAppend},";
                    text.Append(textToAppend);
                    if (string.IsNullOrWhiteSpace(firstPoint))
                    {
                        firstPoint = $"{projectedCenter.X} {projectedCenter.Y}";
                        firstPoint = firstPoint.Replace(',', '.');
                    }
                }
                text.Append(firstPoint);
             var dbGeography=DbGeography.PolygonFromText($"POLYGON(({text}))", 4326);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And it works, but when i saved it to a SQL database on a column of type Geography, it does not work correctly.&lt;/P&gt;&lt;P&gt;What is the correct way to achieve this?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 21:17:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210952#M11318</guid>
      <dc:creator>AlexVelez</dc:creator>
      <dc:date>2022-09-08T21:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Polygon to DbGeography</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210959#M11319</link>
      <description>&lt;P&gt;You're better off going through the geometry builders than going through WKT which would be extremely slow. Perhaps this code snippet here will help:&amp;nbsp;&lt;A href="https://github.com/dotMorten/GeometryConversions/blob/master/src/GeometryConversions.Shared/System.Spatial/SystemSpatialConverter.CreateGeography.cs" target="_blank"&gt;https://github.com/dotMorten/GeometryConversions/blob/master/src/GeometryConversions.Shared/System.Spatial/SystemSpatialConverter.CreateGeography.cs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 21:41:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210959#M11319</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2022-09-08T21:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Polygon to DbGeography</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210985#M11321</link>
      <description>&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was checking the code but its for convert to Microsoft.Spatial and i dont know what more to do to convert to System.Data.Entity.Spatial.DbGeography. Please help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 23:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1210985#M11321</guid>
      <dc:creator>AlexVelez</dc:creator>
      <dc:date>2022-09-08T23:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Polygon to DbGeography</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1211018#M11325</link>
      <description>&lt;P&gt;I don't know EF too well, but browsing their code it looks like it's just a wrapper around other spatial libraries, and there's some sort of provider that might give you access to the underlying sql geometry libraries.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 02:38:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/convert-polygon-to-dbgeography/m-p/1211018#M11325</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2022-09-09T02:38:48Z</dc:date>
    </item>
  </channel>
</rss>

