public void testLabelLineOrientation() throws Exception {
    Style style = RendererBaseTest.loadStyle(this, "textLineOrientation.sld");

    DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84);
    mc.addLayer(fs, style);

    renderer.setContext(mc);

    RendererBaseTest.showRender("Lines with circl stroke", renderer, TIME, bounds);
  }
  private void testTransformWithQuery(boolean invert)
      throws IOException, URISyntaxException, CQLException, NoSuchAuthorityCodeException,
          FactoryException, Exception {
    // grab the style
    Style style =
        RendererBaseTest.loadStyle(
            this, invert ? "attributeRename.sld" : "attributeRenameNoInvert.sld");
    // grab the data
    File property = new File(TestData.getResource(this, "point.properties").toURI());
    PropertyDataStore ds = new PropertyDataStore(property.getParentFile());
    FeatureSource fs = ds.getFeatureSource("point");

    // prepare a feature layer with a query and the rendering tx
    FeatureLayer layer = new FeatureLayer(fs, style);
    layer.setQuery(new Query(null, CQL.toFilter("id > 5")));

    // render it
    MapContent mc = new MapContent();
    mc.addLayer(layer);
    StreamingRenderer renderer = new StreamingRenderer();
    final AtomicInteger counter = new AtomicInteger();
    renderer.addRenderListener(
        new RenderListener() {

          @Override
          public void featureRenderer(SimpleFeature feature) {
            counter.incrementAndGet();
          }

          @Override
          public void errorOccurred(Exception e) {}
        });
    renderer.setMapContent(mc);
    ReferencedEnvelope re = new ReferencedEnvelope(0, 12, 0, 12, CRS.decode("EPSG:4326"));
    BufferedImage image =
        RendererBaseTest.showRender("Lines with circle stroke", renderer, TIME, re);

    // if everything went fine we'll have a single red dot in the middle, and we rendered
    // just one feature
    assertEquals(1, counter.get());
    assertEquals(Color.RED, getPixelColor(image, image.getWidth() / 2, image.getHeight() / 2));
  }
  @Test
  public void testTransformReproject() throws Exception {
    // grab the style
    Style style = RendererBaseTest.loadStyle(this, "reproject-rt.sld");
    // grab the data
    File property = new File(TestData.getResource(this, "point.properties").toURI());
    PropertyDataStore ds = new PropertyDataStore(property.getParentFile());
    FeatureSource fs = ds.getFeatureSource("point");

    // prepare a feature layer with a query and the rendering tx
    FeatureLayer layer = new FeatureLayer(fs, style);

    // prepare a bbox in UTM-32N
    ReferencedEnvelope reWgs84 = new ReferencedEnvelope(0, 12, 0, 12, CRS.decode("EPSG:4326"));
    ReferencedEnvelope reUTM32N = reWgs84.transform(CRS.decode("EPSG:3857"), true);

    // render it
    MapContent mc = new MapContent();
    mc.addLayer(layer);
    StreamingRenderer renderer = new StreamingRenderer();
    final AtomicInteger counter = new AtomicInteger();
    renderer.addRenderListener(
        new RenderListener() {

          @Override
          public void featureRenderer(SimpleFeature feature) {
            counter.incrementAndGet();
          }

          @Override
          public void errorOccurred(Exception e) {}
        });
    renderer.setMapContent(mc);
    BufferedImage image =
        RendererBaseTest.showRender("Lines with circle stroke", renderer, TIME, reUTM32N);

    // if everything went fine we rendered all the features
    assertEquals(10, counter.get());
    assertEquals(Color.RED, getPixelColor(image, image.getWidth() / 2, image.getHeight() / 2));
  }
  @Test
  public void testTransformNullCoverage() throws Exception {
    Style style = RendererBaseTest.loadStyle(this, "coverageCenter.sld");

    GridCoverage2DReader reader =
        new AbstractGridCoverage2DReader() {

          @Override
          public Format getFormat() {
            return null;
          }

          @Override
          public GridCoverage2D read(GeneralParameterValue[] parameters)
              throws IllegalArgumentException, IOException {
            // we return null on purpose, simulating a reader queried outside of its area, or
            // on a dimension value it does not have
            return null;
          }
        };

    MapContent mc = new MapContent();
    mc.addLayer(new GridReaderLayer(reader, style));

    StreamingRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mc);

    ReferencedEnvelope re = new ReferencedEnvelope(-70, 70, -160, 160, CRS.decode("EPSG:4326"));

    BufferedImage image =
        RendererBaseTest.showRender("Transformation with null input", renderer, TIME, re);
    // full white, no NPE
    double[] minimums = new ImageWorker(image).getMinimums();
    assertEquals(255, minimums[0], 0d);
    assertEquals(255, minimums[1], 0d);
    assertEquals(255, minimums[2], 0d);
    assertEquals(255, minimums[3], 0d);
  }
  @Test
  public void testTransformReprojectedGridCoverage() throws Exception {
    Style style = RendererBaseTest.loadStyle(this, "coverageCenter.sld");

    GeoTiffReader reader = new GeoTiffReader(TestData.copy(this, "geotiff/world.tiff"));

    MapContent mc = new MapContent();
    mc.addLayer(new GridCoverageLayer(reader.read(null), style));

    StreamingRenderer renderer = new StreamingRenderer();
    renderer.setMapContent(mc);

    ReferencedEnvelope reWgs84 =
        new ReferencedEnvelope(-70, 70, -160, 160, CRS.decode("EPSG:4326"));
    ReferencedEnvelope re = reWgs84.transform(CRS.decode("EPSG:3857"), true);

    BufferedImage image =
        RendererBaseTest.showRender("Lines with circle stroke", renderer, TIME, re);
    // if everything worked we are going to have a red dot in the middle of the map
    assertEquals(Color.RED, getPixelColor(image, image.getWidth() / 2, image.getHeight() / 2));
    assertEquals(Color.WHITE, getPixelColor(image, image.getWidth() / 4, image.getHeight() / 2));
    assertEquals(Color.WHITE, getPixelColor(image, image.getWidth() / 2, image.getHeight() / 4));
    assertEquals(Color.WHITE, getPixelColor(image, image.getWidth() / 4, image.getHeight() / 4));
  }
 public void testPolyLabeling() throws Exception {
   FeatureCollection collection = createPolyFeatureCollection();
   Style style = loadStyle("PolyStyle.sld");
   assertNotNull(style);
   MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84);
   map.addLayer(collection, style);
   StreamingRenderer renderer = new StreamingRenderer();
   renderer.setContext(map);
   ReferencedEnvelope env = map.getLayerBounds();
   int boundary = 10;
   env =
       new ReferencedEnvelope(
           env.getMinX() - boundary,
           env.getMaxX() + boundary,
           env.getMinY() - boundary,
           env.getMaxY() + boundary,
           null);
   RendererBaseTest.showRender("testPolyLabeling", renderer, timout, env);
 }