Draw a line from a point by giving an angle and distance to next point

5356
7
Jump to solution
04-04-2017 03:36 AM
PranavMS
New Contributor II

I want to know how can i draw another line which respect of one point means we have first plotted a point  'a' on map. Then i know the next point's'b'  distance and angle to the point 'a'

My question is how can i draw that line between these two points 'a' and 'b'.  And this process may continued till get my polygon .

If my shape of polygon is triangle.

Initial i know the first point. Then i plot that point in map. At the same same it should pop up the box to ask the angle and distance to next point.(it is possible to display that popup) 
Then i fill the boxes and submit it . Then It should draw the line form first point to next one based on given distance and angle.
Then it again pop up the same box to asking the angle and distance of next point

Now we know the third point is same as the first point. so it should draw this as a polygon .

I think you people got my idea . Please suggest me some libraries or some way to achieve this process.

Thanks advance.
Pranav MS

0 Kudos
1 Solution

Accepted Solutions
AlexanderNohe1
Occasional Contributor III

It looks like most of your questions were already answered on that site.  For your third question, I am wondering if you had trouble with the moveGeodesic method?  I am running the latest version of the runtime and this worked flawlessly for me:

public class MainActivity extends AppCompatActivity {

    ArcGISMap arcGISMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        final MapView mapView = (MapView) findViewById(R.id.mapView);
        arcGISMap = new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS, 0,0,10);
        mapView.setMap(arcGISMap);

        //This section can be customized for your needs.  This is how I was able to move the point from an existing point
        Point point = new Point(0,0,SpatialReferences.getWebMercator());
        GraphicsOverlay go = new GraphicsOverlay(GraphicsOverlay.RenderingMode.DYNAMIC);
        mapView.getGraphicsOverlays().add(go);
        Symbol sms = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 15);
        go.getGraphics().add(new Graphic(point, sms));
        LinearUnit meters = new LinearUnit(LinearUnitId.METERS);
        AngularUnit ag = new AngularUnit(AngularUnitId.DEGREES);
        Point point1 = GeometryEngine.moveGeodetic(point, 100000, meters, 15.00, ag, GeodeticCurveType.GEODESIC);
        mapView.getGraphicsOverlays().get(0).getGraphics().add(new Graphic(point1, sms));
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

7 Replies
AlexanderNohe1
Occasional Contributor III

Hello Pranav MS‌,

You could build a view in android with two edit texts that let you take the distance and angle.  From there, you could plug this into the GeometryEngine's moveGeodetic method and this should return a new point from the starting point which you can then use to build your polygon.  You can then put this returned points into a point collection and when you press finish (ButtonView wired by you) you can return a Polygon by passing the point collection into a PolygonBuilder ( PolygonBuilder| arcgis-android ).

I hope this helps!

Thanks,

Alexander 

PranavMS
New Contributor II

Thank you for your help.Let me check the references that you given. 

0 Kudos
PranavMS
New Contributor II

Dear sir, 

I have tried but the package examples are not  updated one...

While im trying this im getting some issues to import the files. It shows it is not available . The online examples except GitHub, all are  which are present in our official site. Every examples may have some class import issues. Can you please give me some refrences to develop an android app in arcgis run time sdk . I am new in this field.

Please help me sir,

0 Kudos
AlexanderNohe1
Occasional Contributor III

Based upon the links that you sent, I believe that you are working from 10.2.x version of the runtime rather than version 100.  With that, you should be able to use the Geodesic Move method and build a point array which you can then use to build a polygon.  If you are looking for resources to learn the ArcGIS Android Runtime API, I would encourage you to visit this site for 10.2.x: ArcGIS Runtime SDK for Android | ArcGIS for Developers 

And this site for runtime verison 100:

ArcGIS Runtime SDK for Android | ArcGIS for Developers 

Runtime version 100 is the newer of the two APIs and it is recommended that if you are building a new application to start with this version of the runtime.

PranavMS
New Contributor II

Dear sir ,

Thanks for your references and advice.Appreciate your kindness.  I am also referring these sites only. But my issue is something what different. Please have look at below links this will describe what i am looking for.

  1. ArcGIS Runtime SDK for Android how to get the lat and long of point - Geographic Information Systems... 
  2. java - ArcGIS Runtime SDK for Android map rotate across the north direction on click button - Geogra... 
  3. Calculating new point coordinates from distance and angle using ArcGIS Runtime SDK for Android? - Ge... 

Sorry i am really new in this field that's why i am asking all these . Sorry .

0 Kudos
AlexanderNohe1
Occasional Contributor III

It looks like most of your questions were already answered on that site.  For your third question, I am wondering if you had trouble with the moveGeodesic method?  I am running the latest version of the runtime and this worked flawlessly for me:

public class MainActivity extends AppCompatActivity {

    ArcGISMap arcGISMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        final MapView mapView = (MapView) findViewById(R.id.mapView);
        arcGISMap = new ArcGISMap(Basemap.Type.LIGHT_GRAY_CANVAS, 0,0,10);
        mapView.setMap(arcGISMap);

        //This section can be customized for your needs.  This is how I was able to move the point from an existing point
        Point point = new Point(0,0,SpatialReferences.getWebMercator());
        GraphicsOverlay go = new GraphicsOverlay(GraphicsOverlay.RenderingMode.DYNAMIC);
        mapView.getGraphicsOverlays().add(go);
        Symbol sms = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.RED, 15);
        go.getGraphics().add(new Graphic(point, sms));
        LinearUnit meters = new LinearUnit(LinearUnitId.METERS);
        AngularUnit ag = new AngularUnit(AngularUnitId.DEGREES);
        Point point1 = GeometryEngine.moveGeodetic(point, 100000, meters, 15.00, ag, GeodeticCurveType.GEODESIC);
        mapView.getGraphicsOverlays().get(0).getGraphics().add(new Graphic(point1, sms));
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
PranavMS
New Contributor II

Dear sir,

Thank you. It is really helps me to draw .

Thanks alot.

0 Kudos