Search in sources :

Example 1 with SLDWriterImpl

use of com.sldeditor.common.output.impl.SLDWriterImpl in project sldeditor by robward-scisys.

the class SLDExternalImagesTest method testGetExternalImagesLine.

/**
 * Test method for {@link
 * com.sldeditor.common.data.SLDExternalImages#getExternalImages(java.net.URL,
 * org.geotools.styling.StyledLayerDescriptor)}.
 */
@Test
public void testGetExternalImagesLine() {
    SLDWriterImpl writer = new SLDWriterImpl();
    File f = new File("D:/temp/test.png");
    URL url = null;
    URL resourceLocator = null;
    try {
        url = f.toURI().toURL();
        resourceLocator = new URL(f.getParentFile().toURI().toURL().toExternalForm() + "/");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    StyledLayerDescriptor lineSLD = createTestLine(url);
    List<String> imageList = SLDExternalImages.getExternalImages(resourceLocator, lineSLD);
    String result = writer.encodeSLD(resourceLocator, lineSLD);
    assertTrue(checkResult(f, result, 2));
    assertEquals(2, imageList.size());
}
Also used : MalformedURLException(java.net.MalformedURLException) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) SLDWriterImpl(com.sldeditor.common.output.impl.SLDWriterImpl) File(java.io.File) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 2 with SLDWriterImpl

use of com.sldeditor.common.output.impl.SLDWriterImpl in project sldeditor by robward-scisys.

the class SLDExternalImagesTest method testGetExternalImagesPoint.

/**
 * Test method for {@link
 * com.sldeditor.common.data.SLDExternalImages#getExternalImages(java.net.URL,
 * org.geotools.styling.StyledLayerDescriptor)}.
 */
@Test
public void testGetExternalImagesPoint() {
    File f = new File("D:/temp/test.png");
    URL url = null;
    URL resourceLocator = null;
    try {
        url = f.toURI().toURL();
        resourceLocator = new URL(f.getParentFile().toURI().toURL().toExternalForm() + "/");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    StyledLayerDescriptor pointSLD = createTestPoint(url);
    List<String> imageList = SLDExternalImages.getExternalImages(resourceLocator, null);
    assertEquals(0, imageList.size());
    imageList = SLDExternalImages.getExternalImages(resourceLocator, pointSLD);
    SLDWriterImpl writer = new SLDWriterImpl();
    String result = writer.encodeSLD(resourceLocator, pointSLD);
    assertTrue(checkResult(f, result, 1));
    assertEquals(1, imageList.size());
}
Also used : MalformedURLException(java.net.MalformedURLException) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) SLDWriterImpl(com.sldeditor.common.output.impl.SLDWriterImpl) File(java.io.File) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 3 with SLDWriterImpl

use of com.sldeditor.common.output.impl.SLDWriterImpl in project sldeditor by robward-scisys.

the class SLDWriterImplTest method testEncodeSLD.

/**
 * Test method for {@link
 * com.sldeditor.common.output.impl.SLDWriterImpl#encodeSLD(org.geotools.styling.StyledLayerDescriptor)}.
 */
@Test
public void testEncodeSLD() {
    SLDWriterImpl writer = new SLDWriterImpl();
    String result = writer.encodeSLD(null, null);
    assertEquals("", result);
    SLDData sldData = new SLDData(null, expectedSld);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
    // No resource locator
    result = writer.encodeSLD(null, sld);
    assertTrue(!result.isEmpty());
}
Also used : SLDData(com.sldeditor.common.data.SLDData) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) SLDWriterImpl(com.sldeditor.common.output.impl.SLDWriterImpl) Test(org.junit.jupiter.api.Test)

Example 4 with SLDWriterImpl

use of com.sldeditor.common.output.impl.SLDWriterImpl in project sldeditor by robward-scisys.

the class SLDExternalImagesTest method testGetExternalImagesPolygon.

/**
 * Test method for {@link
 * com.sldeditor.common.data.SLDExternalImages#getExternalImages(java.net.URL,
 * org.geotools.styling.StyledLayerDescriptor)}.
 */
@Test
public void testGetExternalImagesPolygon() {
    SLDWriterImpl writer = new SLDWriterImpl();
    File f = new File("D:/temp/test.png");
    URL url = null;
    URL resourceLocator = null;
    try {
        url = f.toURI().toURL();
        resourceLocator = new URL(f.getParentFile().toURI().toURL().toExternalForm() + "/");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    StyledLayerDescriptor polygonSLD = createTestPolygon(url);
    List<String> imageList = SLDExternalImages.getExternalImages(resourceLocator, polygonSLD);
    String result = writer.encodeSLD(resourceLocator, polygonSLD);
    assertTrue(checkResult(f, result, 3));
    assertEquals(3, imageList.size());
}
Also used : MalformedURLException(java.net.MalformedURLException) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) SLDWriterImpl(com.sldeditor.common.output.impl.SLDWriterImpl) File(java.io.File) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Aggregations

SLDWriterImpl (com.sldeditor.common.output.impl.SLDWriterImpl)4 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)4 Test (org.junit.jupiter.api.Test)4 File (java.io.File)3 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 SLDData (com.sldeditor.common.data.SLDData)1