Hi Nils,

  You are on the right track with the envelope query.  Unless your polygons
are unusually overlapped (i.e. many overlap many), you should get good
performance using the results of the envelope query to feed the inner loop
of geometry intersection.

regards,
Larry




On Fri, Jun 25, 2010 at 10:53 AM, Nils Kuhn <nils.k...@bws-gmbh.de> wrote:

>  Hi all,
>
> I have the following problem:
> I have two polygon-layers with many thousands of features. In layer a I
> want to flag in an integer-field for every feature, whether the area of the
> intersection with the polygons of layer b amounts more than 1 percent of the
> area himself.
>
> The attached code works, but the calculation would last about two weeks, I
> think...
>
> Can anybody see a better way than my nested loop through the features of
> both layers? I searched for a function like* *
> com.vividsolutions.jump.feature.FeatureCollectionWrapper.query(
> com.vividsolutions.jts.geom.Envelope envelope), but I would like to refer
> a geometry instead of an envelope.
>
> Thanks for any ideas in advance.
> Regards, Nils
>
>
>
>                double dblAreaIntersectionTemp;
>                //layer a
>                lyrA=context.getLayerManager().getLayer("LayerA");
>                FeatureCollectionWrapper fcwA =
> lyrA.getFeatureCollectionWrapper();
>                final Collection featuresA = fcwA.getFeatures();
>                //layer b
>                lyrB=context.getLayerManager().getLayer("LayerB");
>                FeatureCollectionWrapper fcwB =
> lyrB.getFeatureCollectionWrapper();
>                final Collection featuresB = fcwB.getFeatures();
>
>                //iterate over the features of layer a
>                for (Iterator iteratorA = featuresA.iterator();
> iteratorA.hasNext();) {
>                        Feature featureA = (Feature) iteratorA.next();
>                        //iterate over the features of layer b, summarize
> the intersection-areas
>                        dblAreaIntersectionTemp=0;
>                        for (Iterator iteratorB = featuresB.iterator();
> iteratorB.hasNext();) {
>                                Feature featureB = (Feature)
> iteratorB.next();
>
>  
> dblAreaIntersectionTemp+=featureB.getGeometry().intersection(featureA.getGeometry()).getArea();
>                        }
>                        //if the summarized intersection-area is larger than
> 1% of the area of the feature of layer a himself a flag is set to this
> feature
>                        if
> ((dblAreaIntersectionTemp/featureA.getGeometry().getArea())>=0.01) {
>                                featureA.setAttribute("flag", 1);
>                        }else{
>                                featureA.setAttribute("flag", 0);
>                        }
>                }
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to