Geometric relationships in ArcGIS Mobile

Geometric relationships are one of the key fundamentals of GIS. After knowing where and what something (a feature) is, knowing what it is near is critical. While the ArcGIS Mobile system does not provide the functionality to do geoprocessing tasks, like finding all the overlapping features in a layer, we do have the ability to do it for a single feature. The geometric relationships are used as part of the queryfilter to extract the proper features from the selected layer.

The code below shows how easy it is to create a queryfilter and set the relationship type.

if(listBox3.SelectedItem.Equals(GeometricRelationshipType.Any))
  m_filter = new QueryFilter(m_layer.Geometry,GeometricRelationshipType.Any); 
if (listBox3.SelectedItem.Equals(GeometricRelationshipType.Contain))
  m_filter = new QueryFilter(m_layer.Geometry, GeometricRelationshipType.Contain);
if(listBox3.SelectedItem.Equals(GeometricRelationshipType.Cross))
  m_filter = new QueryFilter(m_layer.Geometry,GeometricRelationshipType.Cross);
if(listBox3.SelectedItem.Equals(GeometricRelationshipType.Disjoint))
  m_filter = new QueryFilter(m_layer.Geometry,GeometricRelationshipType.Disjoint);
if (listBox3.SelectedItem.Equals(GeometricRelationshipType.Intersect))
  m_filter = new QueryFilter(m_layer.Geometry, GeometricRelationshipType.Intersect);
if (listBox3.SelectedItem.Equals(GeometricRelationshipType.Overlap))
  m_filter = new QueryFilter(m_layer.Geometry, GeometricRelationshipType.Overlap);
if (listBox3.SelectedItem.Equals(GeometricRelationshipType.Touch))
  m_filter = new QueryFilter(m_layer.Geometry, GeometricRelationshipType.Touch);
if(listBox3.SelectedItem.Equals(GeometricRelationshipType.Within))
  m_filter = new QueryFilter(m_layer.Geometry, GeometricRelationshipType.Within);

Once the queryfilter is created using a geometry sketched on the screen and the relationship selected, the code to perform the operation is very simple as shown below.

FeatureDataTable m_table = mobileCache1.FeatureLayers[listBox1.SelectedIndex].GetDataTable(m_filter);
dataGridView1.DataSource = m_table;

Where to get the sample

The sample is available for download from here.


9/20/2011