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