public class QueryService extends ServiceBase
构造器和说明 |
---|
QueryService(java.lang.String url)
通过一个URL构造一个查询服务。
|
限定符和类型 | 方法和说明 |
---|---|
void |
query(ServiceQueryParameter param, QueryMode mode)
对Rest服务进行查询。
|
void |
query(java.lang.String fullUrl, ServiceQueryParameter param, QueryMode mode)
对Rest地图服务进行查询。
|
getResponseCallback, getUrl, setResponseCallback, setServerName, setUrl
public void query(ServiceQueryParameter param, QueryMode mode)
param
- 查询参数。mode
- 查询模式。public void ServiceQuery() { //假设http://192.168.170.59:8090地址服务器上已发布地图Rest服务,服务名称为map-testmap/rest,该地图服务中包含地图map,地图中含有 图层Capitals@testmap。 QueryService service = new QueryService("http://192.168.170.59:8090"); ServiceQueryParameter parameter = new ServiceQueryParameter(); parameter.setQueryMapName("map"); parameter.setQueryServiceName("map-testmap/rest"); parameter.setQueryLayerName("Capitals@testmap"); parameter.setExpectRecordCount(2000); parameter.setQueryRecordStart(0); parameter.setQueryOption(QueryOption.ATTRIBUTEANDGEOMETRY); parameter.setAttributeFilter("SMID>0"); service.setResponseCallback(new ResponseCallback() { @Override public void requestSuccess() { // TODO Auto-generated method stub System.out.println("查询requestSuccess"); } @Override public void requestFailed(String arg0) { // TODO Auto-generated method stub System.out.println("查询requestFailed"); } @Override public void receiveResponse(FeatureSet arg0) { // TODO Auto-generated method stub System.out.println("查询receiveResponse"); if (arg0 instanceof FeatureSet) { FeatureSet featureSet = (FeatureSet)arg0; featureSet.moveFirst(); while (!featureSet.isEOF()) { Geometry geo = featureSet.getGeometry(); if (geo == null) { featureSet.moveNext(); continue; } featureSet.moveNext(); } System.out.println("要素集合中要素的个数是 " + featureSet.getFeatureCount()); } } }); service.query(parameter, QueryMode.SqlQuery); }
public void query(java.lang.String fullUrl, ServiceQueryParameter param, QueryMode mode)
fullUrl
- 地图服务的全地址 :如:http://192.168.120.1:8090/iserver/services/map-world/rest/maps/World。param
- 查询参数。mode
- 查询模式。