svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / request / WFSGetFeatureRequest.java @ 40769
History | View | Annotate | Download (4.96 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.remoteclient.wfs.request; |
25 |
|
26 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
27 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
28 |
import org.gvsig.remoteclient.wfs.WFSRequestInformation; |
29 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
30 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
31 |
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding; |
32 |
|
33 |
/**
|
34 |
* The GetFeature operation allows retrieval of features from a
|
35 |
* web feature service. A GetFeature request is processed by
|
36 |
* a WFS and when the value of the outputFormat attribute is
|
37 |
* set to text/gml a GML instance document, containing the
|
38 |
* result set, is returned to the client.
|
39 |
* @see http://www.opengeospatial.org/standards/wfs
|
40 |
* @author Jorge Piera Llodrá (jorge.piera@iver.es)
|
41 |
*/
|
42 |
public abstract class WFSGetFeatureRequest extends WFSRequest{ |
43 |
|
44 |
public WFSGetFeatureRequest(WFSStatus status,
|
45 |
WFSProtocolHandler protocolHandler) { |
46 |
super(status, protocolHandler);
|
47 |
} |
48 |
|
49 |
/*
|
50 |
* (non-Javadoc)
|
51 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpPostRequest(java.lang.String)
|
52 |
*/
|
53 |
protected String getHttpPostRequest(String onlineResource) { |
54 |
StringBuffer request = new StringBuffer(); |
55 |
request.append(WFSTTags.XML_ROOT); |
56 |
request.append("<" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
57 |
request.append(CapabilitiesTags.WFS_GETFEATURE + " ");
|
58 |
request.append(CapabilitiesTags.VERSION + "=\"" + protocolHandler.getVersion() + "\" "); |
59 |
request.append(WFSTTags.WFST_SERVICE + "=\"WFS\" ");
|
60 |
if (status.getMaxFeatures().longValue() > 0){ |
61 |
request.append(CapabilitiesTags.MAXFEATURES + "=\"" + status.getMaxFeatures() + "\" "); |
62 |
} |
63 |
if (status.getResultType() == WFSStatus.RESULTYPE_HITS){
|
64 |
request.append(WFSTTags.WFS_RESULTTYPE + "=\"" + WFSTTags.WFS_HITS + "\" "); |
65 |
} |
66 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.OGC_NAMESPACE_PREFIX);
|
67 |
request.append("=\"" + WFSTTags.OGC_NAMESPACE + "\" "); |
68 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.WFS_NAMESPACE_PREFIX);
|
69 |
request.append("=\"" + WFSTTags.WFS_NAMESPACE + "\" "); |
70 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.XML_NAMESPACE_PREFIX);
|
71 |
request.append("=\"" + WFSTTags.XML_NAMESPACE + "\" "); |
72 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.GML_NAMESPACE_PREFIX);
|
73 |
request.append("=\"" + WFSTTags.GML_NAMESPACE + "\" "); |
74 |
request.append(WFSTTags.XMLNS + ":" + status.getNamespacePrefix());
|
75 |
request.append("=\"" + status.getNamespaceLocation() + "\" "); |
76 |
request.append(WFSTTags.XML_NAMESPACE_PREFIX + ":" + WFSTTags.XML_SCHEMALOCATION);
|
77 |
request.append("=\"" + WFSTTags.WFS_NAMESPACE + " "); |
78 |
request.append(getSchemaLocation()); |
79 |
request.append("\">");
|
80 |
request.append("<" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
81 |
request.append(WFSTTags.WFS_QUERY); |
82 |
request.append(" typeName=\"" + status.getFeatureFullName() + "\""); |
83 |
request.append(">");
|
84 |
if ((status.getFilterByAttribute() != null) || (status.getFilterByArea() != null)){ |
85 |
FilterEncoding filterEncoding = new FilterEncoding(status);
|
86 |
request.append(filterEncoding.toString(protocolHandler.getVersion())); |
87 |
} |
88 |
request.append("</" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
89 |
request.append(WFSTTags.WFS_QUERY); |
90 |
request.append(">");
|
91 |
request.append("</" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
92 |
request.append(CapabilitiesTags.WFS_GETFEATURE + ">");
|
93 |
return request.toString();
|
94 |
} |
95 |
|
96 |
/*
|
97 |
* (non-Javadoc)
|
98 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getOperationCode()
|
99 |
*/
|
100 |
protected String getOperationName() { |
101 |
return CapabilitiesTags.WFS_GETFEATURE;
|
102 |
} |
103 |
|
104 |
/*
|
105 |
* (non-Javadoc)
|
106 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getSchemaLocation()
|
107 |
*/
|
108 |
protected String getSchemaLocation() { |
109 |
return null; |
110 |
} |
111 |
|
112 |
/*
|
113 |
* (non-Javadoc)
|
114 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getTempFilePrefix()
|
115 |
*/
|
116 |
protected String getTempFilePrefix() { |
117 |
return "wfs_getFeature.gml"; |
118 |
} |
119 |
|
120 |
/*
|
121 |
* (non-Javadoc)
|
122 |
* @see org.gvsig.remoteclient.wfs.request.WFSRequest#createRequestInformation()
|
123 |
*/
|
124 |
public WFSRequestInformation createRequestInformation() {
|
125 |
return new WFSGetFeatureRequestInformation(); |
126 |
} |
127 |
|
128 |
|
129 |
} |