1.國家天地圖wfs地址
getcapabilities
http://www.tianditu.com/wfssearch.shtml?request=getcapabilities&service=wfs
操作名 |
參數名 |
是否必須 |
備註 |
GetCapabilities |
VERSION |
是 |
服務版本號,支持1.0.0 |
SERVICE |
是 |
值爲“WFS” |
|
REQUEST |
是 |
值爲“GetCapabilities” |
|
DescribeFeatureType |
VERSION |
是 |
版本號,支持“1.1.0” |
REQUEST |
是 |
值爲“DescribeFeatureType” |
|
TYPENAME |
是 |
圖層列表,以“,”分割 |
|
OUTPUTFORMAT |
是 |
支持“text/xml” |
|
GetFeature |
VERSION |
是 |
版本號,支持“1.1.0” |
REQUEST |
是 |
值爲“GetFeature” |
|
TYPENAME |
是 |
圖層列表,以“,”分割 |
|
OUTPUTFORMAT |
是 |
支持“text/xml” |
|
BBOX |
否 |
請求的範圍 |
|
PROPERTYNAME |
否 |
圖層的屬性列表,以“,”分割 |
|
FILTER |
否 |
過濾條件 |
|
MAXFEATURES |
否 |
請求的最大要素記錄數 |
|
FEATUREID |
否 |
要素ID號 |
|
RESULTTYPE |
否 |
值爲“results” |
希望研究這個的大神能指導我下,求交流
下面是客服給的一個demo,注意 utf-8編碼,不然你post出去的中文會讓你找不到錯在哪裏。。。
public class Simapledemo { /** * 該程序簡單給出一個請求天地圖wfs服務的簡單市裏,請求串按字符串拼接的形式給出,XMl格式的請求可以根據給出的請求串自行生成 * 請求記錄最多支持300條 * 不支持只含有*的搜索,必須有明確的搜索關鍵詞 * 目前不支持視野內搜索,不支持統計搜索,如果需要的可以等待我們網站api出爐 * 搜索格式 全國搜索 在 <ogc:Literal>***北京 超市**</ogc:Literal> *之間只輸入關鍵字就可以 如果指定城市搜索 輸入 城市名 + “ ” +搜索關鍵字 * @param args */ public static void main(String[] args) throws Exception { try { URL url = new URL("http://www.tianditu.com/wfssearch.shtml"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setDoOutput(true); con.setRequestMethod("POST"); OutputStream out = con.getOutputStream(); String strQuest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<wfs:GetFeature maxFeatures=\"100\" service=\"WFS\" version=\"1.0.0\" xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd\" xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> " + " <wfs:Query typeName=\"DOMAIN_POI_NEW\" srsName=\"EPSG:4326\">" + "<ogc:Filter>" + "<ogc:And> " + "<ogc:PropertyIsLike wildCard=\"*\" singleChar=\".\" escape=\"!\"> " + " <ogc:PropertyName>NAME</ogc:PropertyName>" + " <ogc:Literal>***北京 超市**</ogc:Literal> " + // 請求的時候僅需要替換 超市 這個關鍵詞就好,如果指定城市搜索,搜索關鍵詞爲指定城市的名稱 加上空格要搜索的關鍵字就可以 "</ogc:PropertyIsLike>" + " </ogc:And>" + "</ogc:Filter>" + "</wfs:Query>" + "</wfs:GetFeature>"; out.write(strQuest.getBytes()); out.close(); BufferedReader br = new BufferedReader(new InputStreamReader(con .getInputStream())); String line = ""; FileWriter fw = null; fw = new FileWriter("seachresult.xml", false); for (line = br.readLine(); line != null; line = br.readLine()) { fw.write(line); System.out.println(line); } fw.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }