using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Mobile;
namespace USTC
{
public class ArcMobileTool
{
private ESRI.ArcGIS.Mobile.Map map1;
public ArcMobileTool(Map map)
{
this.map1 = map;
}
///
/// 得到矩形区域内的包含所选图层的图元
///
/// 所选图层
/// 矩形左上点
/// 矩形右下点
///
public FeatureLayerDataTable GetFeature(FeatureLayer featureLayer, Coordinate m_startCoordinate, Coordinate m_endCoordinate)
{
Envelope envelope = new Envelope(m_startCoordinate, m_endCoordinate);
// Retrieves the first layer in the map
//FeatureLayer featureLayer = map1.MapLayers[0].Layer as FeatureLayer;
if (featureLayer == null)
return null;
// Creates a instance of a query filter. Query filter uses the dragged map rectangle and
// it will search for all features in layer index = 0, that are contained in this geometry.
QueryFilter spatialQueryFilter = new QueryFilter(envelope, EsriGeometricRelationship.Contain);
// Querying the feature layer
FeatureLayerDataTable featureLayerDataTable = featureLayer.GetDataTable(spatialQueryFilter);
return featureLayerDataTable;
}
public FeatureDataReader GetDataReader(FeatureLayer featureLayer, Coordinate m_startCoordinate, Coordinate m_endCoordinate)
{
Envelope envelope = new Envelope(m_startCoordinate, m_endCoordinate);
// Retrieves the first layer in the map
//FeatureLayer featureLayer = map1.MapLayers[0].Layer as FeatureLayer;
if (featureLayer == null)
return null;
// Creates a instance of a query filter. Query filter uses the dragged map rectangle and
// it will search for all features in layer index = 0, that are contained in this geometry.
QueryFilter spatialQueryFilter = new QueryFilter(envelope, EsriGeometricRelationship.Contain);
// Querying the feature layer
FeatureDataReader featureLayerDataTable = featureLayer.GetDataReader(spatialQueryFilter, null);
return featureLayerDataTable;
/*
* while (reader.Read())
{
// Retrieves the feature抯 geometry
geometry = reader.GetGeometry();
if (geometry != null)
// If geometry is valid, the map will rendered once for 100 milliseconds.
map1.FlashGeometry(Pens.Red, (SolidBrush)Brushes.Yellow, 15, 100, 1, geometry);
}
*/
}
///
/// 根据SQL语句的WHERE条件查询
///
/// 所选图层
/// where条件
///
public FeatureLayerDataTable GetFeature(FeatureLayer featureLayer, string whereClause)
{
if (featureLayer == null)
return null;
// Creates a where clause string.
// Use % or * to find a string that contains an a character
//string whereClause = featureLayer.DisplayColumnName + " like '%a%'";
// Creates a instance of a query filter. Query filter uses the dragged map rectangle and
// it will search for all features in layer index = 0, that are contained in this geometry.
QueryFilter queryFilter = new QueryFilter(whereClause, true);
// Querying the feature layer
FeatureLayerDataTable featureLayerDataTable = featureLayer.GetDataTable(queryFilter);
return featureLayerDataTable;
}
public FeatureDataReader GetDataReader(FeatureLayer featureLayer, string whereClause)
{
if (featureLayer == null)
return null;
QueryFilter queryFilter = new QueryFilter(whereClause, true);
Geometry geometry = null;
// Querying the feature layer
FeatureDataReader reader = featureLayer.GetDataReader(queryFilter, null);
return reader;
/*
* while (reader.Read())
{
// Retrieves the feature抯 geometry
geometry = reader.GetGeometry();
if (geometry != null)
// If geometry is valid, the map will rendered once for 100 milliseconds.
map1.FlashGeometry(Pens.Red, (SolidBrush)Brushes.Yellow, 15, 100, 1, geometry);
}
*/
}
///
/// 创建点
///
///
///
public Point CreatePoint(double dx, double dy)
{
// Creates a new instance of a Point using some lat/lon coordinates
// Latitud value
//double dx = 34.058247;
// Longitud value
//double dy = -117.198104;
// Converts a WSD84 coordinate to a Mobile coordinate
Coordinate coordinate = map1.MapCache.SpatialReference.Wgs84ToMobileGeometry(dx, dy);
// Creates a new instance of a point at a given coordinate
ESRI.ArcGIS.Mobile.Point m_point = new ESRI.ArcGIS.Mobile.Point(coordinate);
return m_point;
}
}
}
本文介绍了一个基于ArcGIS Mobile的地图查询工具类,该工具提供多种方法来检索地图中的特征数据,包括根据矩形区域、SQL语句条件等进行查询。
1047

被折叠的 条评论
为什么被折叠?



