[Schmitzm-commits] r894 - in trunk: src/schmitzm/geotools src/schmitzm/geotools/gui src/skrueger/geotools src_junit/schmitzm/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jun 4 11:19:11 CEST 2010
Author: alfonx
Date: 2010-06-04 11:19:07 +0200 (Fri, 04 Jun 2010)
New Revision: 894
Added:
trunk/src/schmitzm/geotools/epsg.properties
trunk/src_junit/schmitzm/geotools/GTUtilTest.java
Modified:
trunk/src/schmitzm/geotools/GTUtil.java
trunk/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java
trunk/src/skrueger/geotools/StyledFS.java
Log:
New mehtod with test in GTUtil
initEPSG() does
A) trigger the initilaiziation of the EPSG database
B) which may block the thread fro some time, but ensures that later the app runs smoother
C) add unoffical EPSG codes to GT which are defined in schmitzm/geotools/epsg.properties
epsg.properties at the moment contains unofficail NZ and Canadian EPSGs, as well as bloody Google EPSG:900913 !
Modified: trunk/src/schmitzm/geotools/GTUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/GTUtil.java 2010-06-03 19:01:53 UTC (rev 893)
+++ trunk/src/schmitzm/geotools/GTUtil.java 2010-06-04 09:19:07 UTC (rev 894)
@@ -30,6 +30,8 @@
package schmitzm.geotools;
import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.net.URL;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
@@ -39,12 +41,17 @@
import org.apache.log4j.Logger;
import org.geotools.data.FeatureSource;
+import org.geotools.factory.Hints;
import org.geotools.geometry.Envelope2D;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.map.MapContext;
import org.geotools.map.MapLayer;
+import org.geotools.metadata.iso.citation.Citations;
import org.geotools.referencing.CRS;
+import org.geotools.referencing.ReferencingFactoryFinder;
+import org.geotools.referencing.factory.PropertyAuthorityFactory;
+import org.geotools.referencing.factory.ReferencingFactoryContainer;
import org.geotools.renderer.GTRenderer;
import org.geotools.renderer.label.LabelCacheImpl;
import org.geotools.renderer.lite.StreamingRenderer;
@@ -54,6 +61,7 @@
import org.opengis.geometry.Envelope;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
/**
@@ -468,4 +476,52 @@
return result;
}
+ /**
+ * Makes GeoTools cache the EPSG database (we assume that we use epsg-hsql).
+ * This may take a few moments and pauses the thread.<br/>
+ * This method also adds some special unofficial EPSG codes to GeoTools,
+ * like 900913. The extra EPSG definitions are read from
+ * <code>/schmitzm/geotools/epsg.properties</code>
+ *
+ * @throws FactoryException
+ * @throws TransformException
+ * @throws IOException
+ */
+ public static void initEPSG() throws FactoryException, TransformException,
+ IOException {
+
+ // This action may take some time, and we never want it to happen on the
+ // Swing Thread
+// AVUtil.checkThatWeAreNotOnEDT();
+
+ URL epsgUrl = GTUtil.class
+ .getResource("/schmitzm/geotools/epsg.properties");
+
+ // you may try several locations...
+ Hints hints = new Hints(Hints.CRS_AUTHORITY_FACTORY,
+ PropertyAuthorityFactory.class);
+ ReferencingFactoryContainer referencingFactoryContainer = ReferencingFactoryContainer
+ .instance(hints);
+
+ PropertyAuthorityFactory factory = new PropertyAuthorityFactory(
+ referencingFactoryContainer, Citations.fromName("EPSG"),
+ epsgUrl);
+ ReferencingFactoryFinder.addAuthorityFactory(factory);
+ ReferencingFactoryFinder.scanForPlugins(); // hook everything up
+
+ final CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
+
+ // 900913 comes from the .properties file and is an unofficial EPSG code
+ // by Google
+ final CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:900913");
+
+ final com.vividsolutions.jts.geom.Envelope envelope = new com.vividsolutions.jts.geom.Envelope(0, 10, 0, 10);
+ final MathTransform transform = CRS.findMathTransform(sourceCRS,
+ targetCRS, true);
+
+ @SuppressWarnings("unused")
+ final com.vividsolutions.jts.geom.Envelope result = JTS.transform(envelope, transform);
+
+ }
+
}
Added: trunk/src/schmitzm/geotools/epsg.properties
===================================================================
--- trunk/src/schmitzm/geotools/epsg.properties 2010-06-03 19:01:53 UTC (rev 893)
+++ trunk/src/schmitzm/geotools/epsg.properties 2010-06-04 09:19:07 UTC (rev 894)
@@ -0,0 +1,33 @@
+900913=PROJCS["Google Mercator",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],UNIT["degree", 0.017453292519943295],AXIS["Geodetic latitude", NORTH],AXIS["Geodetic longitude", EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator (1SP)", AUTHORITY["EPSG","9804"]],PARAMETER["semi_major", 6378137.0],PARAMETER["semi_minor", 6378137.0],PARAMETER["latitude_of_origin", 0.0],PARAMETER["central_meridian", 0.0],PARAMETER["scale_factor", 1.0],PARAMETER["false_easting", 0.0],PARAMETER["false_northing", 0.0],UNIT["m", 1.0],AXIS["Easting", EAST],AXIS["Northing", NORTH],AUTHORITY["EPSG","900913"]]
+18001=PROJCS["Geoscience Australia Standard National Scale Lambert Projection",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1978",6378135,298.26],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",134.0],PARAMETER["latitude_of_origin",0.0],PARAMETER["standard_parallel_1",-18.0],PARAMETER["standard_parallel_2",-36.0],UNIT["Meter",1]]
+41001=PROJCS["WGS84 / Simple Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],UNIT["Meter",1]]
+42101=PROJCS["WGS 84 / LCC Canada",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",-95.0],PARAMETER["latitude_of_origin",0],PARAMETER["standard_parallel_1",49.0],PARAMETER["standard_parallel_2",77.0],PARAMETER["false_northing",-8000000.0],UNIT["Meter",1]]
+42102=PROJCS["BC_Albers",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["False_Easting",1000000],PARAMETER["Central_Meridian",-126],PARAMETER["Standard_Parallel_1",50],PARAMETER["Standard_Parallel_2",58.5],PARAMETER["Latitude_Of_Origin",45],UNIT["Meter",1]]
+42103=PROJCS["WGS 84 / LCC USA",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1978",6378135,298.26]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",-100.0],PARAMETER["latitude_of_origin",0],PARAMETER["standard_parallel_1",33.0],PARAMETER["standard_parallel_2",45.0],UNIT["Meter",1]]
+42104=PROJCS["NAD83 / MTM zone 8 Québec",GEOGCS["GRS80",DATUM["GRS_1980",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-73.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",304800],UNIT["Meter",1]]
+42105=PROJCS["WGS84 / Merc NorthAm",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",-96],UNIT["Meter",1]]
+42106=PROJCS["WGS84 / Lambert Azim Mozambique",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Azimuthal_Equal_Area"],PARAMETER["latitude_of_origin",5],PARAMETER["central_meridian",20],UNIT["Meter",1]]
+42301=PROJCS["NAD27 / Polar Stereographic / CM=-98",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213901],TOWGS84[-9,151,185]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Stereographic"],PARAMETER["latitude_of_origin",90],PARAMETER["central_meridian",-98.0],PARAMETER["scale_factor",0.9996],UNIT["Meter",1]]
+42302=PROJCS["JapanOrtho.09 09",GEOGCS["Lon/Lat.Tokyo Datum",DATUM["Tokyo Datum",SPHEROID["anon",6377397.155,299.15281310608]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["Central_Meridian",139.833333333333],PARAMETER["Latitude_of_Origin",36],PARAMETER["Scale_Factor",0.9999],UNIT["Meter",1]]
+42303=PROJCS["NAD83 / Albers NorthAm",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Albers_conic_equal_area"],PARAMETER["central_meridian",-96.0],PARAMETER["latitude_of_origin",23],PARAMETER["standard_parallel_1",29.5],PARAMETER["standard_parallel_2",45.5],UNIT["Meter",1]]
+42304=PROJCS["NAD83 / NRCan LCC Canada",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",-95.0],PARAMETER["latitude_of_origin",49.0],PARAMETER["standard_parallel_1",49.0],PARAMETER["standard_parallel_2",77.0],UNIT["Meter",1]]
+42305=PROJCS["France_II",GEOGCS["GCS_NTF_Paris",DATUM["Nouvelle_Triangulation_Francaise",SPHEROID["Clarke_1880_IGN",6378249.2,293.46602]],PRIMEM["Paris",2.337229166666667],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",600000],PARAMETER["False_Northing",2200000],PARAMETER["Central_Meridian",0],PARAMETER["Standard_Parallel_1",45.898918964419],PARAMETER["Standard_Parallel_2",47.696014502038],PARAMETER["Latitude_Of_Origin",46.8],UNIT["Meter",1]]
+42306=PROJCS["NAD83/QC_LCC",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",-68.5],PARAMETER["latitude_of_origin",44],PARAMETER["standard_parallel_1",46],PARAMETER["standard_parallel_2",60],UNIT["Meter",1]]
+42307=PROJCS["NAD83 / Texas Central - feet",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",31.8833333333333],PARAMETER["standard_parallel_2",30.1166666666667],PARAMETER["latitude_of_origin",29.6666666666667],PARAMETER["central_meridian",-100.333333333333],PARAMETER["false_easting",2296583.33333333333333],PARAMETER["false_northing",9842500],UNIT["US_Foot",0.30480060960121924]]
+42308=PROJCS["NAD27 / California Albers",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213901],TOWGS84[-9,151,185]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Albers_conic_equal_area"],PARAMETER["central_meridian",-120.0],PARAMETER["latitude_of_origin",0],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["false_northing",-4000000],UNIT["Meter",1]]
+42309=PROJCS["NAD 83 / LCC Canada AVHRR-2",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",-95.0],PARAMETER["latitude_of_origin",0],PARAMETER["standard_parallel_1",49.0],PARAMETER["standard_parallel_2",77.0],UNIT["Meter",1]]
+42310=PROJCS["WGS84+GRS80 / Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["GRS 1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],UNIT["Meter",1]]
+42311=PROJCS["NAD83 / LCC Statcan",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["central_meridian",-91.866667],PARAMETER["latitude_of_origin",63.390675],PARAMETER["standard_parallel_1",49],PARAMETER["standard_parallel_2",77],PARAMETER["false_easting",6200000],PARAMETER["false_northing",3000000],UNIT["Meter",1]]
+45555=PROJCS["WRF_Lambert_Conformal_Conic 2",GEOGCS["GCS_North_American_1983",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.25722356300003]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943299]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-97],PARAMETER["Standard_Parallel_1",33],PARAMETER["Standard_Parallel_2",60],PARAMETER["Latitude_Of_Origin",40.003338],UNIT["Meter",1],AUTHORITY["EPSG","45555"]]
+45556=PROJCS["Albers Equal area",GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AUTHORITY["EPSG","4326"]], PROJECTION["Albers Equal Area", AUTHORITY["EPSG","9822"]], PARAMETER["central_meridian", -96.0], PARAMETER["latitude_of_origin", 37.5], PARAMETER["standard_parallel_1", 29.833333333333336], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], PARAMETER["standard_parallel_2", 45.833333333333336], UNIT["m", 1.0], AUTHORITY["EPSG","45556"]]
+54004=PROJCS["WGS84 / Simple Mercator", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295]], PROJECTION["Mercator_1SP_Google"], PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH], AUTHORITY["EPSG","54004"]]
+100001=GEOGCS["NAD83 / NFIS Seconds",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["Decimal_Second",4.84813681109536e-06]]
+100002=PROJCS["NAD83 / Austin",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",31.8833333333333],PARAMETER["standard_parallel_2",30.1166666666667],PARAMETER["latitude_of_origin",29.6666666666667],PARAMETER["central_meridian",-100.333333333333],PARAMETER["false_easting",2296583.333333],PARAMETER["false_northing",9842500.0000000],UNIT["Meter",1]]
+100003=PROJCS["WGS84 / Google Mercator", GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AUTHORITY["EPSG","4326"]], PROJECTION["Mercator (1SP)", AUTHORITY["EPSG","9804"]], PARAMETER["semi_major", 6378137.0], PARAMETER["semi_minor", 6378137.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AUTHORITY["EPSG","900913"]]
+900913=PROJCS["WGS84 / Google Mercator", GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AUTHORITY["EPSG","4326"]], PROJECTION["Mercator (1SP)", AUTHORITY["EPSG","9804"]], PARAMETER["semi_major", 6378137.0], PARAMETER["semi_minor", 6378137.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0], PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AUTHORITY["EPSG","900913"]]
+30031000=PROJCS["Monte Mario / Italy zone 1 - Peninsular Part/Accuracy 3-4m", GEOGCS["Monte Mario", DATUM["Monte Mario", SPHEROID["International 1924", 6378388.0, 297.0, AUTHORITY["EPSG","7022"]], TOWGS84[-104.1, -49.1, -9.9, 0.971, -2.917, 0.714, -11.68], AUTHORITY["EPSG","6265"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4265"]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 9.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 1500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","30031000"]]
+30031001=PROJCS["Monte Mario / Italy zone 1 - Sardinia/Accuracy 3-4m", GEOGCS["Monte Mario", DATUM["Monte Mario", SPHEROID["International 1924", 6378388.0, 297.0, AUTHORITY["EPSG","7022"]], TOWGS84[-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48], AUTHORITY["EPSG","6265"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4265"]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 9.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 1500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","30031001"]]
+30031002=PROJCS["Monte Mario / Italy zone 1 - Sicily/Accuracy 3-4m", GEOGCS["Monte Mario", DATUM["Monte Mario", SPHEROID["International 1924", 6378388.0, 297.0, AUTHORITY["EPSG","7022"]], TOWGS84[-50.2,-50.4,84.8,-0.690,-2.012,0.459,-28.08], AUTHORITY["EPSG","6265"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4265"]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 9.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 1500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","30031002"]]
+30041000=PROJCS["Monte Mario / Italy zone 2 - Peninsular Part/Accuracy 3-4m", GEOGCS["Monte Mario", DATUM["Monte_Mario", SPHEROID["International 1924", 6378388.0, 297.0, AUTHORITY["EPSG","7022"]], TOWGS84[-104.1, -49.1, -9.9, 0.971, -2.917, 0.714, -11.68], AUTHORITY["EPSG","6265"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Lon", EAST], AXIS["Lat", NORTH], AUTHORITY["EPSG","4265"]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 15.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 2520000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH], AUTHORITY["EPSG","30041000"]]
+30041001=PROJCS["Monte Mario / Italy zone 2 - Sardinia/Accuracy 3-4m", GEOGCS["Monte Mario", DATUM["Monte_Mario", SPHEROID["International 1924", 6378388.0, 297.0, AUTHORITY["EPSG","7022"]], TOWGS84[-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48], AUTHORITY["EPSG","6265"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Lon", EAST], AXIS["Lat", NORTH], AUTHORITY["EPSG","4265"]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 15.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 2520000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH], AUTHORITY["EPSG","30041001"]]
+30041002=PROJCS["Monte Mario / Italy zone 2 - Sicily/Accuracy 3-4m", GEOGCS["Monte Mario", DATUM["Monte_Mario", SPHEROID["International 1924", 6378388.0, 297.0, AUTHORITY["EPSG","7022"]], TOWGS84[-50.2,-50.4,84.8,-0.690,-2.012,0.459,-28.08], AUTHORITY["EPSG","6265"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Lon", EAST], AXIS["Lat", NORTH], AUTHORITY["EPSG","4265"]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 15.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996], PARAMETER["false_easting", 2520000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH], AUTHORITY["EPSG","30041002"]]
Property changes on: trunk/src/schmitzm/geotools/epsg.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Modified: trunk/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java 2010-06-03 19:01:53 UTC (rev 893)
+++ trunk/src/schmitzm/geotools/gui/GeotoolsGUIUtil.java 2010-06-04 09:19:07 UTC (rev 894)
@@ -42,6 +42,8 @@
import org.apache.log4j.Logger;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.feature.FeatureCollection;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.referencing.ReferenceIdentifier;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -54,21 +56,28 @@
/**
* Diese Klasse enthaelt statische Hilfsmethoden im Bereich Geotools GUI.
- * @author <a href="mailto:Martin.Schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ *
+ * @author <a href="mailto:Martin.Schmitz at koeln.de">Martin Schmitz</a>
+ * (University of Bonn/Germany)
* @version 1.0
*/
public class GeotoolsGUIUtil {
- private static Logger LOGGER = Logger.getLogger( GeotoolsGUIUtil.class.getName() );
+ private static Logger LOGGER = Logger.getLogger(GeotoolsGUIUtil.class
+ .getName());
- /** {@link ResourceProvider}, der die Lokalisation fuer GUI-Komponenten
- * des Package {@code schmitzm.geotools.gui} zur Verfuegung stellt. Diese sind
- * in properties-Datein unter {@code schmitzm.geotools.gui.resource.locales}
- * hinterlegt. */
- public static ResourceProvider RESOURCE = ResourceProvider.newInstance( LangUtil.extendPackagePath(GeotoolsGUIUtil.class,"resource.locales.GTResourceBundle"), Locale.ENGLISH );
+ /**
+ * {@link ResourceProvider}, der die Lokalisation fuer GUI-Komponenten des
+ * Package {@code schmitzm.geotools.gui} zur Verfuegung stellt. Diese sind in
+ * properties-Datein unter {@code schmitzm.geotools.gui.resource.locales}
+ * hinterlegt.
+ */
+ public static ResourceProvider RESOURCE = ResourceProvider.newInstance(
+ LangUtil.extendPackagePath(GeotoolsGUIUtil.class,
+ "resource.locales.GTResourceBundle"), Locale.ENGLISH);
/**
- * Convenience method to access the translations in the {@link ResourceProvider}
- * resources.
+ * Convenience method to access the translations in the
+ * {@link ResourceProvider} resources.
*
* @param key
* the key for the properties file
@@ -79,214 +88,232 @@
return RESOURCE.getString(key, values);
}
-
- /** {@link FileNameExtensionFilter} fuer ArcInfoAscii-Raster. */
- public static final FileNameExtensionFilter FILTER_RASTER_ASCII = new FileNameExtensionFilter("ASCII-Raster (*.asc)","asc");
- /** {@link FileNameExtensionFilter} fuer GeoTiff-Raster. */
- public static final FileNameExtensionFilter FILTER_RASTER_GEOTIFF = new FileNameExtensionFilter("GeoTiff (*.tif)","tif");
- /** {@link FileNameExtensionFilter} fuer Shape-Files. */
- public static final FileNameExtensionFilter FILTER_FEATURE_SHAPE = new FileNameExtensionFilter("Shape-File (*.shp)","shp");
-
- /**
- * Zeigt einen Dialog zum Auswaehlen einer Datei an.
- * @param parent dem Dialog uebergeordnete GUI-Komponente
- * @param dialogType {@code JFileChooser.SAVE_DIALOG} oder {@code JFileChooser.OPEN_DIALOG}
- * @param title Titel, der im Dialog angezeigt wird (kann {@code null} sein)
- * @param initialDir Verzeichnis, das angezeigt wird (kann {@code null} sein)
- * @param filter (optionale) Filter, die im Dialog angewaehlt werden koennen
- * @return den FileChooser, in dem die Datei ausgewaehlt ist oder {@code null}
- * falls der Dialog abgebrochen wurde
- */
- private static JFileChooser chooseFile(Component parent, int dialogType, String title, File initialDir, FileFilter... filter) {
- final JFileChooser fileChooser = new JFileChooser(initialDir);
- fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- fileChooser.setMultiSelectionEnabled( false );
- for (FileFilter f : filter)
- fileChooser.addChoosableFileFilter(f);
- if ( filter.length > 0 ) {
- fileChooser.setFileFilter(filter[0]);
- fileChooser.setAcceptAllFileFilterUsed(false);
- }
- if ( title != null )
- fileChooser.setDialogTitle(title);
- int retValue = 0;
- if ( dialogType == JFileChooser.SAVE_DIALOG )
- retValue = fileChooser.showSaveDialog(parent);
- else if ( dialogType == JFileChooser.OPEN_DIALOG )
- retValue = fileChooser.showOpenDialog(parent);
- else
- throw new IllegalArgumentException("Unsupported dialog type: "+dialogType);
+ /** {@link FileNameExtensionFilter} fuer ArcInfoAscii-Raster. */
+ public static final FileNameExtensionFilter FILTER_RASTER_ASCII = new FileNameExtensionFilter(
+ "ASCII-Raster (*.asc)", "asc");
+ /** {@link FileNameExtensionFilter} fuer GeoTiff-Raster. */
+ public static final FileNameExtensionFilter FILTER_RASTER_GEOTIFF = new FileNameExtensionFilter(
+ "GeoTiff (*.tif)", "tif");
+ /** {@link FileNameExtensionFilter} fuer Shape-Files. */
+ public static final FileNameExtensionFilter FILTER_FEATURE_SHAPE = new FileNameExtensionFilter(
+ "Shape-File (*.shp)", "shp");
- if ( retValue != JFileChooser.APPROVE_OPTION )
- return null;
+ /**
+ * Zeigt einen Dialog zum Auswaehlen einer Datei an.
+ *
+ * @param parent
+ * dem Dialog uebergeordnete GUI-Komponente
+ * @param dialogType
+ * {@code JFileChooser.SAVE_DIALOG} oder {@code
+ * JFileChooser.OPEN_DIALOG}
+ * @param title
+ * Titel, der im Dialog angezeigt wird (kann {@code null} sein)
+ * @param initialDir
+ * Verzeichnis, das angezeigt wird (kann {@code null} sein)
+ * @param filter
+ * (optionale) Filter, die im Dialog angewaehlt werden koennen
+ * @return den FileChooser, in dem die Datei ausgewaehlt ist oder {@code
+ * null} falls der Dialog abgebrochen wurde
+ */
+ private static JFileChooser chooseFile(Component parent, int dialogType,
+ String title, File initialDir, FileFilter... filter) {
+ final JFileChooser fileChooser = new JFileChooser(initialDir);
+ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ fileChooser.setMultiSelectionEnabled(false);
+ for (FileFilter f : filter)
+ fileChooser.addChoosableFileFilter(f);
+ if (filter.length > 0) {
+ fileChooser.setFileFilter(filter[0]);
+ fileChooser.setAcceptAllFileFilterUsed(false);
+ }
+ if (title != null)
+ fileChooser.setDialogTitle(title);
+ int retValue = 0;
+ if (dialogType == JFileChooser.SAVE_DIALOG)
+ retValue = fileChooser.showSaveDialog(parent);
+ else if (dialogType == JFileChooser.OPEN_DIALOG)
+ retValue = fileChooser.showOpenDialog(parent);
+ else
+ throw new IllegalArgumentException("Unsupported dialog type: "
+ + dialogType);
- return fileChooser;
- }
+ if (retValue != JFileChooser.APPROVE_OPTION)
+ return null;
- /**
- * Zeigt einen Dialog zum Auswaehlen einer Export-Datei an. Die
- * Datei-Erweiterung wird entsprechend des ausgewaehlten Filters
- * automatisch angehaengt. Existiert die Datei bereits, wird zum Bestaetigen#
- * des Ueberschreibens aufgefordert.
- * @param parent dem Dialog uebergeordnete GUI-Komponente
- * @param dialogType {@code JFileChooser.SAVE_DIALOG} oder {@code JFileChooser.OPEN_DIALOG}
- * @param title Titel, der im Dialog angezeigt wird (kann {@code null} sein)
- * @param initialDir Verzeichnis, das angezeigt wird (kann {@code null} sein)
- * @param filter (optionale) Filter, die im Dialog angewaehlt werden koennen
- * @return den FileChooser, in dem die Datei ausgewaehlt ist oder {@code null}
- * falls der Dialog abgebrochen wurde
- */
- private static JFileChooser chooseExportFile(Component parent, String title, File initialDir, FileNameExtensionFilter... filter) {
- JFileChooser expFileChooser = null;
- do {
- // Export-Datei auswaehlen
- expFileChooser = chooseFile(
- parent,
- JFileChooser.SAVE_DIALOG,
- title,
- initialDir,
- filter
- );
- if ( expFileChooser == null )
- return null;
- // Verzeichnis merken
- initialDir = expFileChooser.getCurrentDirectory();
+ return fileChooser;
+ }
- // Ueberschreiben bestaetigen
- File expFile = expFileChooser.getSelectedFile();
- String expFileExt = ((FileNameExtensionFilter)expFileChooser.getFileFilter()).getExtensions()[0];
- expFile = IOUtil.appendFileExt(expFile, expFileExt);
- expFileChooser.setSelectedFile(expFile);
+ /**
+ * Zeigt einen Dialog zum Auswaehlen einer Export-Datei an. Die
+ * Datei-Erweiterung wird entsprechend des ausgewaehlten Filters automatisch
+ * angehaengt. Existiert die Datei bereits, wird zum Bestaetigen# des
+ * Ueberschreibens aufgefordert.
+ *
+ * @param parent
+ * dem Dialog uebergeordnete GUI-Komponente
+ * @param dialogType
+ * {@code JFileChooser.SAVE_DIALOG} oder {@code
+ * JFileChooser.OPEN_DIALOG}
+ * @param title
+ * Titel, der im Dialog angezeigt wird (kann {@code null} sein)
+ * @param initialDir
+ * Verzeichnis, das angezeigt wird (kann {@code null} sein)
+ * @param filter
+ * (optionale) Filter, die im Dialog angewaehlt werden koennen
+ * @return den FileChooser, in dem die Datei ausgewaehlt ist oder {@code
+ * null} falls der Dialog abgebrochen wurde
+ */
+ private static JFileChooser chooseExportFile(Component parent,
+ String title, File initialDir, FileNameExtensionFilter... filter) {
+ JFileChooser expFileChooser = null;
+ do {
+ // Export-Datei auswaehlen
+ expFileChooser = chooseFile(parent, JFileChooser.SAVE_DIALOG,
+ title, initialDir, filter);
+ if (expFileChooser == null)
+ return null;
+ // Verzeichnis merken
+ initialDir = expFileChooser.getCurrentDirectory();
- if ( !expFile.exists() || approveFileOverwrite(parent,expFile.getName()) )
- break;
- } while ( true );
+ // Ueberschreiben bestaetigen
+ File expFile = expFileChooser.getSelectedFile();
+ String expFileExt = ((FileNameExtensionFilter) expFileChooser
+ .getFileFilter()).getExtensions()[0];
+ expFile = IOUtil.appendFileExt(expFile, expFileExt);
+ expFileChooser.setSelectedFile(expFile);
- return expFileChooser;
+ if (!expFile.exists()
+ || approveFileOverwrite(parent, expFile.getName()))
+ break;
+ } while (true);
- }
- /**
- * Zeigt einen Dialog an, in dem das Ueberschreiben einer Datei bestaetigt
- * werden muss.
- * @param parent Uebergeordnete GUI-Komponente fuer die Meldung
- * @param filename Bezeichnung der Datei
- * @return {@code true}, falls das Ueberschreiben mit OK bestaetigt wurde
- */
- public static boolean approveFileOverwrite(Component parent, String filename) {
- int retValue = JOptionPane.showConfirmDialog(
- parent,
- filename,
- SwingUtil.RESOURCE.getString("Overwrite"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE
- );
- return retValue == JOptionPane.OK_OPTION;
- }
+ return expFileChooser;
- /**
- * Exportiert eine {@link FeatureCollection} in ein Shape-File. Dabei
- * wird ein Anwender-Dialog geoeffnet, um die Ziel-Datei auszuwaehlen.
- * Tritt ein Fehler beim Export auf, wird dieser in einem Dialog angezeigt.
- * @param parent dem Dialog uebergeordnete GUI-Komponente (kann {@code null} sein)
- * @param fc zu exportierende {@link FeatureCollection}
- * @param desc Beschreibung der FeatureCollection, die im Dialog-Titel angezeigt
- * wird (kann {@code null} sein)
- * @return die Export-Datei, oder {@code null} falls der Export abgebrochen
- * oder aufgrund eines Fehlers nicht durchgefuehrt wurde
- */
- public static URL exportFeatureCollection(Component parent, FeatureCollection fc, String desc) {
- String title = RESOURCE.getString("schmitzm.geotools.gui.GeotoolsGUIUtil.SaveFeature");
- if ( desc != null && !desc.trim().equals("") )
- title += " [" + desc.trim() + "]";
+ }
- // Export-Datei auswaehlen
- JFileChooser destFileChooser = chooseExportFile(
- parent,
- title,
- null,
- FILTER_FEATURE_SHAPE
- );
- if ( destFileChooser == null )
- return null;
- File destFile = destFileChooser.getSelectedFile();
+ /**
+ * Zeigt einen Dialog an, in dem das Ueberschreiben einer Datei bestaetigt
+ * werden muss.
+ *
+ * @param parent
+ * Uebergeordnete GUI-Komponente fuer die Meldung
+ * @param filename
+ * Bezeichnung der Datei
+ * @return {@code true}, falls das Ueberschreiben mit OK bestaetigt wurde
+ */
+ public static boolean approveFileOverwrite(Component parent, String filename) {
+ int retValue = JOptionPane.showConfirmDialog(parent, filename,
+ SwingUtil.RESOURCE.getString("Overwrite"),
+ JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
+ return retValue == JOptionPane.OK_OPTION;
+ }
- // FeatureCollection exportieren, je nach angewaehltem Format
- try {
- FileFilter fileFilter = destFileChooser.getFileFilter();
- if ( fileFilter == FILTER_FEATURE_SHAPE )
- GeoExportUtil.writeFeaturesToShapeFile(fc, destFile);
- else
- throw new UnsupportedOperationException("Chosen file format not supported: "+fileFilter.getDescription());
- return destFile.toURI().toURL();
- } catch (Exception err) {
- ExceptionDialog.show(parent,err);
- return null;
- }
- }
+ /**
+ * Exportiert eine {@link FeatureCollection} in ein Shape-File. Dabei wird
+ * ein Anwender-Dialog geoeffnet, um die Ziel-Datei auszuwaehlen. Tritt ein
+ * Fehler beim Export auf, wird dieser in einem Dialog angezeigt.
+ *
+ * @param parent
+ * dem Dialog uebergeordnete GUI-Komponente (kann {@code null}
+ * sein)
+ * @param fc
+ * zu exportierende {@link FeatureCollection}
+ * @param desc
+ * Beschreibung der FeatureCollection, die im Dialog-Titel
+ * angezeigt wird (kann {@code null} sein)
+ * @return die Export-Datei, oder {@code null} falls der Export abgebrochen
+ * oder aufgrund eines Fehlers nicht durchgefuehrt wurde
+ */
+ public static URL exportFeatureCollection(Component parent,
+ FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String desc) {
+ String title = RESOURCE
+ .getString("schmitzm.geotools.gui.GeotoolsGUIUtil.SaveFeature");
+ if (desc != null && !desc.trim().equals(""))
+ title += " [" + desc.trim() + "]";
- /**
- * Exportiert ein {@link GridCoverage2D} in eine Raster-Datei. Dabei
- * wird ein Anwender-Dialog geoeffnet, um die Ziel-Datei und den Datei-Typ
- * auszuwaehlen.
- * Tritt ein Fehler beim Export auf, wird dieser in einem Dialog angezeigt.
- * @param parent dem Dialog uebergeordnete GUI-Komponente (kann {@code null} sein)
- * @param gc zu exportierendes Raster
- * @param desc Beschreibung des Rasters, die im Dialog-Titel angezeigt
- * wird (kann {@code null} sein)
- * @return die Export-Datei, oder {@code null} falls der Export abgebrochen
- * oder aufgrund eines Fehlers nicht durchgefuehrt wurde
- */
- public static URL exportGridCoverage2D(Component parent, GridCoverage2D gc, String desc) {
- String title = RESOURCE.getString("schmitzm.geotools.gui.GeotoolsGUIUtil.SaveRaster");
- if ( desc != null && !desc.trim().equals("") )
- title += " [" + desc.trim() + "]";
-
- // Export-Datei auswaehlen
- JFileChooser destFileChooser = chooseExportFile(
- parent,
- title,
- null,
- FILTER_RASTER_ASCII,
- FILTER_RASTER_GEOTIFF
- );
- if ( destFileChooser == null )
- return null;
- File destFile = destFileChooser.getSelectedFile();
+ // Export-Datei auswaehlen
+ JFileChooser destFileChooser = chooseExportFile(parent, title, null,
+ FILTER_FEATURE_SHAPE);
+ if (destFileChooser == null)
+ return null;
+ File destFile = destFileChooser.getSelectedFile();
- // Raster exportieren, je nach angewaehltem Format
- try {
- FileFilter fileFilter = destFileChooser.getFileFilter();
- if ( fileFilter == FILTER_RASTER_ASCII )
- GeoExportUtil.writeGridToArcInfoASCII(gc, destFile);
- else if ( fileFilter == FILTER_RASTER_GEOTIFF )
- GeoExportUtil.writeGridToGeoTiff(gc, destFile);
- else
- throw new UnsupportedOperationException("Chosen file format not supported: "+fileFilter.getDescription());
- return destFile.toURI().toURL();
- } catch (Exception err) {
- ExceptionDialog.show(parent,err);
- return null;
- }
- }
+ // FeatureCollection exportieren, je nach angewaehltem Format
+ try {
+ FileFilter fileFilter = destFileChooser.getFileFilter();
+ if (fileFilter == FILTER_FEATURE_SHAPE)
+ GeoExportUtil.writeFeaturesToShapeFile(fc, destFile);
+ else
+ throw new UnsupportedOperationException(
+ "Chosen file format not supported: "
+ + fileFilter.getDescription());
+ return destFile.toURI().toURL();
+ } catch (Exception err) {
+ ExceptionDialog.show(parent, err);
+ return null;
+ }
+ }
- /**
- * @return a good guess for a human readable string description of this CRS. An empty string in the worst case.
+ /**
+ * Exportiert ein {@link GridCoverage2D} in eine Raster-Datei. Dabei wird
+ * ein Anwender-Dialog geoeffnet, um die Ziel-Datei und den Datei-Typ
+ * auszuwaehlen. Tritt ein Fehler beim Export auf, wird dieser in einem
+ * Dialog angezeigt.
+ *
+ * @param parent
+ * dem Dialog uebergeordnete GUI-Komponente (kann {@code null}
+ * sein)
+ * @param gc
+ * zu exportierendes Raster
+ * @param desc
+ * Beschreibung des Rasters, die im Dialog-Titel angezeigt wird
+ * (kann {@code null} sein)
+ * @return die Export-Datei, oder {@code null} falls der Export abgebrochen
+ * oder aufgrund eines Fehlers nicht durchgefuehrt wurde
*/
+ public static URL exportGridCoverage2D(Component parent, GridCoverage2D gc,
+ String desc) {
+ String title = RESOURCE
+ .getString("schmitzm.geotools.gui.GeotoolsGUIUtil.SaveRaster");
+ if (desc != null && !desc.trim().equals(""))
+ title += " [" + desc.trim() + "]";
+
+ // Export-Datei auswaehlen
+ JFileChooser destFileChooser = chooseExportFile(parent, title, null,
+ FILTER_RASTER_ASCII, FILTER_RASTER_GEOTIFF);
+ if (destFileChooser == null)
+ return null;
+ File destFile = destFileChooser.getSelectedFile();
+
+ // Raster exportieren, je nach angewaehltem Format
+ try {
+ FileFilter fileFilter = destFileChooser.getFileFilter();
+ if (fileFilter == FILTER_RASTER_ASCII)
+ GeoExportUtil.writeGridToArcInfoASCII(gc, destFile);
+ else if (fileFilter == FILTER_RASTER_GEOTIFF)
+ GeoExportUtil.writeGridToGeoTiff(gc, destFile);
+ else
+ throw new UnsupportedOperationException(
+ "Chosen file format not supported: "
+ + fileFilter.getDescription());
+ return destFile.toURI().toURL();
+ } catch (Exception err) {
+ ExceptionDialog.show(parent, err);
+ return null;
+ }
+ }
+
+ /**
+ * @return a good guess for a human readable string description of this CRS.
+ * An empty string in the worst case.
+ */
public static String getTitleForCRS(CoordinateReferenceSystem crs) {
- // try {
- // final ReferenceIdentifier name = mapCrs.getName();
- // if (name != null)
- // return name.getCode();
- // else
- // return mapCrs.toString();
- // } catch (final Exception e) {
- // return mapCrs.toString();
- // }
-
+
String layerCrsName = "";
-
- if (crs == null) return layerCrsName;
-
+
+ if (crs == null)
+ return layerCrsName;
+
try {
final ReferenceIdentifier name = crs.getName();
if (name != null)
Modified: trunk/src/skrueger/geotools/StyledFS.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFS.java 2010-06-03 19:01:53 UTC (rev 893)
+++ trunk/src/skrueger/geotools/StyledFS.java 2010-06-04 09:19:07 UTC (rev 894)
@@ -156,10 +156,17 @@
public CoordinateReferenceSystem getCrs() {
if (crs == null) {
crs = fs.getSchema().getCoordinateReferenceSystem();
- if (fs.getSchema().getCoordinateReferenceSystem() == null) {
- LOGGER.warn("Could not determine the CRS of " + getTitle()
- + ". Using default " + GeoImportUtil.getDefaultCRS());
- crs = GeoImportUtil.getDefaultCRS();
+ if (crs == null) {
+
+ crs = fs.getSchema().getGeometryDescriptor()
+ .getCoordinateReferenceSystem();
+
+ if (crs == null) {
+ LOGGER.warn("Could not determine the CRS of " + getTitle()
+ + ". Using default "
+ + GeoImportUtil.getDefaultCRS());
+ crs = GeoImportUtil.getDefaultCRS();
+ }
}
}
return crs;
@@ -292,8 +299,7 @@
* @return The {@link File} where the SLD was loaded from or
* <code>null</code> if there didn't exist a {@link File}.
*
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Tzeggai</a>
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
public File getSldFile() {
return sldFile;
@@ -366,12 +372,13 @@
/**
* Tries to load a style from the file denoted in {@link #getSldFile()}. If
* the file doesn't exits, return <code>null</code>;
+ *
* @return <code>true</code> is style was loaded
*/
public boolean loadStyle() {
if (getSldFile() == null)
return false;
-
+
try {
Style[] loadSLD = StylingUtil.loadSLD(getSldFile());
setStyle(loadSLD[0]);
Added: trunk/src_junit/schmitzm/geotools/GTUtilTest.java
===================================================================
--- trunk/src_junit/schmitzm/geotools/GTUtilTest.java 2010-06-03 19:01:53 UTC (rev 893)
+++ trunk/src_junit/schmitzm/geotools/GTUtilTest.java 2010-06-04 09:19:07 UTC (rev 894)
@@ -0,0 +1,22 @@
+package schmitzm.geotools;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.geotools.referencing.CRS;
+import org.junit.Test;
+import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.operation.TransformException;
+
+public class GTUtilTest {
+
+ @Test
+ public void testInitEPSG() throws FactoryException, TransformException, IOException {
+ GTUtil.initEPSG();
+
+ assertNotNull("Normal EPSG can not be resolved!", CRS.decode("EPSG:4326"));
+ assertNotNull("Extended EPSG from epsg.properties can not be resolved!", CRS.decode("EPSG:900913"));
+ }
+
+}
Property changes on: trunk/src_junit/schmitzm/geotools/GTUtilTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
More information about the Schmitzm-commits
mailing list