This is a programming error, look at my comments

Quoting ballibum <[email protected]>:

> Thanks for answering,
> i've tested your idea, but it does not work.
> That is my code:
>
>
>       public static Geometry big_geom (SimpleFeatureCollection 
> featureCollection)
>       {
>               Geometry big_geom = null;
// big_geom is null here
>               FeatureIterator iterator_polygone = 
> featureCollection.features();
>               try
>               {
>                       while(iterator_polygone.hasNext())
>                       {
>                               SimpleFeature feature_polygon = (SimpleFeature)
> iterator_polygone.next();
>                               Geometry the_geom = (Geometry) 
> feature_polygon.getDefaultGeometry();
>                               big_geom = big_geom.union(the_geom);
// first iteration, big_geom is still null, big_geom.union(the_geom) causes
// the NullPointerException, the following will work
//
//  if (big_geom==null)
//      big_geom=the_geom
//  else
//      big_geom = big_geom.union(the_geom);
//


>                       }
>               }
>               finally
>               {
>                       featureCollection.close( iterator_polygone );
>               }
>               return big_geom;
>       }
>
> I got the following error:
>
>
> Exception in thread "main" java.lang.NullPointerException
>       at main.funktionen.big_geom(funktionen.java:165)
>       at main.funktionen.Flaeche(funktionen.java:130)
>       at main.start.main(start.java:48)
>
>
> --
> View this message in context:   
> http://osgeo-org.1803224.n2.nabble.com/difference-between-layer-a-and-layer-b-tp6358222p6358322.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to