use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class IsolineSymbolizer method setLineSymbolizer.
public void setLineSymbolizer(LineSymbolizer lineSymbolizer) {
this.lineSymbolizer = lineSymbolizer;
if (lineSymbolizer != null) {
final StyleXmlIO util = new StyleXmlIO();
this.lineSymbolizerType = util.getTransformerXMLv110().visit(lineSymbolizer, null).getValue();
}
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class IsolineSymbolizer method setRasterSymbolizer.
public void setRasterSymbolizer(RasterSymbolizer rasterSymbolizer) {
this.rasterSymbolizer = rasterSymbolizer;
if (rasterSymbolizer != null) {
final StyleXmlIO util = new StyleXmlIO();
this.rasterSymbolizerType = util.getTransformerXMLv110().visit(rasterSymbolizer, null).getValue();
}
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class OGCforSLD110Test method testCustom2.
@Test
public void testCustom2() throws JAXBException, FactoryException {
StyleXmlIO util = new StyleXmlIO();
final SortProperty sort = util.readSortBy(OGCforSLD110Test.class.getResource("/org/geotoolkit/test/filter/sortby.xml"), org.geotoolkit.sld.xml.Specification.Filter.V_1_1_0);
assertEquals("sf:str4Property", sort.getValueReference().getXPath());
assertEquals(SortOrder.ASCENDING, sort.getSortOrder());
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class InlineImageTest method readImage.
@Test
public void readImage() throws Exception {
final BufferedImage image = new BufferedImage(20, 10, BufferedImage.TYPE_INT_ARGB);
final String geometry = null;
final ExternalGraphic external = SF.externalGraphic(new ImageIcon(image), Collections.EMPTY_LIST);
final Graphic graphic = SF.graphic(Collections.singletonList((GraphicalSymbol) external), LITERAL_ONE_FLOAT, LITERAL_ONE_FLOAT, LITERAL_ONE_FLOAT, DEFAULT_ANCHOR_POINT, DEFAULT_DISPLACEMENT);
final PointSymbolizer ips = SF.pointSymbolizer("", geometry, DEFAULT_DESCRIPTION, Units.POINT, graphic);
final MutableStyle style = SF.style(ips);
final File f = File.createTempFile("sld", ".xml");
f.deleteOnExit();
final StyleXmlIO io = new StyleXmlIO();
io.writeStyle(f, style, Specification.StyledLayerDescriptor.V_1_1_0);
final MutableStyle result = io.readStyle(f, Specification.SymbologyEncoding.V_1_1_0);
final Symbolizer s = result.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
assertTrue(s instanceof PointSymbolizer);
final PointSymbolizer ps = (PointSymbolizer) s;
final ExternalGraphic eg = (ExternalGraphic) ps.getGraphic().graphicalSymbols().get(0);
assertNotNull(eg);
final Icon ri = eg.getInlineContent();
assertNotNull(ri);
assertEquals(20, ri.getIconWidth());
assertEquals(10, ri.getIconHeight());
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class StyledLayerDescriptorToReferenceConverter method convert.
/**
* {@inheritDoc}
*/
@Override
public Reference convert(final StyledLayerDescriptor source, final Map<String, Object> params) throws UnconvertibleObjectException {
if (params.get(TMP_DIR_PATH) == null) {
throw new UnconvertibleObjectException("The output directory should be defined.");
}
if (source == null) {
throw new UnconvertibleObjectException("The source is not defined.");
}
Reference reference = new Reference();
reference.setMimeType((String) params.get(MIME));
reference.setEncoding((String) params.get(ENCODING));
reference.setSchema((String) params.get(SCHEMA));
if (WPSMimeType.APP_SLD.val().equalsIgnoreCase(reference.getMimeType())) {
// create file
final Path dataFile = buildPath(params, UUID.randomUUID().toString() + ".sld");
try {
StyleXmlIO xmlio = new StyleXmlIO();
xmlio.writeSLD(dataFile, source, Specification.StyledLayerDescriptor.V_1_1_0);
} catch (JAXBException e) {
throw new UnconvertibleObjectException(e.getMessage(), e);
}
final String relLoc = getRelativeLocation(dataFile, params);
reference.setHref(params.get(TMP_DIR_URL) + "/" + relLoc);
} else {
throw new UnconvertibleObjectException("Unsupported mime-type for " + this.getClass().getName() + " : " + reference.getMimeType());
}
return reference;
}
Aggregations