com.supermap.services

Class QueryService



  • public class QueryService
    extends ServiceBase
    The QueryService class Users need to set related callback setResponseCallback, which can get the operation result and server response, etc.
    • Constructor Detail

      • QueryService

        public QueryService(java.lang.String url)
        Constructs a query service by URL.
        Parameters:
        url - The specified URL.
    • Method Detail

      • query

        public void query(ServiceQueryParameter param,
                          QueryMode mode)
        Query Rest service.
        Parameters:
        param - The query parameter.
        mode - The query mode.
        Example:
        The following codes show how to query the data from the server and get the result.
         public void ServiceQuery() {
                                //Let us suppose map Rest service has been published on the address http://192.168.170.59:8090.The service name is map-testmap/rest,the map service contains the map ,
                                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("QueryrequestSuccess");
                                        }
                                                
                                        @Override
                                        public void requestFailed(String arg0) {
                                                // TODO Auto-generated method stub
                                                System.out.println("QueryrequestFailed");
                                        }
                                        
                                        @Override
                                        public void receiveResponse(FeatureSet arg0) {
                                                // TODO Auto-generated method stub
                                                System.out.println("Query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("The number of elements is" + featureSet.getFeatureCount());
                                                }                               
                                        }
                                });
                                service.query(parameter, QueryMode.SqlQuery);
            }
         
      • query

        public void query(java.lang.String fullUrl,
                          ServiceQueryParameter param,
                          QueryMode mode)
        Query Rest map service.
        Parameters:
        fullUrl - The full URL of the map service: e.g., http://192.168.120.1:8090/iserver/services/map-world/rest/maps/World.
        param - The query parameter.
        mode - The query mode.