<?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: CoordinateConversion format to show DMS + elevation in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247346#M79856</link>
    <description>&lt;P&gt;Oh, you're right, there was a bug in my &lt;A href="https://codepen.io/gsoosalu/pen/xxJRjMX" target="_self"&gt;app&lt;/A&gt;. It should be fixed now, so the custom format should be shown:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GreteSoosalu_0-1673457876729.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/60216i61CDE9711CFC826D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GreteSoosalu_0-1673457876729.png" alt="GreteSoosalu_0-1673457876729.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/192881"&gt;@Leandro-Zamudio&lt;/a&gt;&amp;nbsp;for sharing the fixed code that works for you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2023 17:26:05 GMT</pubDate>
    <dc:creator>GreteSoosalu</dc:creator>
    <dc:date>2023-01-11T17:26:05Z</dc:date>
    <item>
      <title>CoordinateConversion format to show DMS + elevation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1243776#M79737</link>
      <description>&lt;P&gt;Hi, following the CoordinateConversion custom format in the documentation I've implemented the widget correctly in my 4.24 app.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeandroZamudio_0-1672151144491.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59291i89A70F98F22E5527/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeandroZamudio_0-1672151144491.png" alt="LeandroZamudio_0-1672151144491.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But now i need to show the lat/long in DMS, it's like combining these two&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeandroZamudio_1-1672151501566.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59292i8D80EF49B62C833E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeandroZamudio_1-1672151501566.png" alt="LeandroZamudio_1-1672151501566.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is my format code&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    const numberSearchPattern = /-?\d+[\.]?\d*/;
    const newFormat = new Format({
      // Nombre único e información del Formato
      name: "XYZ",
      conversionInfo: {
        convert: function (point) {
          const returnPoint = point.spatialReference.isWGS84
            ? point
            : webMercatorUtils.webMercatorToGeographic(point);
          const x = returnPoint.x.toFixed(2);
          const y = returnPoint.y.toFixed(2);
          const z = returnPoint.z.toFixed(2)/2;
          return {
            location: returnPoint,
            coordinate: `${x}, ${y}, ${z}`
          };
        },
        reverseConvert: function (string) {
          const parts = string.split(",");
          return new Point({
            x: parseFloat(parts[0]),
            y: parseFloat(parts[1]),
            z: parseFloat(parts[2]),
            spatialReference: { wkid: 4326 }
          });
        }
      },
      coordinateSegments: [
        {
          alias: "X",
          description: "Longitud",
          searchPattern: numberSearchPattern
        },
        {
          alias: "Y",
          description: "Latitud",
          searchPattern: numberSearchPattern
        },
        {
          alias: "Z",
          description: "Elevación",
          searchPattern: numberSearchPattern
        }
      ],
      defaultPattern: "X°, Y°, Zm"
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Note: The Z value is divided by 2 because the WebScene has a 2x exaggeration.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 14:42:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1243776#M79737</guid>
      <dc:creator>Leandro-Zamudio</dc:creator>
      <dc:date>2022-12-27T14:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: CoordinateConversion format to show DMS + elevation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1245982#M79793</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/192881"&gt;@Leandro-Zamudio&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In such a case, it is the best to break the coordinates already into degrees-minutes-seconds inside the &lt;FONT face="andale mono,times"&gt;conversionInfo&lt;/FONT&gt; and adjust the &lt;FONT face="andale mono,times"&gt;coordinateSegments&lt;/FONT&gt; accordingly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For pre-formatting the point's coordinates into&amp;nbsp;"40 50 02.55N 121 31 54.83W" pattern, you can use the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-coordinateFormatter.html#toLatitudeLongitude" target="_self"&gt;coordinateFormatter&lt;/A&gt; converter:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;coordinateFormatter.toLatitudeLongitude(returnPoint, "dms", 3)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Here's an example app that shows the widget with a custom DMS format with Z values:&amp;nbsp;&lt;A href="https://codepen.io/gsoosalu/pen/xxJRjMX" target="_blank" rel="noopener"&gt;https://codepen.io/gsoosalu/pen/xxJRjMX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you further.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 14:06:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1245982#M79793</guid>
      <dc:creator>GreteSoosalu</dc:creator>
      <dc:date>2023-01-06T14:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: CoordinateConversion format to show DMS + elevation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247342#M79855</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/503459"&gt;@GreteSoosalu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I watched the codepen but it doesn't show the custom coordinate format but reading the code and re-thinking it I could solve it breaking the coordinates as you suggested. For further reference I share the solution of the same code but corrected:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const newFormat = new Format({
      name: "XYZ",
      conversionInfo: {
        convert: function (point) {
          const returnPoint = point.spatialReference.isWGS84
            ? point
            : webMercatorUtils.webMercatorToGeographic(point);
          const x = Math.trunc(returnPoint.x);
          const a = Math.trunc(-(returnPoint.x-x)*60);
          const b = (-(returnPoint.x-x-(a/-60))*3600).toFixed(2);
          const y = Math.trunc(returnPoint.y);
          const c = Math.trunc(-(returnPoint.y-y)*60);
          const d = (-(returnPoint.y-y-(c/-60))*3600).toFixed(2);
          const z = returnPoint.z.toFixed(2)/2;
          //console.log(b)
          return {
            location: returnPoint,
            coordinate: `${x}, ${a}, ${b}, ${y}, ${c}, ${d}, ${z}`
          };
        },
//For now i'm not using the reverseConvert function so I left it as is
        reverseConvert: function (string) {
          const parts = string.split(",");
          return new Point({
            x: parseFloat(parts[0]),
            y: parseFloat(parts[1]),
            z: parseFloat(parts[2]),
            spatialReference: { wkid: 4326 }
          });
        }
      },
      coordinateSegments: [
        {alias: "X", description: "Longitud Grados", searchPattern: numberSearchPattern},
        {alias: "A", description: "Longitud Minutos", searchPattern: numberSearchPattern},
        {alias: "B", description: "Longitud Segundos", searchPattern: numberSearchPattern},
        {alias: "Y", description: "Latitud Grados", searchPattern: numberSearchPattern},
        {alias: "C", description: "Latitud Minutos", searchPattern: numberSearchPattern},
        {alias: "D", description: "Latitud Segundos", searchPattern: numberSearchPattern},
        {alias: "Z", description: "Elevación", searchPattern: numberSearchPattern}
      ],
      defaultPattern: "X° A\' B\", Y° C\' D\", Zm"
    });&lt;/LI-CODE&gt;&lt;P&gt;I'd like to know more about the Regular expressions that you used to find a number, is there any reference to read about it?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      // Regular expressions to find a number
      const numberSearchPattern = /-?\d+[\.]?\d*/;
      const number2Digit = /\d{1,2}[\.|\.]?\d*/i; // Same as CoordinateConversion widget's DMS format uses
      const number3Digit = /\d{1,3}[\.|\.]?\d*/i; // Same as CoordinateConversion widget's DMS format uses&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247342#M79855</guid>
      <dc:creator>Leandro-Zamudio</dc:creator>
      <dc:date>2023-01-11T17:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: CoordinateConversion format to show DMS + elevation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247346#M79856</link>
      <description>&lt;P&gt;Oh, you're right, there was a bug in my &lt;A href="https://codepen.io/gsoosalu/pen/xxJRjMX" target="_self"&gt;app&lt;/A&gt;. It should be fixed now, so the custom format should be shown:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GreteSoosalu_0-1673457876729.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/60216i61CDE9711CFC826D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GreteSoosalu_0-1673457876729.png" alt="GreteSoosalu_0-1673457876729.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/192881"&gt;@Leandro-Zamudio&lt;/a&gt;&amp;nbsp;for sharing the fixed code that works for you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 17:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247346#M79856</guid>
      <dc:creator>GreteSoosalu</dc:creator>
      <dc:date>2023-01-11T17:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: CoordinateConversion format to show DMS + elevation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247360#M79857</link>
      <description>&lt;P&gt;Regarding the Regular expressions, I cannot think of any references at the moment but if I find anything, I'll post it here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 18:02:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/coordinateconversion-format-to-show-dms-elevation/m-p/1247360#M79857</guid>
      <dc:creator>GreteSoosalu</dc:creator>
      <dc:date>2023-01-11T18:02:08Z</dc:date>
    </item>
  </channel>
</rss>

