<?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: Transform a Point into a Polygon (Square) in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1027228#M5431</link>
    <description>&lt;P&gt;You will find it much easier if you convert your point which you want as the centre of your square into a projected coordinate system.&amp;nbsp; Once you've done that you can offset in metres from the location and things are much easier to understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;              SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF00FF00, 3); 
              // a point in a field near London, UK
              wgs84Point = new Point(0,51, SpatialReferences.getWgs84());

              // convert wgs84 (lat / long) into projected coordinate system
              Point wmPoint = (Point) GeometryEngine.project(wgs84Point, SpatialReferences.getWebMercator());

              // size of your square in metres
              double size = 100;

              // easier logic for point of square with offsets in metres
              Point p1 = new Point(wmPoint.getX() + (size / 2), wmPoint.getY() + (size /2), SpatialReferences.getWebMercator());
              Point p2 = new Point(wmPoint.getX() + (size / 2), wmPoint.getY() - (size /2), SpatialReferences.getWebMercator());
              Point p3 = new Point(wmPoint.getX() - (size / 2), wmPoint.getY() - (size /2), SpatialReferences.getWebMercator());
              Point p4 = new Point(wmPoint.getX() - (size / 2), wmPoint.getY() + (size /2), SpatialReferences.getWebMercator());

              // make polygon from points
              PointCollection pointCollection = new PointCollection(SpatialReferences.getWebMercator());
              pointCollection.add(p1);
              pointCollection.add(p2);
              pointCollection.add(p3);
              pointCollection.add(p4);

              Polygon square = new Polygon(pointCollection);

              // Graphic and add to graphics overlay to display it
              Graphic squareGraphic = new Graphic(square, simpleLineSymbol);
              graphicsOverlay.getGraphics().add(squareGraphic);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not a pretty bit of code, but it should point you in the right direction.&lt;/P&gt;&lt;P&gt;Does this help&lt;/P&gt;</description>
    <pubDate>Tue, 16 Feb 2021 17:40:05 GMT</pubDate>
    <dc:creator>MarkBaird</dc:creator>
    <dc:date>2021-02-16T17:40:05Z</dc:date>
    <item>
      <title>Transform a Point into a Polygon (Square)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1027175#M5430</link>
      <description>&lt;P&gt;Hello.&amp;nbsp;I am having trouble&amp;nbsp; to implementing a new functionality in my application.&lt;/P&gt;&lt;P&gt;Based on a point (latitude and longitude),&amp;nbsp; I want that this point automatically transform into a square, with this lat and long as the center. I'm trying something like this to transform the point:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;double &lt;/SPAN&gt;ang__ = &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;double &lt;/SPAN&gt;co_x1 = (&lt;SPAN&gt;sin&lt;/SPAN&gt;(&lt;SPAN&gt;toRadians&lt;/SPAN&gt;(ang__ + &lt;SPAN&gt;90&lt;/SPAN&gt;)) * &lt;SPAN&gt;widthImplement&lt;/SPAN&gt;) + point.getX()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;double &lt;/SPAN&gt;co_y1 = (&lt;SPAN&gt;cos&lt;/SPAN&gt;(&lt;SPAN&gt;toRadians&lt;/SPAN&gt;(ang__ + &lt;SPAN&gt;90&lt;/SPAN&gt;)) * &lt;SPAN&gt;widthImplement&lt;/SPAN&gt;) + point.getY()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;double &lt;/SPAN&gt;co_x2 = (&lt;SPAN&gt;sin&lt;/SPAN&gt;(&lt;SPAN&gt;toRadians&lt;/SPAN&gt;(ang__ + &lt;SPAN&gt;270&lt;/SPAN&gt;)) * &lt;SPAN&gt;widthImplement&lt;/SPAN&gt;) + point.getX()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;double &lt;/SPAN&gt;co_y2 = (&lt;SPAN&gt;cos&lt;/SPAN&gt;(&lt;SPAN&gt;toRadians&lt;/SPAN&gt;(ang__ + &lt;SPAN&gt;270&lt;/SPAN&gt;)) * &lt;SPAN&gt;widthImplement&lt;/SPAN&gt;) + point.getY()&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;But it's not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone already done something like that?&lt;BR /&gt;Note: I would like to present width options for this square on the screen.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 15:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1027175#M5430</guid>
      <dc:creator>GuilhermeFernandes</dc:creator>
      <dc:date>2021-02-16T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Transform a Point into a Polygon (Square)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1027228#M5431</link>
      <description>&lt;P&gt;You will find it much easier if you convert your point which you want as the centre of your square into a projected coordinate system.&amp;nbsp; Once you've done that you can offset in metres from the location and things are much easier to understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;              SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF00FF00, 3); 
              // a point in a field near London, UK
              wgs84Point = new Point(0,51, SpatialReferences.getWgs84());

              // convert wgs84 (lat / long) into projected coordinate system
              Point wmPoint = (Point) GeometryEngine.project(wgs84Point, SpatialReferences.getWebMercator());

              // size of your square in metres
              double size = 100;

              // easier logic for point of square with offsets in metres
              Point p1 = new Point(wmPoint.getX() + (size / 2), wmPoint.getY() + (size /2), SpatialReferences.getWebMercator());
              Point p2 = new Point(wmPoint.getX() + (size / 2), wmPoint.getY() - (size /2), SpatialReferences.getWebMercator());
              Point p3 = new Point(wmPoint.getX() - (size / 2), wmPoint.getY() - (size /2), SpatialReferences.getWebMercator());
              Point p4 = new Point(wmPoint.getX() - (size / 2), wmPoint.getY() + (size /2), SpatialReferences.getWebMercator());

              // make polygon from points
              PointCollection pointCollection = new PointCollection(SpatialReferences.getWebMercator());
              pointCollection.add(p1);
              pointCollection.add(p2);
              pointCollection.add(p3);
              pointCollection.add(p4);

              Polygon square = new Polygon(pointCollection);

              // Graphic and add to graphics overlay to display it
              Graphic squareGraphic = new Graphic(square, simpleLineSymbol);
              graphicsOverlay.getGraphics().add(squareGraphic);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not a pretty bit of code, but it should point you in the right direction.&lt;/P&gt;&lt;P&gt;Does this help&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 17:40:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1027228#M5431</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2021-02-16T17:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Transform a Point into a Polygon (Square)</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1028455#M5436</link>
      <description>&lt;P&gt;Thank you so much Mark. Worked perfectly.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 12:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/transform-a-point-into-a-polygon-square/m-p/1028455#M5436</guid>
      <dc:creator>GuilhermeFernandes</dc:creator>
      <dc:date>2021-02-19T12:40:48Z</dc:date>
    </item>
  </channel>
</rss>

