<?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: How is Geofence calculated? in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279553#M2698</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/675410"&gt;@GeraldLim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't see enough of the app to see what it is doing.&amp;nbsp; You are correct, there is a loop which iterates over the mLatLngs which is a collection of points, but the code only shows an empty collection defined.&lt;/P&gt;&lt;P&gt;I don't know what your app is used for to attempt to guess why it is drawing multiple circles.&amp;nbsp; Can you describe the use-case?&lt;/P&gt;&lt;P&gt;I'm happy to help, but I need more context about that your app does and the problem you are trying to solve.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2023 07:47:11 GMT</pubDate>
    <dc:creator>MarkBaird</dc:creator>
    <dc:date>2023-04-18T07:47:11Z</dc:date>
    <item>
      <title>How is Geofence calculated?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279147#M2691</link>
      <description>&lt;P&gt;I took over a project recently and already implemented a set of codes to calculate the geofence area and draw. I have difficulty in understand this set of codes. Could anyone explain to me, how is the geofence being calculated; what is the diameter, what coordinates are needed to draw etc?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is there any guide to which I could refer?&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;static final double &lt;/SPAN&gt;&lt;SPAN&gt;EARTH_RADIUS_X &lt;/SPAN&gt;= &lt;SPAN&gt;6378137.0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;static final double &lt;/SPAN&gt;&lt;SPAN&gt;EARTH_RADIUS_Y &lt;/SPAN&gt;= &lt;SPAN&gt;6356752.3142&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;final &lt;/SPAN&gt;List&amp;lt; Polygon &amp;gt; &lt;SPAN&gt;mGeoFences &lt;/SPAN&gt;= &lt;SPAN&gt;new &lt;/SPAN&gt;ArrayList&amp;lt;&amp;gt;()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;final &lt;/SPAN&gt;List&amp;lt; Point &amp;gt; &lt;SPAN&gt;mLatLngs &lt;/SPAN&gt;= &lt;SPAN&gt;new &lt;/SPAN&gt;ArrayList&amp;lt;&amp;gt;()&lt;SPAN&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;void &lt;/SPAN&gt;&lt;SPAN&gt;drawGeoFence&lt;/SPAN&gt;() {&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;final &lt;/SPAN&gt;GraphicsOverlay overlay = &lt;SPAN&gt;map_view&lt;/SPAN&gt;.getGraphicsOverlays().get( &lt;SPAN&gt;0 &lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; for&lt;/SPAN&gt;( &lt;SPAN&gt;final &lt;/SPAN&gt;Point point : &lt;SPAN&gt;mLatLngs &lt;/SPAN&gt;) {&lt;BR /&gt;&lt;SPAN&gt;mMap&lt;/SPAN&gt;.addPointToDetermine1stTimeZoom( point )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;lat = point.getY()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;lng = point.getX()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; &lt;SPAN&gt;mGeoFences&lt;/SPAN&gt;.add( drawCircle( overlay.getGraphics()&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;mThreshold&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;lat&lt;SPAN&gt;, &lt;/SPAN&gt;lng&lt;SPAN&gt;, false &lt;/SPAN&gt;) )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; drawCircle( overlay.getGraphics()&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;lat&lt;SPAN&gt;, &lt;/SPAN&gt;lng&lt;SPAN&gt;, true &lt;/SPAN&gt;)&lt;SPAN&gt;; &lt;/SPAN&gt;&lt;SPAN&gt;// center point&lt;BR /&gt;&lt;/SPAN&gt; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Polygon &lt;SPAN&gt;drawCircle&lt;/SPAN&gt;( &lt;SPAN&gt;final &lt;/SPAN&gt;List&amp;lt; Graphic &amp;gt; graphics&lt;SPAN&gt;, final float &lt;/SPAN&gt;radius&lt;SPAN&gt;, final double &lt;/SPAN&gt;lat&lt;SPAN&gt;, final double &lt;/SPAN&gt;lng&lt;SPAN&gt;, boolean &lt;/SPAN&gt;isCenter ) {&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;final &lt;/SPAN&gt;Point point = &lt;SPAN&gt;new &lt;/SPAN&gt;Point( lng&lt;SPAN&gt;, &lt;/SPAN&gt;lat&lt;SPAN&gt;, &lt;/SPAN&gt;SpatialReferences.&lt;SPAN&gt;getWgs84&lt;/SPAN&gt;() )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final &lt;/SPAN&gt;PointCollection c = &lt;SPAN&gt;new &lt;/SPAN&gt;PointCollection( SpatialReferences.&lt;SPAN&gt;getWgs84&lt;/SPAN&gt;() )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;centerX = point.getX()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;centerY = point.getY()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final int &lt;/SPAN&gt;pointsCount = &lt;SPAN&gt;360&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;slice = Math.&lt;SPAN&gt;PI &lt;/SPAN&gt;/ &lt;SPAN&gt;180.0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;dX = radius / &lt;SPAN&gt;EARTH_RADIUS_X &lt;/SPAN&gt;/ slice&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;dY = radius / ( &lt;SPAN&gt;EARTH_RADIUS_Y &lt;/SPAN&gt;* Math.&lt;SPAN&gt;cos&lt;/SPAN&gt;( lat * slice ) ) / slice&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; for&lt;/SPAN&gt;( &lt;SPAN&gt;int &lt;/SPAN&gt;i = &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;; &lt;/SPAN&gt;i &amp;lt;= pointsCount&lt;SPAN&gt;; &lt;/SPAN&gt;i++ ) {&lt;BR /&gt;&lt;SPAN&gt;final double &lt;/SPAN&gt;r = slice * i&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;x = centerX + dX * Math.&lt;SPAN&gt;cos&lt;/SPAN&gt;( r )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final double &lt;/SPAN&gt;y = centerY + dY * Math.&lt;SPAN&gt;sin&lt;/SPAN&gt;( r )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; c.add( x&lt;SPAN&gt;, &lt;/SPAN&gt;y )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;final &lt;/SPAN&gt;Polygon polygon&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; try &lt;/SPAN&gt;{&lt;BR /&gt;polygon = &lt;SPAN&gt;new &lt;/SPAN&gt;Polygon( c )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; } &lt;SPAN&gt;catch&lt;/SPAN&gt;( &lt;SPAN&gt;final &lt;/SPAN&gt;Throwable e ) {&lt;BR /&gt;AdvancedLog.&lt;SPAN&gt;e&lt;/SPAN&gt;( e )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; PopUp.&lt;SPAN&gt;showErrorMsgDialog&lt;/SPAN&gt;( &lt;SPAN&gt;this, &lt;/SPAN&gt;PopUp.&lt;SPAN&gt;getListenerFinishActivity&lt;/SPAN&gt;( &lt;SPAN&gt;this &lt;/SPAN&gt;)&lt;SPAN&gt;, &lt;/SPAN&gt;R.string.&lt;SPAN&gt;msg_invalid_asset_location_data &lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; return null;&lt;BR /&gt;&lt;/SPAN&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;final &lt;/SPAN&gt;SimpleFillSymbol fillSymbols = &lt;SPAN&gt;new &lt;/SPAN&gt;SimpleFillSymbol( SimpleFillSymbol.Style.&lt;SPAN&gt;SOLID&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt; isCenter ? Color.&lt;SPAN&gt;RED &lt;/SPAN&gt;: &lt;SPAN&gt;red_transparent&lt;/SPAN&gt;&lt;SPAN&gt;, null &lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; graphics.add( &lt;SPAN&gt;new &lt;/SPAN&gt;Graphic( polygon&lt;SPAN&gt;, &lt;/SPAN&gt;fillSymbols ) )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final &lt;/SPAN&gt;Polyline polyline = &lt;SPAN&gt;new &lt;/SPAN&gt;Polyline( c )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; final &lt;/SPAN&gt;SimpleLineSymbol lineSymbol = &lt;SPAN&gt;new &lt;/SPAN&gt;SimpleLineSymbol( SimpleLineSymbol.Style.&lt;SPAN&gt;SOLID&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;Color.&lt;SPAN&gt;RED&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;1 &lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; graphics.add( &lt;SPAN&gt;new &lt;/SPAN&gt;Graphic( polyline&lt;SPAN&gt;, &lt;/SPAN&gt;lineSymbol ) )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; graphics.add( &lt;SPAN&gt;new &lt;/SPAN&gt;Graphic( point ) )&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; return &lt;/SPAN&gt;polygon&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 07:23:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279147#M2691</guid>
      <dc:creator>GeraldLim</dc:creator>
      <dc:date>2023-04-17T07:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How is Geofence calculated?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279182#M2692</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/675410"&gt;@GeraldLim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at the code I can see:&lt;/P&gt;&lt;P&gt;&amp;nbsp;- You are using a Graphics Overlay on a MapView.&amp;nbsp; A Graphics Overlay is a container for Graphics which are for drawing points, line or polygons which persist in memory for the lifetime of your application&lt;/P&gt;&lt;P&gt;- The method drawCircle creates a polygon which has a number of vertices dependant on the radius.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;- When you draw the polygon as a graphic you are using a SimpleFillSymbol to define the fill of your polygon and a SimpleLineSymbol to define the outline of the polygon.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is some documentation about graphics overlays &lt;A href="https://developers.arcgis.com/java/maps-2d/add-graphics-to-a-map-view/" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp; There is a &lt;A href="https://developers.arcgis.com/java/maps-2d/tutorials/add-a-point-line-and-polygon/" target="_self"&gt;tutorial&lt;/A&gt; too which you can follow which will take you through the basics.&lt;/P&gt;&lt;P&gt;We also have a samples &lt;A href="https://github.com/Esri/arcgis-maps-sdk-java-samples/" target="_self"&gt;repository&lt;/A&gt; you can look at where there are a few samples which show graphics overlays.&amp;nbsp; This &lt;A href="https://github.com/Esri/arcgis-maps-sdk-java-samples/tree/main/display_information/add-graphics-with-symbols" target="_self"&gt;sample&lt;/A&gt; is worth looking at.&lt;/P&gt;&lt;P&gt;One observation I have about the drawCircle method is this could be simplified.&amp;nbsp; A circle is basically a buffer around a point and we have a method which does that for you.&amp;nbsp; Take a look at this &lt;A href="https://github.com/Esri/arcgis-maps-sdk-java-samples/tree/main/geometry/buffer" target="_self"&gt;sample&lt;/A&gt; which makes use of buffers and mentions geodesic buffers which are what I suspect you will need to use.&lt;/P&gt;&lt;P&gt;Does this help?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 10:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279182#M2692</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2023-04-17T10:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: How is Geofence calculated?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279550#M2697</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/48868"&gt;@MarkBaird&lt;/a&gt;, thanks for the reply.&amp;nbsp; I kinda get the buffer around a point. However, I am puzzled at why does the code do a loop over mLatLngs&amp;nbsp;&lt;SPAN&gt;and draws multiple circles. Do you have any idea on that?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 07:27:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279550#M2697</guid>
      <dc:creator>GeraldLim</dc:creator>
      <dc:date>2023-04-18T07:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: How is Geofence calculated?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279553#M2698</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/675410"&gt;@GeraldLim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't see enough of the app to see what it is doing.&amp;nbsp; You are correct, there is a loop which iterates over the mLatLngs which is a collection of points, but the code only shows an empty collection defined.&lt;/P&gt;&lt;P&gt;I don't know what your app is used for to attempt to guess why it is drawing multiple circles.&amp;nbsp; Can you describe the use-case?&lt;/P&gt;&lt;P&gt;I'm happy to help, but I need more context about that your app does and the problem you are trying to solve.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 07:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/how-is-geofence-calculated/m-p/1279553#M2698</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2023-04-18T07:47:11Z</dc:date>
    </item>
  </channel>
</rss>

