<?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: Help using NormalizeCentralMeridian (or spanning the antimeridian) in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1457411#M12704</link>
    <description>&lt;P&gt;Thanks - really appreciate that. I'm having 2 difficult problems, and NormalizeCentralMeridian seems to be doing nothing.&lt;/P&gt;&lt;P&gt;1. I have a simple rectangular box spanning the antimeridian. Can't split it in two with&amp;nbsp;NormalizeCentralMeridian.&lt;/P&gt;&lt;P&gt;2. And then I have the mother of all meridian problems. I have a polygon enclosing Antarctica. Need to split that in two as well.&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2024 12:15:40 GMT</pubDate>
    <dc:creator>MarcHillman</dc:creator>
    <dc:date>2024-05-13T12:15:40Z</dc:date>
    <item>
      <title>Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1204342#M11275</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I'm trying to display some geometries that span the antimeridian in a WPF app. Ultimately, the geometries will be pulled from a map service, but I have a simple rectangle polygon that I'm testing with. This seems to be a pretty common issue, and I've read through all of the examples that I could find. Most of the examples I've seen are using the JS API, and I'm having trouble getting the same results in the .Net SDK.&lt;/P&gt;&lt;P data-unlink="true"&gt;The working JS example here (&lt;A href="https://codepen.io/andygup/pen/QeyerP" target="_blank" rel="noopener"&gt;https://codepen.io/andygup/pen/QeyerP&lt;/A&gt;) appears to call geodesicUtils.geodesicDensify() to resolve the issue. I didn't see any reference to NormalizeCentralMeridian() in this example, like I've seen in other examples. Porting that to .Net didn't work, though.&lt;/P&gt;&lt;P&gt;This example converts to WebMercator then uses NormalizeCentralMeridian() (&lt;A href="https://jsbin.com/xegicih/2/edit?html,output" target="_blank"&gt;https://jsbin.com/xegicih/2/edit?html,output&lt;/A&gt;), but again is in JS.&lt;/P&gt;&lt;P&gt;This post (&lt;A href="https://community.esri.com/t5/arcgis-runtime-sdk-for-net-questions/polyline-not-crossing-international-dateline/td-p/496299" target="_blank"&gt;https://community.esri.com/t5/arcgis-runtime-sdk-for-net-questions/polyline-not-crossing-international-dateline/td-p/496299&lt;/A&gt;) is in .Net and suggested adding 360 to the negative western longitudes. Doing this will put a box in the correct place, but with an extra line at 180 degrees. The JS examples don't have this issue.&lt;/P&gt;&lt;P&gt;Can the .Net SDK display a geometry the same way as the JS examples?&lt;/P&gt;&lt;P&gt;Here is a sample of the code I've been working with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void addGraphic(Geometry.Geometry geometry)
  {
    SimpleLineSymbol outlineSymbol = 
      new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Green, 2);
    Geometry.PointCollection points = 
      new Geometry.PointCollection(SpatialReferences.Wgs84)
      {
        new MapPoint(-178, -5),
        new MapPoint(-178, 5),
        new MapPoint(178, 5),
        new MapPoint(178, -5)
      };

      Polygon polygon = new Polygon(points);
      Geometry.Geometry g = GeometryEngine.NormalizeCentralMeridian(polygon);
      esriMap.SetViewpointGeometryAsync(g, 50);

      Graphic graphic = new Graphic(g, outlineSymbol);
      _overlay.Graphics.Add(graphic);
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's how I tried adding 360 to the longitudes. That got me a bit closer, but still not what I was looking for:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void addGraphic(Geometry.Geometry geometry)
  {
    SimpleLineSymbol outlineSymbol = 
      new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Green, 2);
    Geometry.PointCollection points = 
      new Geometry.PointCollection(SpatialReferences.Wgs84)
      {
        new MapPoint(-178, -5),
        new MapPoint(-178, 5),
        new MapPoint(178, 5),
        new MapPoint(178, -5)
      };

      Polygon polygon = new Polygon(points);
      Polygon newPoly;
      Geometry.PointCollection newPoints = 
        new Geometry.PointCollection(SpatialReferences.Wgs84);
      
      foreach (ReadOnlyPart gp in polygon.Parts)
      {
        foreach (MapPoint pt in gp.Points)
          {
            double x = pt.X;
            if(x&amp;lt;0){ x += 360; }
            newPoints.Add(new MapPoint(x, pt.Y));
          } 
       }
            newPoly = new Polygon(newPoints);
            //this puts a box in the correct place, 
            //but has an extra vertical line at 180
            esriMap.SetViewpointGeometryAsync(newPoly.Extent, 50);
            Graphic graphic = new Graphic(newPoly, outlineSymbol);
            _overlay.Graphics.Add(graphic);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 21:53:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1204342#M11275</guid>
      <dc:creator>MattH</dc:creator>
      <dc:date>2022-08-18T21:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1454645#M12702</link>
      <description>&lt;P&gt;I have EXACTLY the same problem (although I'm coding in VB.NET). Did you ever get an answer? When I apply NormalizeCentralMeridian to my polygon, nothing happens. I don't get two polygons returned.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 04:46:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1454645#M12702</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2024-05-13T04:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1457334#M12703</link>
      <description>&lt;P&gt;Would you believe that I can't remember? I usually post updates if I find answers, so it's possible that I just had to move on.&lt;/P&gt;&lt;P&gt;I'll dig through my old project this afternoon, and see if I can find it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 12:03:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1457334#M12703</guid>
      <dc:creator>MattH</dc:creator>
      <dc:date>2024-05-13T12:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1457411#M12704</link>
      <description>&lt;P&gt;Thanks - really appreciate that. I'm having 2 difficult problems, and NormalizeCentralMeridian seems to be doing nothing.&lt;/P&gt;&lt;P&gt;1. I have a simple rectangular box spanning the antimeridian. Can't split it in two with&amp;nbsp;NormalizeCentralMeridian.&lt;/P&gt;&lt;P&gt;2. And then I have the mother of all meridian problems. I have a polygon enclosing Antarctica. Need to split that in two as well.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2024 12:15:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1457411#M12704</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2024-05-13T12:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1473530#M12707</link>
      <description>&lt;P&gt;This problem is REALLY bugging me. I can't see what I'm doing wrong. I have written a minimal code example. It creates a linestring (using a polylinebuilder) that crosses the Antimeridian (it's a box around Fiji). It is 1 part with 5 points. I then apply&amp;nbsp;NormalizeCentralMeridian to it to produce "normal".&amp;nbsp; normal is identical to linestring.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        Dim plb As New PolylineBuilder(SpatialReferences.Wgs84)       ' drawn bounding box
        plb.AddPoint(New MapPoint(177.17, -19.25))       ' first point
        plb.AddPoint(New MapPoint(-179.65, -19.25))
        plb.AddPoint(New MapPoint(-179.65, -15.67))
        plb.AddPoint(New MapPoint(177.17, -15.67))
        plb.AddPoint(New MapPoint(177.17, -19.25))       ' last point

        Dim linestring = plb.ToGeometry
        AppendText(TextBox1, $"Before {linestring.ToString}{vbCrLf}")
        Dim normal = linestring.NormalizeCentralMeridian
        AppendText(TextBox1, $"After {normal.ToString}{vbCrLf}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output of test program shows NormalizeCentralMeridian is having no effect&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Before Polyline[Parts=1, Points=5, Wkid=4326]
After Polyline[Parts=1, Points=5, Wkid=4326]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 05:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1473530#M12707</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2024-05-16T05:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1473885#M12709</link>
      <description>&lt;P&gt;I have a fix, but I'm not why it's valid. If I have a polygon that spans the antimeridian, I simply add 360 to any -ve X value. NormalizeCentralMeridian then does what you'd expect. I'm not sure I fully understand why, but at least I have a solution.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 14:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1473885#M12709</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2024-05-16T14:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1473964#M12712</link>
      <description>&lt;P&gt;Do you have a snippet of code that you could post? That sounds like what I was trying, but I'm still getting an additional line along the antimeridian.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="snip.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/104385i930709D26BABA0F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snip.PNG" alt="snip.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 16:09:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1473964#M12712</guid>
      <dc:creator>MattH</dc:creator>
      <dc:date>2024-05-16T16:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help using NormalizeCentralMeridian (or spanning the antimeridian)</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1474526#M12713</link>
      <description>&lt;P&gt;Below is the code I currently use. It works in almost all cases.&lt;/P&gt;&lt;P&gt;1. If you have a polygon spanning the antimeridian, it produces the desired result - the polygon is split into pieces. I have a box around Fiji, and I can render it no problem.&lt;/P&gt;&lt;P&gt;2. I also have a polygon that encircles the South Pole. This code is splitting the polygon into 3 pieces, but it is not rendering properly. All the signs on the X's in the 3 pieces are the same, so they look sensible.&lt;/P&gt;&lt;P&gt;The code works by testing for antimeridian crossing (CrossesAntiMeridian) and if it does then&lt;/P&gt;&lt;P&gt;1. deconstruct the polygon into a polygonbuilder so we can modify it&lt;/P&gt;&lt;P&gt;2. Add 360 to every X that is less than 0 in every part&lt;/P&gt;&lt;P&gt;3. Rebuild the polygon from the polygonbuilder&lt;/P&gt;&lt;P&gt;4. Use NormalizeCentralMeridian&lt;/P&gt;&lt;P&gt;5. Use Simplify as results of&amp;nbsp;NormalizeCentralMeridian seem to leave polygons that are not Simple&lt;/P&gt;&lt;P&gt;As I said, it seems to be working for 'standard' cases where a pole is not involved, but it seems to breakdown at the poles.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    Function CrossesAntiMeridian(g As Geometry) As Boolean
        ' returns true if geometry crosses anti-meridian
        Return Math.Abs(g.Extent.XMax - g.Extent.XMin) &amp;gt; 300
    End Function
    Function NormalizeCentralMeridian(PolyBox As Polygon) As Polygon
        ' Normalize a polygon if it crosses the anti-meridian
        If CrossesAntiMeridian(PolyBox) Then       '  crosses anti-meridian
            With PolyBox.Extent
                Dim plb As New PolygonBuilder(PolyBox)        ' deconstruct polygon to polygon builder
                ' Add 360 to any negative X value in any part
                For prt = 0 To plb.Parts.Count - 1
                    For pnt = 0 To plb.Parts(prt).Points.Count - 1
                        If plb.Parts(prt).Points(pnt).X &amp;lt; 0 Then
                            plb.Parts(prt).SetPoint(pnt, New MapPoint(plb.Parts(prt).Points(pnt).X + 360, plb.Parts(prt).Points(pnt).Y, plb.SpatialReference))   ' add 360 to X
                        End If
                    Next
                Next
                Dim poly = plb.ToGeometry               ' reconstruct geometry
                Dim Normalized As Polygon = poly.NormalizeCentralMeridian   ' split geometry into parts that don't cross the antimeridian
                Normalized = Normalized.Simplify        ' Normalizing seems to produce a non simple result
                Return Normalized
            End With
        Else
            Return PolyBox       ' doesn't cross anti-meridian
        End If
    End Function&lt;/LI-CODE&gt;&lt;P&gt;Below&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 13:39:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/help-using-normalizecentralmeridian-or-spanning/m-p/1474526#M12713</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2024-05-17T13:39:22Z</dc:date>
    </item>
  </channel>
</rss>

