AGSMapResource agsMap = ((AGSMapResource)webContext.getResources().get("ags1"));//获得数据源,配置文件中有声明
MapServerPort mapServer = agsMap.getMapServer();
//生成查询对象
EnvelopeN env = new EnvelopeN(extent.getMinX(), extent.getMinY(), extent.getMaxX(), extent.getMaxY(),null, null, null, null, null);
SpatialFilter spatialFilter = new SpatialFilter();
spatialFilter.setSpatialRel(EsriSpatialRelEnum.esriSpatialRelIntersects);
spatialFilter.setWhereClause("");
spatialFilter.setSearchOrder(EsriSearchOrder.esriSearchOrderSpatial);
spatialFilter.setSpatialRelDescription("");
spatialFilter.setGeometryFieldName("");
spatialFilter.setFilterGeometry(env);
try{
int layerId = 1;//查询的土层,ID号配置文件中有声明
this.countedFeatures = mapServer.queryFeatureCount(mapServer.getDefaultMapName(), layerId, spatialFilter);
System.out.println("你选择了 "+countedFeatures+" 要素");
}catch(RemoteException rme){
throw new ADFAGSException("Could not execute MapServer::queryFeatureCount()",rme);
}
Interface MapServerPort常用的方法:
mapServer.getDefaultMapName() 获得默认地图名
mapServer.queryFeatureCount(String mapName , int layerId ,SpatialFilter sf) return int 获得指定图层查询到的要素总数
mapServer.queryFeatureData(String mapName , int layerId ,SpatialFilter sf) return RecordSet 获得指定图层查询到的要素集(包含所有属性字段)
mapServer.getDefaultMapName() return String 返回默认地图名称
mapServer.hasLayerCache(String mapName, int layerID) return bool 返回指定图层是否是缓存图层
转载于: http://leo43.blog.hexun.com/p9/default.aspx