001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/MapFactory.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042:
043: ---------------------------------------------------------------------------*/
044: package org.deegree.graphics;
045:
046: import org.deegree.graphics.sld.UserStyle;
047: import org.deegree.model.coverage.grid.GridCoverage;
048: import org.deegree.model.crs.CoordinateSystem;
049: import org.deegree.model.feature.FeatureCollection;
050: import org.deegree.model.spatialschema.Envelope;
051:
052: /**
053: * Factory class for creating <tt>MapView</tt>s, <tt>Layer</tt>s and <tt>Theme</tt>s.
054: *
055: * <p>
056: * ------------------------------------------------------------------------
057: * </p>
058: *
059: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
060: * @version $Revision: 9340 $ $Date: 2007-12-27 04:32:12 -0800 (Thu, 27 Dec 2007) $
061: */
062: public class MapFactory {
063: /**
064: * creates an empty feature layer with EPSG:4326 as default coordinate reference system. All
065: * data that will be added to the layer will be converted to the EPSG:4326 coordinate reference
066: * system if no other CRS is set.
067: */
068: public static synchronized Layer createFeatureLayer(String name)
069: throws Exception {
070: return new FeatureLayer(name);
071: }
072:
073: /**
074: * creates an empty feature layer. All data that will be added to the layer will be converted to
075: * the submitted coordinate reference system if no other CRS is set.
076: */
077: public static synchronized Layer createFeatureLayer(String name,
078: CoordinateSystem crs) throws Exception {
079: return new FeatureLayer(name, crs);
080: }
081:
082: /**
083: * creates a complete feature layer. If the CRS of the geometries contained within the submitted
084: * feature collection are not the same as the submitted CRS all geometries will be converted to
085: * the submitted CRS.
086: */
087: public static synchronized Layer createFeatureLayer(String name,
088: CoordinateSystem crs, FeatureCollection fc)
089: throws Exception {
090: return new FeatureLayer(name, crs, fc);
091: }
092:
093: /**
094: * creates a raster layer. The required CRS is contained within the <tt>GC_GridCoverage</tt>
095: * object
096: */
097: public static synchronized Layer createRasterLayer(String name,
098: GridCoverage raster) throws Exception {
099: return new RasterLayer(name, raster);
100: }
101:
102: /**
103: * creates a theme with a name, a Layer containing the themes data and an array of styles to be
104: * known by the <tt>Theme</tt>
105: */
106: public static synchronized Theme createTheme(String name,
107: Layer layer, UserStyle[] styles) {
108: return new Theme(name, layer, styles);
109: }
110:
111: /**
112: * creates a theme with a name, a Layer containing the themes data and an array of styles to be
113: * known by the <tt>Theme</tt>
114: */
115: public static synchronized Theme createTheme(String name,
116: Layer layer) {
117: return new Theme(name, layer, new UserStyle[] { null });
118: }
119:
120: /**
121: * creates a <tt>MapView</tt> with a name, a boundingbox describing the area coverd by the
122: * <tt>MapView</tt>, a CRS and n <tt>Theme</tt>s.
123: */
124: public static synchronized MapView createMapView(String name,
125: Envelope boundingbox, CoordinateSystem crs, Theme[] themes,
126: double pixelsize) throws Exception {
127: MapView mv = new MapView(name, boundingbox, crs, pixelsize);
128: for (int i = 0; i < themes.length; i++) {
129: mv.addTheme(themes[i]);
130: }
131:
132: return mv;
133: }
134:
135: }
|