Finding out whether lat/long position within Polygon.

463
2
10-15-2019 02:13 PM
Jose_Renato_deMelo
New Contributor
I am working on a system that will work offline, so I exported my map data to a geodatabase.

I need to check if the GPS coordinate is within a polygon of my geodatabase and return the record table of that polygon.

Below is the code snippet that reads my geodatabase:

I am working on a system that will work offline, so I exported my map data to a geodatabase.

I need to check if the GPS coordinate is within a polygon of my geodatabase and return the record table of that polygon.

Below is the code snippet that reads my geodatabase:

private void loadGeodatabase() { String path; path = Environment.getExternalStorageDirectory().getPath() + "/gdbuam.geodatabase"; final Geodatabase geodatabase = new Geodatabase(path); Log.d("GEO", path); geodatabase.loadAsync(); geodatabase.addDoneLoadingListener( () -> { if(geodatabase.getLoadStatus() == LoadStatus.LOADED){ GeodatabaseFeatureTable table = geodatabase.getGeodatabaseFeatureTableByServiceLayerId(0); System.out.println("Nome da tabela: " + table.getTableName()); }else{ Toast.makeText(Screen_Pre_Certificado_Tractor.this, "Erro ao carregar!!!!", Toast.LENGTH_LONG).show(); } });}
0 Kudos
2 Replies
Kae_WoeiKang
New Contributor II

Hi Jose, 

I am facing the same issue. I have several polygons drew on map; and I have a long press MotionEvent. The user will need to long press on of the polygon, and my software have to identify if the coordinate is lying within which polygon. 

Have you successfully resolve this issue? It would be great if you able to share the solution.

Thanks!

My issue's thread:

identify if Point within Polygon 

0 Kudos
Kae_WoeiKang
New Contributor II

GeometryEngine.contains static method - GeometryEngine (ArcGIS Runtime SDK for Android 100.7.0) able to serve the purpose of verifying. 

boolean isContain = GeometryEngine.contains(p, ltLn);

0 Kudos