Revision: 6012
http://sourceforge.net/p/jump-pilot/code/6012
Author: michaudm
Date: 2018-12-02 15:37:12 +0000 (Sun, 02 Dec 2018)
Log Message:
-----------
Clean/improve IntersectPolygonLayersPlugIn
Modified Paths:
--------------
core/trunk/ChangeLog
core/trunk/src/org/openjump/core/ui/plugin/tools/IntersectPolygonLayersPlugIn.java
Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog 2018-12-02 11:53:17 UTC (rev 6011)
+++ core/trunk/ChangeLog 2018-12-02 15:37:12 UTC (rev 6012)
@@ -3,6 +3,9 @@
# 2. make sure that lines break at 80 chars for constricted display situations
#<-------------------------------- 80 chars
---------------------------------->#
+2018-12-02
+ * Make IntersectPolygonLayersPlugIn faster
+
2018-12-01 Giuseppe Aruta.
* Added a standard icon from Kosmo Saig to RasterLegendPlugIn,
WMSLegendPlugIn and (Layer) LegendPlugIn
Modified:
core/trunk/src/org/openjump/core/ui/plugin/tools/IntersectPolygonLayersPlugIn.java
===================================================================
---
core/trunk/src/org/openjump/core/ui/plugin/tools/IntersectPolygonLayersPlugIn.java
2018-12-02 11:53:17 UTC (rev 6011)
+++
core/trunk/src/org/openjump/core/ui/plugin/tools/IntersectPolygonLayersPlugIn.java
2018-12-02 15:37:12 UTC (rev 6012)
@@ -28,18 +28,14 @@
package org.openjump.core.ui.plugin.tools;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
-import org.openjump.core.geomutils.algorithm.GeometryConverter;
+import com.vividsolutions.jts.algorithm.locate.SimplePointInAreaLocator;
+import com.vividsolutions.jts.geom.*;
+import com.vividsolutions.jts.geom.util.LinearComponentExtracter;
+import com.vividsolutions.jts.operation.linemerge.LineMerger;
import org.openjump.core.geomutils.algorithm.IntersectGeometries;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.MultiPolygon;
-import com.vividsolutions.jts.geom.Point;
-import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.index.SpatialIndex;
import com.vividsolutions.jts.index.strtree.STRtree;
import com.vividsolutions.jts.operation.polygonize.Polygonizer;
@@ -49,7 +45,6 @@
import com.vividsolutions.jump.feature.Feature;
import com.vividsolutions.jump.feature.FeatureCollection;
import com.vividsolutions.jump.feature.FeatureDataset;
-import com.vividsolutions.jump.feature.FeatureDatasetFactory;
import com.vividsolutions.jump.feature.FeatureSchema;
import com.vividsolutions.jump.task.TaskMonitor;
import com.vividsolutions.jump.tools.AttributeMapping;
@@ -76,7 +71,6 @@
* TODO: translate Error messages
*
*/
-
public class IntersectPolygonLayersPlugIn extends ThreadedBasePlugIn {
private final static String LAYER1 = GenericNames.LAYER_A;
@@ -84,19 +78,13 @@
private final static String sTRANSFER = I18N
.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Transfer-attributes");
private String sDescription = "Intersects all geometries of two layers
that contain both polygons. Note: The Planar Graph function provides similar
functionality.";
- private final static String sAccurracy = "Set calculation accuray in
map units";
- // -- reset in execute to correct language
- private MultiInputDialog dialog;
- private Layer layer1 = null;
+ private Layer layer1 = null;
private Layer layer2 = null;
- private String methodNameToRun;
private boolean exceptionThrown = false;
- private PlugInContext context = null;
private boolean transferAtt = true;
- private double accurracy = 0.01;
-
+
public void initialize(PlugInContext context) throws Exception {
- context.getFeatureInstaller().addMainMenuItem(
+ context.getFeatureInstaller().addMainMenuPlugin(
this,
new String[] {MenuNames.TOOLS,
MenuNames.TOOLS_ANALYSIS},
this.getName(),
@@ -134,17 +122,16 @@
.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Intersect-Polygon-Layers")
+ "...";
}
- public void run(TaskMonitor monitor, PlugInContext context)
- throws Exception {
- this.context = context;
+ public void run(TaskMonitor monitor, PlugInContext context) throws
Exception {
monitor.allowCancellationRequests();
- FeatureSchema featureSchema = new FeatureSchema();
FeatureCollection resultColl = runIntersectionNew(layer1
.getFeatureCollectionWrapper(), layer2
.getFeatureCollectionWrapper(),
this.transferAtt, monitor,
context);
if ((resultColl != null) && (resultColl.size() > 0)) {
- context.addLayer(StandardCategoryNames.RESULT,
I18N.get("ui.plugin.analysis.GeometryFunctionPlugIn.intersection") + "-" +
layer1.getName() +"-"+ layer2.getName(),
+ context.addLayer(StandardCategoryNames.RESULT,
+
I18N.get("ui.plugin.analysis.GeometryFunctionPlugIn.intersection") + "-" +
+
layer1.getName() + "-" + layer2.getName(),
resultColl);
}
if (exceptionThrown)
@@ -163,9 +150,9 @@
* otherwise the attributes are transferred. The later step assumes
that a new created
* intersection polygon has at max only one correspondent polygon per
layer.
*
- * @param fcA
- * @param fcB
- * @param transfer Attributes should attributes be transfered?
+ * @param fcA first FeatureCollection
+ * @param fcB second FeatureCollection
+ * @param transferAttributes Attributes should attributes be transfered?
* @param monitor can be null
* @param context can be null
* @return a FeatureCollection that contains the result of the
intersection
@@ -174,141 +161,123 @@
private FeatureCollection runIntersectionNew(FeatureCollection fcA,
FeatureCollection fcB, boolean transferAttributes,
TaskMonitor monitor, PlugInContext context) {
- FeatureCollection fd = null;
- // -- put all geoms in one list and calculate their
intersections
- // i.e. iterate until pure
- ArrayList<Geometry> geomsToCheck = new ArrayList<Geometry>();
- for (Iterator iterator = fcA.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- geomsToCheck.add(f.getGeometry());
+
+ // put all geoms in a single list and prepare two indexes
+ monitor.report("Extract linearComponents and create indexes");
+ Collection<LineString> linearComponents = new ArrayList<>();
+ for (Feature f : fcA.getFeatures()) {
+ LinearComponentExtracter.getLines(f.getGeometry(),
linearComponents);
}
- for (Iterator iterator = fcB.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- geomsToCheck.add(f.getGeometry());
+ for (Feature f : fcB.getFeatures()) {
+ LinearComponentExtracter.getLines(f.getGeometry(),
linearComponents);
}
- // -- sort out the different geometry types and receive Lines
- ArrayList lines = new ArrayList();
- for (Iterator iterator = geomsToCheck.iterator();
iterator.hasNext();) {
- Geometry geom = (Geometry) iterator.next();
- if ((geom instanceof Polygon) || (geom instanceof
MultiPolygon)) {
- // everything is fine
- // -- get Lines
-
lines.addAll(GeometryConverter.transformPolygonToLineStrings(geom));
- } else {
- // --
- if (context != null) {
- context.getWorkbenchFrame().warnUser(
-
I18N.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Geometry-no-Polygon-or-Multi-Polygon"));
+ // de-duplicate segments
+ monitor.report("De-duplicate segments");
+ Set<LineString> lines = new HashSet<>();
+ GeometryFactory gf = new GeometryFactory();
+ for (LineString linearComponent : linearComponents) {
+ Coordinate[] coordinates =
linearComponent.getCoordinates();
+ for (int i = 1 ; i < coordinates.length ; i++) {
+ LineString line;
+ if (coordinates[i-1].x < coordinates[i].x) {
+ line = gf.createLineString(new
Coordinate[]{coordinates[i - 1], coordinates[i]});
+ } else if (coordinates[i-1].x >
coordinates[i].x) {
+ line = gf.createLineString(new
Coordinate[]{coordinates[i], coordinates[i-1]});
+ } else if (coordinates[i-1].y <
coordinates[i].y) {
+ line = gf.createLineString(new
Coordinate[]{coordinates[i-1], coordinates[i]});
+ } else {
+ line = gf.createLineString(new
Coordinate[]{coordinates[i], coordinates[i-1]});
}
- // --
- return null;
+ lines.add(line);
}
}
+ linearComponents.clear();
+
+ monitor.report("Merge segments into LineStrings");
+ LineMerger merger = new LineMerger();
+ merger.add(lines);
+ lines.clear();
+ linearComponents = merger.getMergedLineStrings();
+
//-- calculate the intersections and use the Polygonizer
- Collection nodedLines = IntersectGeometries.nodeLines((List)
lines);
- Polygonizer polygonizer = new Polygonizer();
- for (Iterator i = nodedLines.iterator(); i.hasNext(); ) {
- Geometry g = (Geometry) i.next();
- polygonizer.add(g);
- }
- //-- get the Polygons
- Collection withoutIntersection = polygonizer.getPolygons();
- //-- check if the polygon has a correspondent
- // if yes, transfer the attributes - if no: remove the
polygon
-
- //-- build a tree for the existing layers first.
- SpatialIndex treeA = new STRtree();
- for (Iterator iterator = fcA.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- treeA.insert(f.getGeometry().getEnvelopeInternal(), f);
- }
- SpatialIndex treeB = new STRtree();
- for (Iterator iterator = fcB.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- treeB.insert(f.getGeometry().getEnvelopeInternal(), f);
- }
+ monitor.report("Node the linework");
+ Collection nodedLines =
IntersectGeometries.nodeLines(linearComponents);
+ linearComponents.clear();
+ Polygonizer polygonizer = new Polygonizer();
+ polygonizer.add(nodedLines);
+ nodedLines.clear();
+
+ //-- get the Polygons
+ monitor.report("Polygonize");
+ Collection<Geometry> withoutIntersection =
polygonizer.getPolygons();
+ polygonizer = null;
+
// -- get all intersecting features (usually there should be
only one
// corresponding feature per layer)
// to avoid problems with spatial predicates we do the query
for an
// internal point of the result polygons
// and apply an point in polygon test
+ monitor.report("Attribute mapping");
AttributeMapping mapping = new
AttributeMapping(fcA.getFeatureSchema(),
fcB.getFeatureSchema());
+ SpatialIndex treeA = new STRtree();
+ SpatialIndex treeB = new STRtree();
+ for (Feature f : fcA.getFeatures()) {
+ treeA.insert(f.getGeometry().getEnvelopeInternal(), f);
+ }
+ for (Feature f : fcB.getFeatures()) {
+ treeB.insert(f.getGeometry().getEnvelopeInternal(), f);
+ }
+
// -- create the empty dataset with the final FeatureSchema
- fd = new FeatureDataset(mapping.createSchema("Geometry"));
+ FeatureCollection fd = new
FeatureDataset(mapping.createSchema("Geometry"));
// -- add the features and do the attribute mapping
- for (Iterator iterator = withoutIntersection.iterator();
iterator
- .hasNext();) {
- boolean errorInA = false; boolean errorInB = false;
- Geometry geom = (Geometry) iterator.next();
- Point pt = geom.getInteriorPoint();
+ int count = 0;
+ List<Integer> errorsInA = new ArrayList<>();
+ List<Integer> errorsInB = new ArrayList<>();
+ for (Geometry geom : withoutIntersection) {
+ monitor.report(count++, withoutIntersection.size(),
"polygon");
+ boolean errorInA = false;
+ boolean errorInB = false;
+ Coordinate coord =
geom.getInteriorPoint().getCoordinate();
+ Envelope envelope = new Envelope(coord, coord);
Feature f = new BasicFeature(fd.getFeatureSchema());
Feature featureA = null;
Feature featureB = null;
// -- query Layer A ---
- List candidatesA =
treeA.query(pt.getEnvelopeInternal());
+ List<Feature> candidatesA = treeA.query(envelope);
int foundCountA = 0;
- for (Iterator iterator2 = candidatesA.iterator();
iterator2.hasNext();){
- Feature ftemp = (Feature) iterator2.next();
- if (ftemp.getGeometry().contains(pt)) {
+ for (Feature ftemp : candidatesA){
+ if (SimplePointInAreaLocator.locate(coord,
ftemp.getGeometry()) == Location.INTERIOR) {
foundCountA++;
featureA = ftemp;
}
}
if (foundCountA > 1) {
- if (context != null) {
- errorInA = true;
- String errorStrg =
I18N.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Found-more-than-one-source-feature-in-Layer");
-
context.getWorkbenchFrame().warnUser(errorStrg+ " " + GenericNames.LAYER_A);
-
context.getWorkbenchFrame().getOutputFrame().createNewDocument();
-
context.getWorkbenchFrame().getOutputFrame().addText("IntersectPolygonLayersPlugIn:
" + errorStrg+ ": " + GenericNames.LAYER_A +
- ". Reason: The Layer contains probably
objects that overlay each other. Will set polygon values of item with FID: " +
f.getID() +
- " to NaN. Use i)" +
I18N.get("org.openjump.sigle.plugin.SpatialJoinPlugIn.Transfer-Attributes") +
- " or ii)" +
I18N.get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.Join-Attributes-Spatially")
+
- " functions to obtain atributes from "
+ GenericNames.LAYER_A);
- }
- } else if (foundCountA == 0) {
- if (context != null) {
- //
context.getWorkbenchFrame().warnUser("no corresponding
- // feature in Layer A");
- }
+ errorInA = true;
+ errorsInA.add(f.getID());
}
// -- query Layer B ---
- List candidatesB =
treeB.query(pt.getEnvelopeInternal());
+ List<Feature> candidatesB = treeB.query(envelope);
int foundCountB = 0;
- for (Iterator iterator2 = candidatesB.iterator();
iterator2.hasNext();){
- Feature ftemp = (Feature) iterator2.next();
- if (ftemp.getGeometry().contains(pt)) {
+ for (Feature ftemp : candidatesB){
+ if (SimplePointInAreaLocator.locate(coord,
ftemp.getGeometry()) == Location.INTERIOR) {
foundCountB++;
featureB = ftemp;
}
}
if (foundCountB > 1) {
- if (context != null) {
- errorInB = true;
- String errorStrg =
I18N.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Found-more-than-one-source-feature-in-Layer");
-
context.getWorkbenchFrame().warnUser(errorStrg+ " " + GenericNames.LAYER_B);
-
context.getWorkbenchFrame().getOutputFrame().createNewDocument();
-
context.getWorkbenchFrame().getOutputFrame().addText("IntersectPolygonLayersPlugIn:
" + errorStrg+ ": " + GenericNames.LAYER_B +
- ". Reason: The Layer contains probably
objects that overlay each other. Will set polygon values of item with FID: " +
f.getID() +
- " to NaN. Use " +
I18N.get("org.openjump.sigle.plugin.SpatialJoinPlugIn.Transfer-Attributes") +
- " or " +
I18N.get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.Join-Attributes-Spatially")
+
- " functions to obtain atributes from "
+ GenericNames.LAYER_B);
- }
- } else if (foundCountB == 0) {
- if (context != null) {
- //
context.getWorkbenchFrame().warnUser("no corresponding
- // feature in Layer B");
- }
+ errorInB = true;
+ errorsInB.add(f.getID());
}
if ((foundCountA > 0) || (foundCountB > 0)){
// -- before mapping check and set for error
values
if (errorInA){
- featureA =
resetFeatureValuesToNaN(featureA);
+ featureA =
resetFeatureValuesToNull(featureA);
}
if (errorInB){
- featureB =
resetFeatureValuesToNaN(featureB);
+ featureB =
resetFeatureValuesToNull(featureB);
}
// -- do mapping
mapping.transferAttributes(featureA, featureB,
f);
@@ -316,33 +285,61 @@
f.setGeometry((Geometry) geom.clone());
fd.add(f);
}
-// else{
-// System.out.println("polygon without
correspondent");
-// }
}
- // --
+ if (context != null) {
+ if (errorsInA.size() > 0 || errorsInB.size() > 0) {
+ String errorStrg =
I18N.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Found-more-than-one-source-feature-in-Layer");
+ String layers = "";
+ if (errorsInA.size() > 0) {
+ layers = layers + " " +
GenericNames.LAYER_A;
+ context.getWorkbenchFrame().getOutputFrame().createNewDocument();
+
context.getWorkbenchFrame().getOutputFrame().addText(
+
"IntersectPolygonLayersPlugIn: " + errorStrg + ": " + GenericNames.LAYER_A +
"." +
+ "\n" +
+
"Reason: The Layer contains probably objects that overlay each other. Will set
polygon values of items with FID: " + errorsInA +
+ " to
NaN. Use " +
I18N.get("org.openjump.sigle.plugin.SpatialJoinPlugIn.Transfer-Attributes") +
+ " or "
+
I18N.get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.Join-Attributes-Spatially")
+
+ "
functions to obtain atributes from " + GenericNames.LAYER_A);
+ }
+ if (errorsInB.size() > 0) {
+ layers = layers + " " +
GenericNames.LAYER_B;
+ context.getWorkbenchFrame().getOutputFrame().createNewDocument();
+
context.getWorkbenchFrame().getOutputFrame().addText(
+
"IntersectPolygonLayersPlugIn: " + errorStrg + ": " + GenericNames.LAYER_B +
"." +
+ "\n" +
+
"Reason: The Layer contains probably objects that overlay each other. Will set
polygon values of items with FID: " + errorsInB +
+ " to
NaN. Use " +
I18N.get("org.openjump.sigle.plugin.SpatialJoinPlugIn.Transfer-Attributes") +
+ " or "
+
I18N.get("org.openjump.core.ui.plugin.tools.JoinAttributesSpatiallyPlugIn.Join-Attributes-Spatially")
+
+ "
functions to obtain atributes from " + GenericNames.LAYER_B);
+ }
+ context.getWorkbenchFrame().warnUser(errorStrg
+ layers);
+ }
+ }
return fd;
}
/**
* All values are set to NaN.
- * @param f
+ * @param f feature to reset
*/
- public static Feature resetFeatureValuesToNaN(Feature f){
+ static Feature resetFeatureValuesToNull(Feature f){
//-- work only on a copy so the original feature isn't changed
Feature ftemp = f.clone(true);
FeatureSchema fs = ftemp.getSchema();
- for (int i =0; i < fs.getAttributeCount(); i++){
+ for (int i = 0; i < fs.getAttributeCount(); i++){
AttributeType type = fs.getAttributeType(i);
if (!type.equals(AttributeType.GEOMETRY)){
if(type.equals(AttributeType.DOUBLE)){
- ftemp.setAttribute(i, Double.NaN);
+ ftemp.setAttribute(i, null);
}
if(type.equals(AttributeType.INTEGER)){
ftemp.setAttribute(i, null);
}
+ if(type.equals(AttributeType.LONG)){
+ ftemp.setAttribute(i, null);
+ }
if(type.equals(AttributeType.STRING)){
- ftemp.setAttribute(i, "NaN");
+ ftemp.setAttribute(i, null);
}
if(type.equals(AttributeType.OBJECT)){
ftemp.setAttribute(i, null);
@@ -350,191 +347,28 @@
if(type.equals(AttributeType.DATE)){
ftemp.setAttribute(i, null);
}
+ if(type.equals(AttributeType.BOOLEAN)){
+ ftemp.setAttribute(i, null);
+ }
}
}
return ftemp;
}
-
- /**
- * Merges/Intersects two polygon layers into one layer. It therefore
- * calculates all geometric intersections between the polygons.
Afterwards
- * the attributes are transferred. The later step assumes that a new
created
- * intersection polygon has at max only one correspondent polygon per
layer.
- * Note: this approach using the IntersectGeometries() class results in
- * unwanted spikes during the polygon intersection. The method
runIntersectionNew()
- * tries to avoid this by not using the polygon intersection but
creating polygons
- * from all lines derived from the polygons and removing some of those.
- *
- * @param fcA
- * @param fcB
- * @param accuraccy this parameter has currently no effect (now the
default fixed precision model is used)
- * @param transferAttributes should attributes be transfered?
- * @param monitor can be null
- * @param context can be null
- * @return a FeatureCollection that contains the result of the
intersection
- * (i.e. the new created features)
- */
- private FeatureCollection runIntersectionOld(FeatureCollection fcA,
- FeatureCollection fcB, double accurracy, boolean
transferAttributes,
- TaskMonitor monitor, PlugInContext context) {
- FeatureCollection fd = null;
- // -- put all geoms in one list and calculate their
intersections
- // i.e. iterate until pure
- ArrayList<Geometry> geomsToCheck = new ArrayList<Geometry>();
- for (Iterator iterator = fcA.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- geomsToCheck.add(f.getGeometry());
- }
- for (Iterator iterator = fcB.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- geomsToCheck.add(f.getGeometry());
- }
- // -- sort out the different geometry types
- for (Iterator iterator = geomsToCheck.iterator();
iterator.hasNext();) {
- Geometry geom = (Geometry) iterator.next();
- if ((geom instanceof Polygon) || (geom instanceof
MultiPolygon)) {
- // everything is fine
- } else {
- // --
- if (context != null) {
- context
- .getWorkbenchFrame()
- .warnUser(
- I18N
-
.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Geometry-no-Polygon-or-Multi-Polygon"));
- }
- // --
- return null;
- }
- }
- ArrayList<Geometry> withoutIntersection = IntersectGeometries
- .intersectPolygons(geomsToCheck, accurracy,
monitor, context);
- if (transferAttributes == false) {
- fd =
FeatureDatasetFactory.createFromGeometry(withoutIntersection);
- return fd;
- }
- if (monitor != null) {
- monitor.report(this.sTRANSFER);
- }
- // ===================== Transfer Attributes ==================
- // note: if we transfer attributes we need a unique set of
- // FeatureSchemas
- // Hence a feature that has a corespondant in only one layer
should
- // still
- // have all attributes from both source layers.
- // ============================================================
- // -- put all original objects in trees for faster query
- SpatialIndex treeA = new STRtree();
- for (Iterator iterator = fcA.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- treeA.insert(f.getGeometry().getEnvelopeInternal(), f);
- }
- SpatialIndex treeB = new STRtree();
- for (Iterator iterator = fcB.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- treeB.insert(f.getGeometry().getEnvelopeInternal(), f);
- }
- // -- get all intersecting features (usually there should be
only one
- // corresponding feature per layer)
- // to avoid problems with spatial predicates we do the query
for an
- // internal point of the result polygons
- // and apply an point in polygon test
- AttributeMapping mapping = new
AttributeMapping(fcA.getFeatureSchema(),
- fcB.getFeatureSchema());
- // -- create the empty dataset with the final FeatureSchema
- fd = new FeatureDataset(mapping.createSchema("Geometry"));
- // -- add the features and do the attribute mapping
- for (Iterator iterator = withoutIntersection.iterator();
iterator
- .hasNext();) {
- Geometry geom = (Geometry) iterator.next();
- Point pt = geom.getInteriorPoint();
- Feature f = new BasicFeature(fd.getFeatureSchema());
- Feature featureA = null;
- Feature featureB = null;
- // -- query Layer A ---
- List candidatesA =
treeA.query(pt.getEnvelopeInternal());
- int foundCountA = 0;
- for (Iterator iterator2 = candidatesA.iterator();
iterator2
- .hasNext();)
- {
- Feature ftemp = (Feature) iterator2.next();
- if (ftemp.getGeometry().contains(pt)) {
- foundCountA++;
- featureA = ftemp;
- }
- }
- if (foundCountA > 1) {
- if (context != null) {
- context
- .getWorkbenchFrame()
- .warnUser(
- I18N
-
.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Found-more-than-one-source-feature-in-Layer")
-
+ " " + GenericNames.LAYER_A);
- }
- } else if (foundCountA == 0) {
- if (context != null) {
- //
context.getWorkbenchFrame().warnUser("no corresponding
- // feature in Layer A");
- }
- }
- // -- query Layer B ---
- List candidatesB =
treeB.query(pt.getEnvelopeInternal());
- int foundCountB = 0;
- for (Iterator iterator2 = candidatesB.iterator();
iterator2
- .hasNext();)
- {
- Feature ftemp = (Feature) iterator2.next();
- if (ftemp.getGeometry().contains(pt)) {
- foundCountB++;
- featureB = ftemp;
- }
- }
- if (foundCountB > 1) {
- if (context != null) {
- context
- .getWorkbenchFrame()
- .warnUser(
- I18N
-
.get("org.openjump.plugin.tools.IntersectPolygonLayersPlugIn.Found-more-than-one-source-feature-in-Layer")
-
+ " " + GenericNames.LAYER_B);
- }
- } else if (foundCountB == 0) {
- if (context != null) {
- //
context.getWorkbenchFrame().warnUser("no corresponding
- // feature in Layer B");
- }
- }
- // -- do mapping
- mapping.transferAttributes(featureA, featureB, f);
- // -- set Geometry
- f.setGeometry((Geometry) geom.clone());
- fd.add(f);
- }
- // --
- return fd;
- }
-
private void setDialogValues(MultiInputDialog dialog, PlugInContext
context) {
dialog.setSideBarDescription(sDescription);
- // Set initial layer values to the first and second layers in
the layer
- // list.
+ // Set initial layer values to the first and second layers in
the layer list.
// In #initialize we've already checked that the number of
layers >= 2.
// [Jon Aquino]
dialog.addLayerComboBox(LAYER1, layer1,
context.getLayerManager());
dialog.addLayerComboBox(LAYER2, layer2,
context.getLayerManager());
- //dialog.addDoubleField(sAccurracy, this.accurracy, 7);
- //dialog.addCheckBox(sTRANSFER, this.transferAtt);
-
}
+
private void getDialogValues(MultiInputDialog dialog) {
layer1 = dialog.getLayer(LAYER1);
layer2 = dialog.getLayer(LAYER2);
- //this.transferAtt = dialog.getBoolean(sTRANSFER);
- //this.accurracy = dialog.getDouble(sAccurracy);
}
}
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel