001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/graphics/MapFactory.java $
002 /*----------------------------------------------------------------------------
003 This file is part of deegree, http://deegree.org/
004 Copyright (C) 2001-2009 by:
005 Department of Geography, University of Bonn
006 and
007 lat/lon GmbH
008
009 This library is free software; you can redistribute it and/or modify it under
010 the terms of the GNU Lesser General Public License as published by the Free
011 Software Foundation; either version 2.1 of the License, or (at your option)
012 any later version.
013 This library is distributed in the hope that it will be useful, but WITHOUT
014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016 details.
017 You should have received a copy of the GNU Lesser General Public License
018 along with this library; if not, write to the Free Software Foundation, Inc.,
019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020
021 Contact information:
022
023 lat/lon GmbH
024 Aennchenstr. 19, 53177 Bonn
025 Germany
026 http://lat-lon.de/
027
028 Department of Geography, University of Bonn
029 Prof. Dr. Klaus Greve
030 Postfach 1147, 53001 Bonn
031 Germany
032 http://www.geographie.uni-bonn.de/deegree/
033
034 e-mail: info@deegree.org
035 ----------------------------------------------------------------------------*/
036 package org.deegree.graphics;
037
038 import org.deegree.graphics.sld.UserStyle;
039 import org.deegree.model.coverage.grid.GridCoverage;
040 import org.deegree.model.crs.CoordinateSystem;
041 import org.deegree.model.feature.FeatureCollection;
042 import org.deegree.model.spatialschema.Envelope;
043 import org.deegree.ogcwebservices.wms.operation.GetMap;
044
045 /**
046 * Factory class for creating <tt>MapView</tt>s, <tt>Layer</tt>s and <tt>Theme</tt>s. RB: Is this class really
047 * necessary? it just calls the appropriate constructors.
048 *
049 * <p>
050 * ------------------------------------------------------------------------
051 * </p>
052 *
053 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
054 * @version $Revision: 18195 $ $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
055 */
056 public class MapFactory {
057 /**
058 * creates an empty feature layer with EPSG:4326 as default coordinate reference system. All data that will be added
059 * to the layer will be converted to the EPSG:4326 coordinate reference system if no other CRS is set.
060 *
061 * @param name
062 * of the layer
063 * @return the layer with epsg:4326 set as crs
064 * @throws Exception
065 */
066 public static synchronized Layer createFeatureLayer( String name )
067 throws Exception {
068 return new FeatureLayer( name );
069 }
070
071 /**
072 * creates an empty feature layer. All data that will be added to the layer will be converted to the submitted
073 * coordinate reference system if no other CRS is set.
074 *
075 * @param name
076 * of the layer
077 * @param crs
078 * of the crs
079 * @return the feature layer with given crs and name.
080 * @throws Exception
081 */
082 public static synchronized Layer createFeatureLayer( String name, CoordinateSystem crs )
083 throws Exception {
084 return new FeatureLayer( name, crs );
085 }
086
087 /**
088 * creates a complete feature layer. If the CRS of the geometries contained within the submitted feature collection
089 * are not the same as the submitted CRS all geometries will be converted to the submitted CRS.
090 *
091 * @param name
092 * of the feature layer
093 * @param crs
094 * of the crs of the feature layer
095 * @param fc
096 * to get the geometries from
097 * @return to the Layer created from given paraemters.
098 * @throws Exception
099 */
100 public static synchronized Layer createFeatureLayer( String name, CoordinateSystem crs, FeatureCollection fc )
101 throws Exception {
102 return new FeatureLayer( name, crs, fc );
103 }
104
105 /**
106 * creates a raster layer. The required CRS is contained within the <tt>GC_GridCoverage</tt> object
107 *
108 * @param name
109 * name of raster layer
110 * @param raster
111 * the raster to create the layer from.
112 * @return the raster layer.
113 * @throws Exception
114 */
115 public static synchronized Layer createRasterLayer( String name, GridCoverage raster )
116 throws Exception {
117 return new RasterLayer( name, raster );
118 }
119
120 /**
121 * @param name
122 * @param raster
123 * @param request
124 * @return the new layer
125 * @throws Exception
126 */
127 public static synchronized Layer createRasterLayer( String name, GridCoverage raster, GetMap request )
128 throws Exception {
129 return new RasterLayer( name, raster, request );
130 }
131
132 /**
133 * creates a theme with a name, a Layer containing the themes data and an array of styles to be known by the
134 * <tt>Theme</tt>
135 *
136 * @param name
137 * of the theme
138 * @param layer
139 * the layer to create the theme from
140 * @param styles
141 * the styles to set
142 * @return the created theme from given parameters
143 */
144 public static synchronized Theme createTheme( String name, Layer layer, UserStyle[] styles ) {
145 return new Theme( name, layer, styles );
146 }
147
148 /**
149 * creates a theme with a name, a Layer containing the themes data and an array of styles to be known by the
150 * <tt>Theme</tt>
151 *
152 * @param name
153 * of the theme
154 * @param layer
155 * to use
156 * @return the created theme from given parameters
157 */
158 public static synchronized Theme createTheme( String name, Layer layer ) {
159 return new Theme( name, layer, new UserStyle[] { null } );
160 }
161
162 /**
163 * creates a <tt>MapView</tt> with a name, a boundingbox describing the area coverd by the <tt>MapView</tt>, a CRS
164 * and n <tt>Theme</tt>s.
165 *
166 * @param name
167 * of the mapview
168 * @param boundingbox
169 * of the mapview
170 * @param crs
171 * of the mapview
172 * @param themes
173 * of the mapview
174 * @param pixelsize
175 * used for rendering
176 * @return the mapview created from given parameters
177 * @throws Exception
178 */
179 public static synchronized MapView createMapView( String name, Envelope boundingbox, CoordinateSystem crs,
180 Theme[] themes, double pixelsize )
181 throws Exception {
182 MapView mv = new MapView( name, boundingbox, crs, pixelsize );
183 for ( int i = 0; i < themes.length; i++ ) {
184 mv.addTheme( themes[i] );
185 }
186
187 return mv;
188 }
189
190 }