[Schmitzm-commits] r730 - trunk/src/skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 26 16:22:26 CET 2010


Author: alfonx
Date: 2010-02-26 16:22:25 +0100 (Fri, 26 Feb 2010)
New Revision: 730

Modified:
   trunk/src/skrueger/geotools/XMapPane.java
Log:
More GUI adjustment in DesignMapViewDialog

Modified: trunk/src/skrueger/geotools/XMapPane.java
===================================================================
--- trunk/src/skrueger/geotools/XMapPane.java	2010-02-26 13:27:33 UTC (rev 729)
+++ trunk/src/skrueger/geotools/XMapPane.java	2010-02-26 15:22:25 UTC (rev 730)
@@ -30,6 +30,7 @@
 import javax.swing.border.Border;
 
 import org.apache.log4j.Logger;
+import org.geotools.data.FeatureSource;
 import org.geotools.data.memory.MemoryFeatureCollection;
 import org.geotools.factory.GeoTools;
 import org.geotools.feature.FeatureCollection;
@@ -1280,8 +1281,7 @@
 
 			// The next command may take long time!
 			// long start = System.currentTimeMillis();
-			final ReferencedEnvelope layerBounds = GTUtil
-					.getVisibleLayoutBounds(localContext);
+			final ReferencedEnvelope layerBounds = getVisibleLayoutBounds(localContext);
 			//			
 			// LOGGER.info(
 			// (System.currentTimeMillis()-start)+"m to get maxExtend");
@@ -1298,7 +1298,73 @@
 		return maxExtend;
 	}
 
+	public static final String SPECIAL_LINES_LAYER_ID = "SPECIAL_LINES_LAYER_ID";
+
 	/**
+	 * This method ignores sepcial layers like {@link #SPECIAL_LINES_LAYER_ID}
+	 */
+	protected ReferencedEnvelope getVisibleLayoutBounds(MapContext context) {
+		ReferencedEnvelope result = null;
+		CoordinateReferenceSystem crs = context.getAreaOfInterest()
+				.getCoordinateReferenceSystem();
+
+		final int length = context.getLayerCount();
+		MapLayer layer;
+		FeatureSource<SimpleFeatureType, SimpleFeature> fs;
+		ReferencedEnvelope env;
+		CoordinateReferenceSystem sourceCrs;
+
+		for (int i = 0; i < length; i++) {
+			layer = context.getLayer(i);
+
+			if (!layer.isVisible())
+				continue;
+
+			
+			if (layer.getTitle().equals(SPECIAL_LINES_LAYER_ID))
+				continue;
+			/*
+			 * fs = layer.getFeatureSource(); sourceCrs =
+			 * fs.getSchema().getDefaultGeometry() .getCoordinateSystem(); env =
+			 * new ReferencedEnvelope(fs.getBounds(), sourceCrs);
+			 */
+
+			env = layer.getBounds();
+			if (env == null) {
+				continue;
+			} else {
+				try {
+					sourceCrs = env.getCoordinateReferenceSystem();
+					if ((sourceCrs != null) && crs != null
+							&& !CRS.equalsIgnoreMetadata(sourceCrs, crs)) {
+						env = env.transform(crs, true);
+					}
+
+				} catch (FactoryException e) {
+					LOGGER
+							.warn(
+									"Data source and map context coordinate system differ, yet it was not possible to get a projected bounds estimate...",
+									e);
+				} catch (TransformException e) {
+					LOGGER
+							.warn(
+									"Data source and map context coordinate system differ, yet it was not possible to get a projected bounds estimate...",
+									e);
+				}
+
+				if (result == null) {
+					result = env;
+				} else {
+					result.expandToInclude(env);
+				}
+			}
+		}
+
+		return result;
+
+	}
+
+	/**
 	 * Retuns the maximum allowed zoom scale. This is the smaller number value
 	 * of the two. Defaults to {@link Double}.MIN_VALUE
 	 * 



More information about the Schmitzm-commits mailing list