<?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: Estimating a location using triangulation, JavaScript in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/estimating-a-location-using-triangulation/m-p/1609472#M62260</link>
    <description>&lt;P&gt;I figured this out and am posting it here for anyone else who might be attempting to get Survey123 to estimate a location based on triangulation.&amp;nbsp; This is a fairly common thing to do in wildlife radiotelemetry surveys.&amp;nbsp; Note, as this requires JavaScript, this can only be implemented by a user that is signed in to the same organization as where the form originated.&amp;nbsp; (An ESRI imposed security limitation.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using `pulldata('@javascript', 'triangulate.js', 'triangulate', ${location1}, ${azimuth1}, ...)` does not work. This approach assumes positional arguments in JavaScript but Survey123 passes only one JSON object.&amp;nbsp; The key step was using a calculate field named 'json_input' with bind::type=string to concat the latitudes, longitudes, and azimuths that are used by the script to estimate the actual location.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attaching both the xlsform and the javascript file (zipped).&amp;nbsp; Certainly interested in any feedback on this approach!&amp;nbsp; Thanks. -- Greg&lt;/P&gt;</description>
    <pubDate>Sat, 26 Apr 2025 14:19:49 GMT</pubDate>
    <dc:creator>GregoryLipps1</dc:creator>
    <dc:date>2025-04-26T14:19:49Z</dc:date>
    <item>
      <title>Estimating a location using triangulation, JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/estimating-a-location-using-triangulation/m-p/1608693#M62220</link>
      <description>&lt;P class=""&gt;I've attempted to build a Survey123 form that calculates an estimated transmitter location using triangulation based on azimuths and GPS points from 3–5 observer positions. Each observer records:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;A geopoint (their current location)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;An azimuth (direction of strongest signal via radio telemetry)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;The goal was to estimate:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Latitude &amp;amp; longitude of the signal source&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Error radius based on variance between intersections&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;In the XLSForm, I used a repeat group to collect observer location + azimuth, then constructed a triplet_string like lat,long,az | lat,long,az| ...&amp;nbsp; This string was passed to a JavaScript function using:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;pulldata("@javascript", "triangulate.js", "triangulateFromRepeat", ${triplet_string}, 0)&lt;/LI-CODE&gt;&lt;P&gt;The trinagulate.js script included:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;parent.triangulateFromRepeat = function(inputString) {
  return [estimatedLat, estimatedLon, errorRadius];
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I tried defining test functions with static return values and packaged a minimal test form which confirmed that Survey123 could see the script but not invoke any function inside it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Despite following Esri's documented pattern (parent.functionName = ...), Survey123 Connect (v3.22.49) consistently returned:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;@javascript error: TypeError: Property 'functionName' of object [object Object] is not a function&lt;/LI-CODE&gt;&lt;P class=""&gt;This occurred with m&lt;SPAN&gt;ultiple valid JS definitions, a&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;stripped-down test form, and with c&lt;/SPAN&gt;&lt;SPAN&gt;lean scripts with no syntax errors.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Are functions defined with parent.functionName = ...&amp;nbsp;not accessible?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Any thoughts on how to estimate a location using triangulation using multiple points and azimuths&amp;nbsp;&lt;EM&gt;inside&lt;/EM&gt; of Survey123?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2025 20:36:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/estimating-a-location-using-triangulation/m-p/1608693#M62220</guid>
      <dc:creator>GregoryLipps1</dc:creator>
      <dc:date>2025-04-23T20:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating a location using triangulation, JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/estimating-a-location-using-triangulation/m-p/1609472#M62260</link>
      <description>&lt;P&gt;I figured this out and am posting it here for anyone else who might be attempting to get Survey123 to estimate a location based on triangulation.&amp;nbsp; This is a fairly common thing to do in wildlife radiotelemetry surveys.&amp;nbsp; Note, as this requires JavaScript, this can only be implemented by a user that is signed in to the same organization as where the form originated.&amp;nbsp; (An ESRI imposed security limitation.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using `pulldata('@javascript', 'triangulate.js', 'triangulate', ${location1}, ${azimuth1}, ...)` does not work. This approach assumes positional arguments in JavaScript but Survey123 passes only one JSON object.&amp;nbsp; The key step was using a calculate field named 'json_input' with bind::type=string to concat the latitudes, longitudes, and azimuths that are used by the script to estimate the actual location.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attaching both the xlsform and the javascript file (zipped).&amp;nbsp; Certainly interested in any feedback on this approach!&amp;nbsp; Thanks. -- Greg&lt;/P&gt;</description>
      <pubDate>Sat, 26 Apr 2025 14:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/estimating-a-location-using-triangulation/m-p/1609472#M62260</guid>
      <dc:creator>GregoryLipps1</dc:creator>
      <dc:date>2025-04-26T14:19:49Z</dc:date>
    </item>
  </channel>
</rss>

