use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class OwcXmlIO method toStyleSet.
private static StyleSetType toStyleSet(Style style, boolean def) {
final StyleSetType styleSet = OWC_FACTORY.createStyleSetType();
styleSet.setDefault(def);
final ContentType content = OWC_FACTORY.createContentType();
final StyleXmlIO io = new StyleXmlIO();
final UserStyle jaxbStyle = io.getTransformerXMLv110().visit(style, null);
content.getContent().add(jaxbStyle);
styleSet.getNameOrTitleOrAbstract().add(OWC_FACTORY.createStyleSetTypeContent(content));
return styleSet;
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class OGCforSLD110Test method testCustom1.
@Test
public void testCustom1() throws JAXBException, FactoryException {
StyleXmlIO util = new StyleXmlIO();
final Filter filter = util.readFilter(OGCforSLD110Test.class.getResource("/org/geotoolkit/test/filter/filterbbox.xml"), org.geotoolkit.sld.xml.Specification.Filter.V_1_1_0);
assertEquals(LogicalOperatorName.OR, filter.getOperatorType());
final LogicalOperator<Object> or = (LogicalOperator) filter;
final Filter f1 = or.getOperands().get(0);
final Filter f2 = or.getOperands().get(1);
assertEquals(ComparisonOperatorName.PROPERTY_IS_EQUAL_TO, f1.getOperatorType());
assertEquals(SpatialOperatorName.BBOX, f2.getOperatorType());
final BinaryComparisonOperator<Object> ff1 = (BinaryComparisonOperator) f1;
final BinarySpatialOperator<Object> ff2 = (BinarySpatialOperator) f2;
assertTrue(ff1.getOperand1() instanceof ValueReference);
assertTrue(ff1.getOperand2() instanceof Literal);
assertTrue(ff2.getOperand1() instanceof ValueReference);
assertTrue(ff2.getOperand2() instanceof Literal);
assertEquals("sf:str4Property", ((ValueReference) ff1.getOperand1()).getXPath());
assertEquals("abc3", ((Literal) ff1.getOperand2()).getValue());
assertEquals("sf:attribut.Géométrie", ((ValueReference) ff2.getOperand1()).getXPath());
final Envelope2D geom = new Envelope2D((Envelope) ((Literal) ff2.getOperand2()).getValue());
assertEquals(34d, geom.getMinX(), 1e-7);
assertEquals(40d, geom.getMaxX(), 1e-7);
assertEquals(15d, geom.getMinY(), 1e-7);
assertEquals(19d, geom.getMaxY(), 1e-7);
final CoordinateReferenceSystem crs = geom.getCoordinateReferenceSystem();
assertEquals(CommonCRS.WGS84.geographic(), crs);
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class GraduationTest method testXml.
/**
* Test Jaxb xml support.
*/
@Test
public void testXml() throws JAXBException, IOException {
final GraduationSymbolizer ps = new GraduationSymbolizer();
final MutableStyle style = GO2Utilities.STYLE_FACTORY.style(ps);
final Path path = Files.createTempFile("xml", ".xml");
IOUtilities.deleteOnExit(path);
new StyleXmlIO().writeStyle(path, style, Specification.StyledLayerDescriptor.V_1_1_0);
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class TileDebugTest method testXml.
/**
* Test Jaxb xml support.
*/
@Test
public void testXml() throws JAXBException, IOException {
final TileDebugSymbolizer gs = new TileDebugSymbolizer();
final MutableStyle style = GO2Utilities.STYLE_FACTORY.style(gs);
final Path path = Files.createTempFile("xml", ".xml");
IOUtilities.deleteOnExit(path);
new StyleXmlIO().writeStyle(path, style, Specification.StyledLayerDescriptor.V_1_1_0);
}
use of org.geotoolkit.sld.xml.StyleXmlIO in project geotoolkit by Geomatys.
the class LegendDemo method createContext.
private static MapLayers createContext() throws JAXBException, FactoryException, URISyntaxException {
final MapLayers context = MapBuilder.createContext();
final StyleXmlIO xmlutil = new StyleXmlIO();
// lines styles
final MutableStyle style2 = xmlutil.readStyle(LegendDemo.class.getResource("/data/style/legend2.xml"), SymbologyEncoding.V_1_1_0);
final MapLayer layer2 = MapBuilder.createEmptyMapLayer();
layer2.setStyle(style2);
layer2.setTitle("Highway");
context.getComponents().add(layer2);
// point styles
final MapLayer layerMark = MapBuilder.createEmptyMapLayer();
layerMark.setStyle(Styles.markPoint());
layerMark.setTitle("Cities");
context.getComponents().add(layerMark);
final MapLayer layerImage = MapBuilder.createEmptyMapLayer();
layerImage.setStyle(Styles.imagePoint());
layerImage.setTitle("Fishing areas");
context.getComponents().add(layerImage);
return context;
}
Aggregations