Revision: 5183
http://sourceforge.net/p/jump-pilot/code/5183
Author: ma15569
Date: 2016-11-13 17:16:27 +0000 (Sun, 13 Nov 2016)
Log Message:
-----------
Workaround for 437 Sextante Explore tool doesn't understand OpenJUMP multi
geometries vector layers . Excluded multi geometries layers: Sextante doesn't
decode anyhow those files for vector analysis (GvSIG CE adopted the same
solution)
Modified Paths:
--------------
plug-ins/SextantePlugIn/src/es/unex/sextante/openjump/gui/OpenJUMPInputFactory.java
Modified:
plug-ins/SextantePlugIn/src/es/unex/sextante/openjump/gui/OpenJUMPInputFactory.java
===================================================================
---
plug-ins/SextantePlugIn/src/es/unex/sextante/openjump/gui/OpenJUMPInputFactory.java
2016-11-13 16:58:26 UTC (rev 5182)
+++
plug-ins/SextantePlugIn/src/es/unex/sextante/openjump/gui/OpenJUMPInputFactory.java
2016-11-13 17:16:27 UTC (rev 5183)
@@ -4,11 +4,13 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
import org.geotools.dbffile.DbfFile;
import org.openjump.core.apitools.IOTools;
+import org.openjump.core.geomutils.GeoUtils;
import org.openjump.core.rasterimage.GeoTiffConstants;
import org.openjump.core.rasterimage.GridAscii;
import org.openjump.core.rasterimage.GridFloat;
@@ -89,7 +91,10 @@
// [Giuseppe Aruta Oct 2016] - Vector
// We exclude image files loaded
// via Layer.class
- if (!feat.isEmpty() && !isImageLayer((Layer) layerable)) {
+ // Also we exclude mixed geometries: Sextante doesn't
decode
+ // them anyhow for vector analysis
+ if (!feat.isEmpty() && !isImageLayer((Layer) layerable)
+ && !isMixedGeometryType((Layer) layerable)) {
obj = new OpenJUMPVectorLayer();
((OpenJUMPVectorLayer) obj).create((Layer) layerable);
layers.add(obj);
@@ -115,6 +120,77 @@
}
+ /**
+ * Layer.class
+ *
+ * @return true if the layer (Layer.class) belongs form an image file (eg.
+ * JPG, TIF, ECW)
+ */
+ public static boolean isImageLayer(Layer layer) {
+ if (layer.getStyle(ReferencedImageStyle.class) != null) {
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean isMixedGeometryType(Layer layer) {
+ FeatureCollectionWrapper featureCollection = layer
+ .getFeatureCollectionWrapper();
+ @SuppressWarnings("unchecked")
+ List<Feature> featureList = featureCollection.getFeatures();
+ BitSet layerBit = new BitSet();
+ BitSet currFeatureBit = new BitSet();
+ if (featureList.size() > 0) {
+ Geometry firstGeo = ((Feature) featureList.iterator().next())
+ .getGeometry();
+ layerBit = GeoUtils.setBit(layerBit, firstGeo); // this is the
layer
+ // type
+ }
+ for (Iterator<Feature> i = featureList.iterator(); i.hasNext();) {
+ Feature feature = (Feature) i.next();
+ Geometry geo = feature.getGeometry();
+ currFeatureBit = GeoUtils.setBit(currFeatureBit, geo);
+ }
+ if ((layerBit.get(GeoUtils.pointBit) && currFeatureBit
+ .get(GeoUtils.lineBit))
+ || (layerBit.get(GeoUtils.polyBit) && currFeatureBit
+ .get(GeoUtils.lineBit))
+ || (layerBit.get(GeoUtils.pointBit) && currFeatureBit
+ .get(GeoUtils.polyBit))) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Boolean (Layer.class). True if all the layer geometries are empty
+ * (Geometrycollection empty). Workaround to decode .csv files and to load
+ * in Sextante as table
+ *
+ * @return
+ */
+
+ public static boolean isTable(Layer layer) {
+ FeatureCollectionWrapper featureCollection = layer
+ .getFeatureCollectionWrapper();
+ List featureList = featureCollection.getFeatures();
+ Geometry nextGeo = null;
+ for (@SuppressWarnings("unchecked")
+ Iterator<FeatureCollectionWrapper> i = featureList.iterator(); i
+ .hasNext();) {
+ Feature feature = (Feature) i.next();
+ nextGeo = feature.getGeometry();
+ }
+ if (!featureCollection.isEmpty() && nextGeo.isEmpty()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public NamedExtent[] getPredefinedExtents() {
return new NamedExtent[0];
@@ -399,44 +475,4 @@
return env;
}
- /**
- * Boolean (Layer.class). True if all the layer geometries are empty
- * (Geometrycollection empty) but a feature colection is not empty.
- * Workaround to decode .csv files and to load in Sextante as table
- *
- * @return
- */
-
- public static boolean isTable(Layer layer) {
- FeatureCollectionWrapper featureCollection = layer
- .getFeatureCollectionWrapper();
- List featureList = featureCollection.getFeatures();
- Geometry nextGeo = null;
- for (@SuppressWarnings("unchecked")
- Iterator<FeatureCollectionWrapper> i = featureList.iterator(); i
- .hasNext();) {
- Feature feature = (Feature) i.next();
- nextGeo = feature.getGeometry();
- }
- if (!featureCollection.isEmpty() && nextGeo.isEmpty()) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Layer.class
- *
- * @return true if the layer (Layer.class) belongs form an image file (eg.
- * JPG, TIF, ECW)
- */
- public static boolean isImageLayer(Layer layer) {
- if (layer.getStyle(ReferencedImageStyle.class) != null) {
-
- return true;
- } else {
- return false;
- }
- }
}
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel