use of org.geotools.GML in project polymap4-core by Polymap4.
the class SchemaCoder method gmlEncode.
protected String gmlEncode(SimpleFeatureType schema) throws Exception {
GML coder = new GML(GML.Version.WFS1_1);
coder.setEncoding(ENCODING);
OutputStream out = new ByteArrayOutputStream(4096);
coder.setBaseURL(new URL("file:///"));
coder.setCoordinateReferenceSystem(schema.getCoordinateReferenceSystem());
// encoder.setNamespace( "location", locationURL.toExternalForm() );
coder.encode(out, schema);
return out.toString();
}
use of org.geotools.GML in project polymap4-core by Polymap4.
the class SchemaCoder method gmlDecode.
public FeatureType gmlDecode(String input) throws Exception {
GML coder = new GML(GML.Version.WFS1_1);
coder.setEncoding(ENCODING);
File f = File.createTempFile(getClass().getName(), "xsd");
try {
FileUtils.write(f, input, ENCODING);
URL url = f.toURI().toURL();
// find name
Matcher match = COMPLEX_TYPE.matcher(input);
if (!match.find()) {
throw new IllegalStateException("No <xsd:complexType name=... found.");
}
String name = match.group(1);
return coder.decodeSimpleFeatureType(url, new NameImpl(name));
} finally {
f.delete();
}
}
Aggregations