Search in sources :

Example 16 with StyleXmlIO

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;
}
Also used : UserStyle(org.geotoolkit.sld.xml.v110.UserStyle) ContentType(org.geotoolkit.owc.xml.v10.ContentType) StyleSetType(org.geotoolkit.owc.xml.v10.StyleSetType) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO)

Example 17 with StyleXmlIO

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);
}
Also used : LogicalOperator(org.opengis.filter.LogicalOperator) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO) Envelope2D(org.apache.sis.geometry.Envelope2D) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.Literal) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) BinaryComparisonOperator(org.opengis.filter.BinaryComparisonOperator) BinarySpatialOperator(org.opengis.filter.BinarySpatialOperator) ValueReference(org.opengis.filter.ValueReference) Test(org.junit.Test)

Example 18 with StyleXmlIO

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);
}
Also used : Path(java.nio.file.Path) MutableStyle(org.geotoolkit.style.MutableStyle) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO) Test(org.junit.Test)

Example 19 with StyleXmlIO

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);
}
Also used : Path(java.nio.file.Path) MutableStyle(org.geotoolkit.style.MutableStyle) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO) Test(org.junit.Test)

Example 20 with StyleXmlIO

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;
}
Also used : MutableStyle(org.geotoolkit.style.MutableStyle) MapLayer(org.apache.sis.portrayal.MapLayer) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO) MapLayers(org.apache.sis.portrayal.MapLayers)

Aggregations

StyleXmlIO (org.geotoolkit.sld.xml.StyleXmlIO)21 Test (org.junit.Test)6 MutableStyle (org.geotoolkit.style.MutableStyle)5 Path (java.nio.file.Path)4 List (java.util.List)3 Expression (org.opengis.filter.Expression)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JAXBElement (javax.xml.bind.JAXBElement)2 JAXBException (javax.xml.bind.JAXBException)2 ContentType (org.geotoolkit.owc.xml.v10.ContentType)2 StyleSetType (org.geotoolkit.owc.xml.v10.StyleSetType)2 UserStyle (org.geotoolkit.sld.xml.v110.UserStyle)2 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 Icon (javax.swing.Icon)1 ImageIcon (javax.swing.ImageIcon)1 Envelope2D (org.apache.sis.geometry.Envelope2D)1 MapLayer (org.apache.sis.portrayal.MapLayer)1