ポイントにおける検索 - Java の例
この Java の例では、Search at Point 呼び出しを実行するために Feature Service を呼び出します。ポリゴンを持つテーブルに対して使用する場合、Search at Point は Point In Polygon メソッドです。
Feature サービスにアクセスするためのスタブ クラスを生成するには、スタブ コードの生成を参照してください。
import com.mapinfo.midev.service.feature.v1.SearchAtPointRequest;
import com.mapinfo.midev.service.feature.v1.SearchAtPointResponse;
import com.mapinfo.midev.service.feature.ws.v1.FeatureService;
import com.mapinfo.midev.service.feature.ws.v1.FeatureServiceInterface;
import com.mapinfo.midev.service.feature.ws.v1.ServiceException;
import com.mapinfo.midev.service.geometries.v1.Point;
import com.mapinfo.midev.service.geometries.v1.Pos;
import com.mapinfo.midev.service.table.v1.NamedTable;
import com.mapinfo.midev.service.table.v1.Table;
import javax.xml.ws.BindingProvider;
import java.util.Map;
public final class FeatureServiceSample {
// username with the authority to call the Feature service
private static final String USERNAME = "admin";
// password of the caller
private static final String PASSWORD = "admin";
public static void main(String[] args) throws ServiceException {
// get the endpoint class
FeatureServiceInterface featureServiceInterface = new FeatureService().getFeatureServiceInterface();
// if authentication is enabled in Spectrum then the following is required
Map<String, Object> requestContext = ((BindingProvider)featureServiceInterface).getRequestContext();
requestContext.put(BindingProvider.USERNAME_PROPERTY, USERNAME);
requestContext.put(BindingProvider.PASSWORD_PROPERTY, PASSWORD);
// start assembling the request
SearchAtPointRequest searchAtPointRequest = new SearchAtPointRequest();
// create the search point
{
Point point = new Point();
point.setSrsName("epsg:4326");
Pos pos = new Pos();
pos.setX(-75.66);
pos.setY(47.88);
point.setPos(pos);
searchAtPointRequest.setPoint(point);
}
// set the named table
{
NamedTable table = new NamedTable();
table.setName("/Samples/NamedTables/USA");
searchAtPointRequest.setTable(table);
}
// send the request
SearchAtPointResponse searchAtPointResponse = featureServiceInterface.searchAtPoint(searchAtPointRequest);
// do what you want with the response ...
}
}