<?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: Geometry Engine functions for middlePoint and bearing? in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121251#M346</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark!&lt;BR /&gt;This should do the work, I was just wondering if the arcgis java lib had something more out of the box solution like a function call with two points parameter.&lt;/P&gt;&lt;P&gt;Thanks for the time to answer my post!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Oct 2020 11:29:09 GMT</pubDate>
    <dc:creator>RafaelFreitas</dc:creator>
    <dc:date>2020-10-08T11:29:09Z</dc:date>
    <item>
      <title>Geometry Engine functions for middlePoint and bearing?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121249#M344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community, &lt;BR /&gt;&lt;BR /&gt;I am currently working with lines on a Java application that requires some geometry processing such the bearing of this line and also the midpoint.&lt;BR /&gt;I was browsing the API and couldn't find any implementation of those by myself. There are functions for this that I am missing?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Oct 2020 11:17:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121249#M344</guid>
      <dc:creator>RafaelFreitas</dc:creator>
      <dc:date>2020-10-06T11:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Engine functions for middlePoint and bearing?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121250#M345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure there are many ways of achieving this but I've found the following works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So lets start with a line and draw it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080;"&gt;// create a purple (0xFF800080) simple line symbol
&lt;/SPAN&gt;SimpleLineSymbol lineSymbol = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;SimpleLineSymbol(SimpleLineSymbol.Style.&lt;SPAN style="color: #9876aa;"&gt;DASH&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;0xFF800080&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// create a new point collection for polyline
&lt;/SPAN&gt;PointCollection points = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;PointCollection(SpatialReferences.&lt;SPAN&gt;getWebMercator&lt;/SPAN&gt;())&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// create and add points to the point collection
&lt;/SPAN&gt;points.add(&lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Point(-&lt;SPAN style="color: #6897bb;"&gt;302232.417504&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;7570568.626755&lt;/SPAN&gt;))&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;points.add(&lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Point(-&lt;SPAN style="color: #6897bb;"&gt;294306.469759&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;7574158.422559&lt;/SPAN&gt;))&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// create the polyline from the point collection
&lt;/SPAN&gt;Polyline polyline = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Polyline(points)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// create the graphic with polyline and symbol
&lt;/SPAN&gt;Graphic graphicLine = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Graphic(polyline&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;lineSymbol)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;graphicsOverlay.getGraphics().add(graphicLine)&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Then we get the mid point in 2 steps.&amp;nbsp; First, you find the length then draw a point along the line at a distance of half that length:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080;"&gt;// get start and end points
&lt;/SPAN&gt;Point startPoint = polyline.getParts().get(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;).getStartPoint()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;Point endPoint = polyline.getParts().get(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;).getEndPoint()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// get the length in metres
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;double &lt;/SPAN&gt;length = GeometryEngine.&lt;SPAN&gt;distanceBetween&lt;/SPAN&gt;(startPoint&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;endPoint)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// use the length to get the mid point
&lt;/SPAN&gt;Point midPoint = GeometryEngine.&lt;SPAN&gt;createPointAlong&lt;/SPAN&gt;(polyline&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;length/&lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// draw the mid point
&lt;/SPAN&gt;SimpleMarkerSymbol sms = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;SimpleMarkerSymbol(SimpleMarkerSymbol.Style.&lt;SPAN style="color: #9876aa;"&gt;CIRCLE&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;0xFF00FF00&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;10&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;Graphic intersectGraphic = &lt;SPAN style="color: #cc7832;"&gt;new &lt;/SPAN&gt;Graphic(midPoint&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sms)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;graphicsOverlay.getGraphics().add(intersectGraphic)&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calculating the bearing can be done using basic geometry, but note this will only work with a projected coordinate system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080;"&gt;// working out the bearing of the line.
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;double &lt;/SPAN&gt;xDiff = endPoint.getX() - startPoint.getX()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;double &lt;/SPAN&gt;yDiff = endPoint.getY() - startPoint.getY()&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;// get the angle
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;double &lt;/SPAN&gt;angleRad = Math.&lt;SPAN&gt;atan&lt;/SPAN&gt;(xDiff/ yDiff)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;double &lt;/SPAN&gt;angleDeg = Math.&lt;SPAN&gt;toDegrees&lt;/SPAN&gt;(angleRad)&lt;SPAN style="color: #cc7832;"&gt;;
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;System.&lt;SPAN style="color: #9876aa;"&gt;out&lt;/SPAN&gt;.println(&lt;SPAN style="color: #6a8759;"&gt;"angle " &lt;/SPAN&gt;+ angleDeg)&lt;SPAN style="color: #cc7832;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:01:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121250#M345</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2021-12-11T07:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Engine functions for middlePoint and bearing?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121251#M346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark!&lt;BR /&gt;This should do the work, I was just wondering if the arcgis java lib had something more out of the box solution like a function call with two points parameter.&lt;/P&gt;&lt;P&gt;Thanks for the time to answer my post!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2020 11:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121251#M346</guid>
      <dc:creator>RafaelFreitas</dc:creator>
      <dc:date>2020-10-08T11:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Engine functions for middlePoint and bearing?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121252#M347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rafael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the bearing calculation there isn't a method which takes 2 points.&amp;nbsp; I can however see the value in it so we may consider if for a future release.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the meantime my method should work, but the calculation will only be correct for project coordinate systems and over small distances to be accurate.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad this helped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2020 15:36:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/geometry-engine-functions-for-middlepoint-and/m-p/121252#M347</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2020-10-09T15:36:02Z</dc:date>
    </item>
  </channel>
</rss>

