use of org.geotoolkit.sld.xml.v110.StyledLayerDescriptor in project geotoolkit by Geomatys.
the class SLD100Test method testSLD.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR STYLE ORDERING //////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testSLD() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test-------------------------------------------------------------
// ----------------------------------------------------------------------
Object obj = UNMARSHALLER.unmarshal(FILE_SLD);
assertNotNull(obj);
StyledLayerDescriptor jax = (StyledLayerDescriptor) obj;
MutableStyledLayerDescriptor sld = TRANSFORMER_GT.visit(jax);
assertNotNull(sld);
// Details
assertEquals(sld.getName(), "SLD : name");
assertEquals(sld.getDescription().getTitle().toString(), "SLD : title");
assertEquals(sld.getDescription().getAbstract().toString(), "SLD : abstract");
// libraries, SLD1.0 does not store thoses informations
assertEquals(sld.libraries().size(), 0);
// layers
assertEquals(sld.layers().size(), 2);
// Named Layer-----------------------------------------------------------
NamedLayer nl = (NamedLayer) sld.layers().get(0);
assertEquals(nl.getName(), "Named layer : name");
// no title, no description in SLD1.0
List<? extends FeatureTypeConstraint> cons = nl.getConstraints().constraints();
assertEquals(cons.size(), 1);
assertNotNull(cons.get(0).getFilter());
assertEquals(cons.get(0).getFeatureTypeName().toString(), "Feature type : name");
assertEquals(cons.get(0).getExtent().size(), 3);
Extent ext = cons.get(0).getExtent().get(0);
assertEquals(ext.getName(), "Ext : Name 1");
assertEquals(ext.getValue(), "Ext : Value 1");
ext = cons.get(0).getExtent().get(1);
assertEquals(ext.getName(), "Ext : Name 2");
assertEquals(ext.getValue(), "Ext : Value 2");
ext = cons.get(0).getExtent().get(2);
assertEquals(ext.getName(), "Ext : Name 3");
assertEquals(ext.getValue(), "Ext : Value 3");
// Named Style-----------------------------------------------------------
assertEquals(nl.styles().size(), 1);
NamedStyle ns = (NamedStyle) nl.styles().get(0);
assertEquals(ns.getName(), "Named style : name");
// User Layer------------------------------------------------------------
UserLayer ul = (UserLayer) sld.layers().get(1);
assertEquals(ul.getName(), "User layer : name");
// no title, no description in SLD1.0
RemoteOWS source = (RemoteOWS) ul.getSource();
assertEquals(source.getService(), "WFS");
assertEquals(source.getOnlineResource().getLinkage().toString(), "http://some.site.com/WFS?");
cons = ((LayerFeatureConstraints) ul.getConstraints()).constraints();
assertEquals(cons.size(), 1);
assertNotNull(cons.get(0).getFilter());
assertEquals(cons.get(0).getFeatureTypeName().toString(), "Feature type : name");
assertEquals(cons.get(0).getExtent().size(), 2);
ext = cons.get(0).getExtent().get(0);
assertEquals(ext.getName(), "Ext : Name 1");
assertEquals(ext.getValue(), "Ext : Value 1");
ext = cons.get(0).getExtent().get(1);
assertEquals(ext.getName(), "Ext : Name 2");
assertEquals(ext.getValue(), "Ext : Value 2");
assertEquals(ul.styles().size(), 1);
// we dont test the user style, this is done in the SE test
// Write test------------------------------------------------------------
// ----------------------------------------------------------------------
StyledLayerDescriptor pvt = TRANSFORMER_SLD.visit(sld, null);
assertNotNull(pvt);
assertEquals(pvt.getName(), "SLD : name");
assertEquals(pvt.getTitle(), "SLD : title");
assertEquals(pvt.getAbstract(), "SLD : abstract");
// layers
assertEquals(pvt.getNamedLayerOrUserLayer().size(), 2);
// Named Layer-----------------------------------------------------------
org.geotoolkit.sld.xml.v100.NamedLayer nlt = (org.geotoolkit.sld.xml.v100.NamedLayer) pvt.getNamedLayerOrUserLayer().get(0);
assertEquals(nlt.getName(), "Named layer : name");
// no title, no description in SLD1.0
List<org.geotoolkit.sld.xml.v100.FeatureTypeConstraint> constr = nlt.getLayerFeatureConstraints().getFeatureTypeConstraint();
assertEquals(constr.size(), 1);
assertNotNull(constr.get(0).getFilter());
assertEquals(constr.get(0).getFeatureTypeName(), "Feature type : name");
assertEquals(constr.get(0).getExtent().size(), 3);
org.geotoolkit.sld.xml.v100.Extent extx = constr.get(0).getExtent().get(0);
assertEquals(extx.getName(), "Ext : Name 1");
assertEquals(extx.getValue(), "Ext : Value 1");
extx = constr.get(0).getExtent().get(1);
assertEquals(extx.getName(), "Ext : Name 2");
assertEquals(extx.getValue(), "Ext : Value 2");
extx = constr.get(0).getExtent().get(2);
assertEquals(extx.getName(), "Ext : Name 3");
assertEquals(extx.getValue(), "Ext : Value 3");
// Named Style-----------------------------------------------------------
assertEquals(nlt.getNamedStyleOrUserStyle().size(), 1);
org.geotoolkit.sld.xml.v100.NamedStyle nst = (org.geotoolkit.sld.xml.v100.NamedStyle) nlt.getNamedStyleOrUserStyle().get(0);
assertEquals(nst.getName(), "Named style : name");
// User Layer------------------------------------------------------------
org.geotoolkit.sld.xml.v100.UserLayer ulx = (org.geotoolkit.sld.xml.v100.UserLayer) pvt.getNamedLayerOrUserLayer().get(1);
assertEquals(ulx.getName(), "User layer : name");
// no title, no description in SLD1.0
org.geotoolkit.sld.xml.v100.RemoteOWS sourcex = (org.geotoolkit.sld.xml.v100.RemoteOWS) ulx.getRemoteOWS();
assertEquals(sourcex.getService(), "WFS");
assertEquals(sourcex.getOnlineResource().getHref(), "http://some.site.com/WFS?");
constr = ulx.getLayerFeatureConstraints().getFeatureTypeConstraint();
assertEquals(constr.size(), 1);
assertNotNull(cons.get(0).getFilter());
assertEquals(cons.get(0).getFeatureTypeName().toString(), "Feature type : name");
assertEquals(cons.get(0).getExtent().size(), 2);
ext = cons.get(0).getExtent().get(0);
assertEquals(ext.getName(), "Ext : Name 1");
assertEquals(ext.getValue(), "Ext : Value 1");
ext = cons.get(0).getExtent().get(1);
assertEquals(ext.getName(), "Ext : Name 2");
assertEquals(ext.getValue(), "Ext : Value 2");
assertEquals(ulx.getUserStyle().size(), 1);
MARSHALLER.marshal(pvt, TEST_FILE_SLD);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.sld.xml.v110.StyledLayerDescriptor in project geotoolkit by Geomatys.
the class SLD110Test method testSLD.
// //////////////////////////////////////////////////////////////////////////
// JAXB TEST MARSHELLING AND UNMARSHELLING FOR STYLE ORDERING //////////////
// //////////////////////////////////////////////////////////////////////////
@Test
public void testSLD() throws JAXBException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test-------------------------------------------------------------
// ----------------------------------------------------------------------
Object obj = UNMARSHALLER.unmarshal(FILE_SLD);
assertNotNull(obj);
StyledLayerDescriptor jax = (StyledLayerDescriptor) obj;
MutableStyledLayerDescriptor sld = TRANSFORMER_GT.visit(jax);
assertNotNull(sld);
// Details
assertEquals(sld.getName(), "SLD : name");
assertEquals(sld.getDescription().getTitle().toString(), "SLD : title");
assertEquals(sld.getDescription().getAbstract().toString(), "SLD : abstract");
// libraries
assertEquals(sld.libraries().size(), 1);
assertEquals(sld.libraries().get(0).getOnlineResource().getLinkage().toString(), "http://geomayts.fr/anSLDFile.xml");
// layers
assertEquals(sld.layers().size(), 2);
// Named Layer-----------------------------------------------------------
NamedLayer nl = (NamedLayer) sld.layers().get(0);
assertEquals(nl.getName(), "Named layer : name");
assertEquals(nl.getDescription().getTitle().toString(), "Named layer : title");
assertEquals(nl.getDescription().getAbstract().toString(), "Named layer : abstract");
List<? extends FeatureTypeConstraint> cons = nl.getConstraints().constraints();
assertEquals(cons.size(), 1);
assertNotNull(cons.get(0).getFilter());
assertTrue(cons.get(0).getFeatureTypeName().toString().endsWith("FeatureName"));
assertEquals(cons.get(0).getExtent().size(), 3);
Extent ext = cons.get(0).getExtent().get(0);
assertEquals(ext.getName(), "Ext : Name 1");
assertEquals(ext.getValue(), "Ext : Value 1");
ext = cons.get(0).getExtent().get(1);
assertEquals(ext.getName(), "Ext : Name 2");
assertEquals(ext.getValue(), "Ext : Value 2");
ext = cons.get(0).getExtent().get(2);
assertEquals(ext.getName(), "Ext : Name 3");
assertEquals(ext.getValue(), "Ext : Value 3");
// Named Style-----------------------------------------------------------
assertEquals(nl.styles().size(), 1);
NamedStyle ns = (NamedStyle) nl.styles().get(0);
assertEquals(ns.getName(), "Named style : name");
assertEquals(ns.getDescription().getTitle().toString(), "Named style : title");
assertEquals(ns.getDescription().getAbstract().toString(), "Named style : abstract");
// User Layer------------------------------------------------------------
UserLayer ul = (UserLayer) sld.layers().get(1);
assertEquals(ul.getName(), "User layer : name");
assertEquals(ul.getDescription().getTitle().toString(), "User layer : title");
assertEquals(ul.getDescription().getAbstract().toString(), "User layer : abstract");
RemoteOWS source = (RemoteOWS) ul.getSource();
assertEquals(source.getService(), "WFS");
assertEquals(source.getOnlineResource().getLinkage().toString(), "http://some.site.com/WFS?");
cons = ((LayerFeatureConstraints) ul.getConstraints()).constraints();
assertEquals(cons.size(), 1);
assertNotNull(cons.get(0).getFilter());
assertTrue(cons.get(0).getFeatureTypeName().toString().endsWith("FeatureName"));
assertEquals(cons.get(0).getExtent().size(), 2);
ext = cons.get(0).getExtent().get(0);
assertEquals(ext.getName(), "Ext : Name 1");
assertEquals(ext.getValue(), "Ext : Value 1");
ext = cons.get(0).getExtent().get(1);
assertEquals(ext.getName(), "Ext : Name 2");
assertEquals(ext.getValue(), "Ext : Value 2");
assertEquals(ul.styles().size(), 1);
// we dont test the user style, this is done in the SE test
// Write test------------------------------------------------------------
// ----------------------------------------------------------------------
StyledLayerDescriptor pvt = TRANSFORMER_SLD.visit(sld, null);
assertNotNull(pvt);
assertEquals(pvt.getName(), "SLD : name");
assertEquals(String.valueOf(pvt.getDescription().getTitle()), "SLD : title");
assertEquals(String.valueOf(pvt.getDescription().getAbstract()), "SLD : abstract");
// layers
assertEquals(pvt.getNamedLayerOrUserLayer().size(), 2);
// Named Layer-----------------------------------------------------------
org.geotoolkit.sld.xml.v110.NamedLayer nlt = (org.geotoolkit.sld.xml.v110.NamedLayer) pvt.getNamedLayerOrUserLayer().get(0);
assertEquals(nlt.getName(), "Named layer : name");
assertEquals(String.valueOf(nlt.getDescription().getTitle()), "Named layer : title");
assertEquals(String.valueOf(nlt.getDescription().getAbstract()), "Named layer : abstract");
List<org.geotoolkit.sld.xml.v110.FeatureTypeConstraint> constr = nlt.getLayerFeatureConstraints().getFeatureTypeConstraint();
assertEquals(constr.size(), 1);
assertNotNull(constr.get(0).getFilter());
assertTrue(cons.get(0).getFeatureTypeName().toString().endsWith("FeatureName"));
assertEquals(constr.get(0).getExtent().size(), 3);
org.geotoolkit.sld.xml.v110.Extent extx = constr.get(0).getExtent().get(0);
assertEquals(extx.getName(), "Ext : Name 1");
assertEquals(extx.getValue(), "Ext : Value 1");
extx = constr.get(0).getExtent().get(1);
assertEquals(extx.getName(), "Ext : Name 2");
assertEquals(extx.getValue(), "Ext : Value 2");
extx = constr.get(0).getExtent().get(2);
assertEquals(extx.getName(), "Ext : Name 3");
assertEquals(extx.getValue(), "Ext : Value 3");
// Named Style-----------------------------------------------------------
assertEquals(nlt.getNamedStyleOrUserStyle().size(), 1);
org.geotoolkit.sld.xml.v110.NamedStyle nst = (org.geotoolkit.sld.xml.v110.NamedStyle) nlt.getNamedStyleOrUserStyle().get(0);
assertEquals(nst.getName(), "Named style : name");
assertEquals(String.valueOf(nst.getDescription().getTitle()), "Named style : title");
assertEquals(String.valueOf(nst.getDescription().getAbstract()), "Named style : abstract");
// User Layer------------------------------------------------------------
org.geotoolkit.sld.xml.v110.UserLayer ulx = (org.geotoolkit.sld.xml.v110.UserLayer) pvt.getNamedLayerOrUserLayer().get(1);
assertEquals(ulx.getName(), "User layer : name");
assertEquals(String.valueOf(ulx.getDescription().getTitle()), "User layer : title");
assertEquals(String.valueOf(ulx.getDescription().getAbstract()), "User layer : abstract");
org.geotoolkit.sld.xml.v110.RemoteOWS sourcex = (org.geotoolkit.sld.xml.v110.RemoteOWS) ulx.getRemoteOWS();
assertEquals(sourcex.getService(), "WFS");
assertEquals(sourcex.getOnlineResource().getHref(), "http://some.site.com/WFS?");
constr = ulx.getLayerFeatureConstraints().getFeatureTypeConstraint();
assertEquals(constr.size(), 1);
assertNotNull(cons.get(0).getFilter());
assertEquals(cons.get(0).getFeatureTypeName().tip().toString(), "FeatureName");
assertEquals(cons.get(0).getExtent().size(), 2);
ext = cons.get(0).getExtent().get(0);
assertEquals(ext.getName(), "Ext : Name 1");
assertEquals(ext.getValue(), "Ext : Value 1");
ext = cons.get(0).getExtent().get(1);
assertEquals(ext.getName(), "Ext : Name 2");
assertEquals(ext.getValue(), "Ext : Value 2");
assertEquals(ulx.getUserStyle().size(), 1);
MARSHALLER.marshal(pvt, TEST_FILE_SLD);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.sld.xml.v110.StyledLayerDescriptor in project geo-platform by geosdi.
the class GPGeoserverStyleConnectorV22XTest method g_geoserverCreateStyleSLDV100RequestTest.
@Test
public void g_geoserverCreateStyleSLDV100RequestTest() throws Exception {
StyledLayerDescriptor styledLayerDescriptor = JACKSON_JAXB_XML_SUPPORT.getDefaultMapper().readValue(new File(of(new File(".").getCanonicalPath(), "src", "test", "resources", "StyledLayerDescriptor-DefaultLine").collect(joining(separator, "", ".xml"))), StyledLayerDescriptor.class);
logger.info("#################GEOSERVER_CREATE_STYLE_SLD_V100_RESPONSE : {}\n", geoserverConnectorStoreV2_20_x.createStyleSLDV100Request().withStyleName("style_sld_v100").withStyleBody(styledLayerDescriptor).getResponse());
}
use of org.geotoolkit.sld.xml.v110.StyledLayerDescriptor in project geo-platform by geosdi.
the class GeoserverConnectorRasterizeTest method a_rasterizeData.
@Test
@Ignore
public void a_rasterizeData() throws Exception {
StyledLayerDescriptor styledLayerDescriptor = this.geoserverConnectorStore.rasterizeData().withRasterName("sfdem").withMin(null).withMax(null).withClasses(null).withDigits(null).withType(null).withGeoserverRamp(null).getResponse();
logger.info("#####################{}\n\n\n", styledLayerDescriptor);
String result = this.geoserverConnectorStore.rasterizeData().withRasterName("sfdem").withMin(null).withMax(null).withClasses(null).withDigits(null).withType(null).withGeoserverRamp(null).getResponseAsString();
logger.info("#####################RESULT CONNECTOR: {}\n\n\n", result);
}
use of org.geotoolkit.sld.xml.v110.StyledLayerDescriptor in project geo-platform by geosdi.
the class GeoserverConnectorStylesTest method b_publishStyle.
// @Ignore
@Test
public void b_publishStyle() throws Exception {
StyledLayerDescriptor styledLayerDescriptor = JACKSON_JAXB_XML_SUPPORT.getDefaultMapper().readValue(new File(of(new File(".").getCanonicalPath(), "src", "test", "resources", "default_polygon_test.sld").collect(joining(separator))), StyledLayerDescriptor.class);
logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@GEOSERVER_STYLE_SLD : {}", styledLayerDescriptor);
logger.info("################{}\n", this.geoserverConnectorStore.createStyleSLDV100Request().withStyleBody(styledLayerDescriptor).withRaw(TRUE).withStyleName("Default_Polygon_Test").getResponseAsString());
}
Aggregations