一个spatialReference引发的血案


    实现功能:用QueryTask类似拉框查询
本机环境:ArcGIS Server10.0、FlexViewer 2.4
正式环境:ArcGIS Server9.3、 FlexViewer 2.4
代码:
//假设graphicsExtent是拉框得到的范围
						var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
						if (graphicsExtent)
						{
							
							
							var query2:Query = new Query();
							query2.returnGeometry = true;
							query2.geometry = graphicsExtent.extent;
							query2.outSpatialReference = map.spatialReference;

							
							var queryTask:QueryTask = new QueryTask();
							queryTask.url = logicMapQueryAddress2;
							queryTask.useAMF = false;
							queryTask.showBusyCursor = true;
							queryTask.execute(query2, new AsyncResponder(onResul2, onFault2));
							
							function onResul2(featureSet:FeatureSet, token:Object = null):void
							{
								if (featureSet.features.length == 0)
								{
									Alert.show("Please try again.");
								}
								else
								{
									trace(featureSet.features);
									var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
									map.extent = graphicsExtent.expand(1.5);
									globalCache.putData("initExtent",graphicsExtent);
								}
								mapExtentLock.lock(map);
							}
							function onFault2(info:Object, token:Object = null):void
							{
								Alert.show(info.toString());
							}
							
						}

这样在本机环境没有错误,但在正式环境就会报错,错误信息:[RPC Fault faultString="Cannot perform query. Invalid query parameters." faultCode="500" faultDetail="inSR param is invalid: {"wkt":"PROJCS[\"XiAn80\",GEOGCS[\"XiAn80\",DATUM[\"D_XiAn_1980\",SPHEROID[\"GRS_1980_China\",6378140.0,298.257]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Gauss_Kruger\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",117.0],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]"}"]
是由于空间参考问题引起的,最后解决方法:代码如下:
var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
						if (graphicsExtent)
						{
							[b]var xmi:Number = graphicsExtent.extent.xmin;
							var ymi:Number = graphicsExtent.extent.ymin;
							var xma:Number = graphicsExtent.extent.xmax;
							var yma:Number = graphicsExtent.extent.ymax;
							var newExtent:Extent = new Extent(xmi,ymi,xma,yma);[/b]
							
							var query2:Query = new Query();
							query2.returnGeometry = true;
						[b]query2.geometry = newExtent.extent;[/b]
							
							var queryTask:QueryTask = new QueryTask();
							queryTask.url = logicMapQueryAddress2;
							queryTask.useAMF = false;
							queryTask.showBusyCursor = true;
							queryTask.execute(query2, new AsyncResponder(onResul2, onFault2));
							
							function onResul2(featureSet:FeatureSet, token:Object = null):void
							{
								if (featureSet.features.length == 0)
								{
									Alert.show("Please try again.");
								}
								else
								{
									trace(featureSet.features);
									var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
									map.extent = graphicsExtent.expand(1.5);
									globalCache.putData("initExtent",graphicsExtent);
								}
								mapExtentLock.lock(map);
							}
							function onFault2(info:Object, token:Object = null):void
							{
								Alert.show(info.toString());
							}
							
						}

 

你可能感兴趣的:(java,工作)