I have a problem in my code (Java Geotools). When I draw in my carte map a LineString sometimes when I run my program an errors apears and I don't understand what does it means.


avr. 14, 2016 2:17:15 PM org.geotools.renderer.lite.StreamingRenderer fireErrorEvent GRAVE: null java.lang.NullPointerException at sun.java2d.pipe.LoopPipe.fill(Unknown Source) at sun.java2d.pipe.PixelToParallelogramConverter.fill(Unknown Source) at sun.java2d.SunGraphics2D.fill(Unknown Source) at org.geotools.renderer.lite.StyledShapePainter.fillLiteShape(StyledShapePainter.java:710) at org.geotools.renderer.lite.StyledShapePainter.paint(StyledShapePainter.java:264) at org.geotools.renderer.lite.StreamingRenderer$PaintShapeRequest.execute(StreamingRenderer.java:3344) at org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:3667) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)


public static Layer addligne( ArrayList<Double> xPoints, ArrayList<Double> yPoints) throws SchemaException, ParseException {

        SimpleFeatureType lineType = DataUtilities.createType("LINE", "geom:LineString,name:String");

    final int N = xPoints.size();
    Coordinate[] coords = new Coordinate[N];
    int i = 0;
    for (i = 0; i < N; i++) {       
                double val_long=(double) xPoints.get(i);
                double val_lat=(double) yPoints.get(i);
                coords[i] = new Coordinate(val_long,val_lat); 

    GeometryFactory gFac = JTSFactoryFinder.getGeometryFactory(null);

       SimpleFeatureCollection col = FeatureCollections.newCollection("internal");

     ((DefaultFeatureCollection) col).add( SimpleFeatureBuilder.build( lineType, new Object[]{ gFac.createLineString(coords)}, null) );
    Style style =SLD.createLineStyle(Color.BLUE, 1.0f);
    Layer  layer = new FeatureLayer(col, style); 
  return layer;
  • 1
    can you add a link to the data you are drawing or the code that generates it – Ian Turton Apr 14 '16 at 13:44
  • I suspect you might need to add the minimal amount of code to reproduce this problem for someone to be able to help you. – John Powell Apr 14 '16 at 13:52
  • OK - what is in the array of points that causes the issue? – Ian Turton Apr 14 '16 at 14:40
  • Here are some of the code when I use this method that causes the errorif (vect_inter.size()>200){ try{ Layer pLayer =Dessin.addLigne(vect1_inter,vect_inter); mapcontext.addLayer( pLayer); StreamingRenderer render = new StreamingRenderer(); render.setMapContent(mapcontext); – beh_bouchra Apr 14 '16 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.