Hello Andrea,
I have just created the Ticket GEOT-1376 for this issue.
I have attached two patches (MainModule and WFS) to it.
I am not able to assign this Ticket to you.
I have also create a patch to Ticket GEOT-1353 (Quering Date-Columns in
OracleDatastore).
I do not get any Reply to it. Do you know if this patch will be insert into
the SourceCode?
- Tim
-----Ursprüngliche Nachricht-----
Von: Andrea Aime [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 2. Juli 2007 18:13
An: Tim Englich
Cc: [email protected]
Betreff: Re: AW: AW: [Geotools-gt2-users] WFS Filter Problems using
Umlauts
Tim Englich ha scritto:
> Hello Andrea,
> for the Post-Request I use <?xml version="1.0" encoding="ISO-8859-15"?> to
> declare the encoding.
> For the Get-Request I use the URLEncoder.encode(bb, "ISO-8859-15")-Method
of
> Java to encode the url.
I see. Well, then open a Jira issue for this one, and eventually attach
a patch. If you want to try and code it, you'll have to add a parameter
in the wfs datastores factory, provide that param to the datastore, and
then down to the places where requests are encoded.
Cheers
Andrea
Index:
D:/WorkspaceGT-2.3/2.3.x/module/main/src/org/geotools/xml/DocumentWriter.java
===================================================================
---
D:/WorkspaceGT-2.3/2.3.x/module/main/src/org/geotools/xml/DocumentWriter.java
(revision 26046)
+++
D:/WorkspaceGT-2.3/2.3.x/module/main/src/org/geotools/xml/DocumentWriter.java
(working copy)
@@ -86,6 +86,12 @@
* TargetNamespaces
*/
public static final String SCHEMA_ORDER = "DocumentWriter_SCHEMA_ORDER";
+
+
+ /**
+ * The Encoding which should be used for the Document which should be
created.
+ */
+ public static final String ENCODING = "DocumentWriter_ENCODING";
// TODO implement this searchOrder
@@ -1365,11 +1371,17 @@
private Schema schema;
protected Map hints;
private Schema[] searchOrder = null;
+ private String encoding = "UTF-8";
WriterContentHandler(Schema schema, Writer writer, Map hints) {
this.writer = writer;
this.schema = schema;
this.hints = hints;
+
+ Object encodingValue = this.getHint(DocumentWriter.ENCODING);
+ if (encodingValue != null){
+ this.encoding = encodingValue.toString();
+ }
prefixMappings = new HashMap();
prefixMappings.put(schema.getTargetNamespace(), "");
@@ -1633,7 +1645,7 @@
* @see PrintHandler#startDocument()
*/
public void startDocument() throws IOException {
- writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ writer.write("<?xml version=\"1.0\" encoding=\""+encoding+"\"?>");
// TODO format here
writer.write("\n");
Index:
D:/WorkspaceGT-2.3/2.3.x/plugin/wfs/src/org/geotools/data/wfs/WFSDataStore.java
===================================================================
---
D:/WorkspaceGT-2.3/2.3.x/plugin/wfs/src/org/geotools/data/wfs/WFSDataStore.java
(revision 26046)
+++
D:/WorkspaceGT-2.3/2.3.x/plugin/wfs/src/org/geotools/data/wfs/WFSDataStore.java
(working copy)
@@ -116,6 +116,8 @@
private int timeout = 10000;
private final boolean tryGZIP;
protected WFSStrategy strategy;
+
+ protected String encoding = "UTF-8";
private boolean lenient;
@@ -128,6 +130,15 @@
// not called
tryGZIP=true;
}
+
+ protected WFSDataStore(URL host, Boolean protocol, String username,
+ String password, int timeout, int buffer, boolean tryGZIP, boolean
lenient,String encoding)
+ throws SAXException, IOException {
+ this( host, protocol, username, password, timeout, buffer, tryGZIP,
lenient);
+ if (encoding != null){
+ this.encoding = encoding;
+ }
+ }
/**
* Construct <code>WFSDataStore</code>.
*
@@ -143,10 +154,13 @@
* @throws IOException
*/
protected WFSDataStore(URL host, Boolean protocol, String username,
- String password, int timeout, int buffer, boolean tryGZIP )
+ String password, int timeout, int buffer, boolean tryGZIP)
throws SAXException, IOException {
this( host, protocol, username, password, timeout, buffer, tryGZIP,
false);
}
+
+
+
/**
* Construct <code>WFSDataStore</code>.
*
@@ -155,6 +169,7 @@
* @param username - iff password
* @param password - iff username
* @param timeout - default 3000 (ms)
+ * @param encoding - default UTF-8
* @param buffer - default 10 (features)
* @param tryGZIP - indicates to use GZIP if server supports it.
* @param lenient - if true the parsing will be very forgiving to bad
data. Errors will be logged rather than exceptions.
@@ -167,6 +182,9 @@
throws SAXException, IOException {
super(true);
+
+
+
this.lenient=lenient;
if ((username != null) && (password != null)) {
auth = new WFSAuthenticator(username, password);
@@ -188,6 +206,8 @@
findCapabilities(host);
determineCorrectStrategy(host);
}
+
+
private void determineCorrectStrategy(URL host) {
if( host.toString().indexOf("mapserv")!=-1 )
strategy=new MapServerWFSStrategy(this);
@@ -516,6 +536,7 @@
if(uri!=null)
hints.put(DocumentWriter.SCHEMA_ORDER, new
String[]{WFSSchema.NAMESPACE.toString(), uri.toString()});
+ hints.put(DocumentWriter.ENCODING, encoding);
try {
DocumentWriter.writeDocument(new String[] { typeName },
WFSSchema.getInstance(), osw, hints);
@@ -580,7 +601,7 @@
if (request.getFilter().getFilterType() ==
FilterType.GEOMETRY_BBOX) {
String bb = printBBoxGet(((GeometryFilter)
request.getFilter()),request.getTypeName());
if(bb!=null)
- url += ("&BBOX=" + URLEncoder.encode(bb, "UTF-8"));
+ url += ("&BBOX=" + URLEncoder.encode(bb, encoding));
} else {
if (request.getFilter().getFilterType() == FilterType.FID)
{
FidFilter ff = (FidFilter) request.getFilter();
@@ -596,14 +617,14 @@
// rest
if (request.getFilter() != Filter.NONE &&
request.getFilter() != Filter.ALL) {
url += "&FILTER=" + URLEncoder.encode(
- printFilter(request.getFilter()), "UTF-8");
+ printFilter(request.getFilter()),
"encoding");
}
}
}
}
}
- url += ("&TYPENAME=" + URLEncoder.encode(request.getTypeName(),
"UTF-8"));
+ url += ("&TYPENAME=" + URLEncoder.encode(request.getTypeName(),
encoding));
Logger.getLogger("org.geotools.data.wfs").fine(url);
Logger.getLogger("org.geotools.data.communication").fine("Output:
"+url);
@@ -762,6 +783,8 @@
hints.put(DocumentWriter.BASE_ELEMENT,
WFSSchema.getInstance().getElements()[2]); // GetFeature
+ hints.put(DocumentWriter.ENCODING, encoding);
+
try {
DocumentWriter.writeDocument(query, WFSSchema.getInstance(), w,
hints);
Index:
D:/WorkspaceGT-2.3/2.3.x/plugin/wfs/src/org/geotools/data/wfs/WFSDataStoreFactory.java
===================================================================
---
D:/WorkspaceGT-2.3/2.3.x/plugin/wfs/src/org/geotools/data/wfs/WFSDataStoreFactory.java
(revision 26046)
+++
D:/WorkspaceGT-2.3/2.3.x/plugin/wfs/src/org/geotools/data/wfs/WFSDataStoreFactory.java
(working copy)
@@ -69,6 +69,14 @@
String.class,
"This allows the user to specify a username. This param should not
be used without the USERNAME param.",
false);
+
+ /**
+ * String
+ */
+ public static final Param ENCODING = new
Param("WFSDataStoreFactory:ENCODING",
+ String.class,
+ "This allows the user to specify the Encoding of the XML of the
XML-Requests sent to the Server.",
+ false);
// timeout -- optional
/**
@@ -153,6 +161,7 @@
int buffer = 10;
boolean tryGZIP=true;
boolean lenient=false;
+ String encoding = null;
if (params.containsKey(TIMEOUT.key)) {
Integer i = (Integer) TIMEOUT.lookUp(params);
@@ -185,6 +194,11 @@
if (params.containsKey(PASSWORD.key)) {
pass = (String) PASSWORD.lookUp(params);
}
+
+ if (params.containsKey(ENCODING.key)) {
+ encoding = (String) ENCODING.lookUp(params);
+ }
+
if (((user == null) && (pass != null))
|| ((pass == null) && (user != null))) {
@@ -197,7 +211,7 @@
DataStore ds = null;
try {
- ds = new WFSDataStore(host, protocol, user, pass, timeout, buffer,
tryGZIP, lenient);
+ ds = new WFSDataStore(host, protocol, user, pass, timeout, buffer,
tryGZIP, lenient,encoding);
cache.put(params, ds);
} catch (SAXException e) {
logger.warning(e.toString());
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users