001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/graphics/MapFactory.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2006 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.crs.UnknownCRSException;
050 import org.deegree.model.feature.FeatureCollection;
051 import org.deegree.model.spatialschema.Envelope;
052
053 /**
054 * Factory class for creating <tt>MapView</tt>s, <tt>Layer</tt>s and <tt>Theme</tt>s.
055 *
056 * <p>------------------------------------------------------------------------</p>
057 *
058 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
059 * @version $Revision: 6259 $ $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
060 */
061 public class MapFactory {
062 /**
063 * creates an empty feature layer with EPSG:4326 as default coordinate
064 * reference system. All data that will be added to the layer will be
065 * converted to the EPSG:4326 coordinate reference system if no other CRS
066 * 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
075 * will be converted to the submitted coordinate reference system if no other
076 * CRS is set.
077 */
078 public static synchronized Layer createFeatureLayer( String name, CoordinateSystem crs )
079 throws Exception {
080 return new FeatureLayer( name, crs );
081 }
082
083 /**
084 * creates a complete feature layer. If the CRS of the geometries contained
085 * within the submitted feature collection are not the same as the submitted
086 * CRS all geometries will be converted to the submitted CRS.
087 */
088 public static synchronized Layer createFeatureLayer( String name, CoordinateSystem crs,
089 FeatureCollection fc )
090 throws Exception {
091 return new FeatureLayer( name, crs, fc );
092 }
093
094 /**
095 * creates a raster layer. The required CRS is contained within the
096 * <tt>GC_GridCoverage</tt> object
097 */
098 public static synchronized Layer createRasterLayer( String name, GridCoverage raster )
099 throws Exception {
100 return new RasterLayer( name, raster );
101 }
102
103 /**
104 * creates a theme with a name, a Layer containing the themes data and an
105 * array of styles to be known by the <tt>Theme</tt>
106 */
107 public static synchronized Theme createTheme( String name, 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
113 * array of styles to be known by the <tt>Theme</tt>
114 */
115 public static synchronized Theme createTheme( String name, Layer layer ) {
116 return new Theme( name, layer, new UserStyle[] { null } );
117 }
118
119 /**
120 * creates a <tt>MapView</tt> with a name and a boundingbox describing the
121 * area coverd by the <tt>MapView</tt>. The <tt>MapView</tt> uses EPSG:4326
122 * as default coordinate reference system. All data (Themes, Layers) passed
123 * to the <tt>MapView</tt> will be converted to this CRS.
124 * @throws UnknownCRSException
125 */
126 public static synchronized MapView createMapView( String name, Envelope boundingbox )
127 throws UnknownCRSException {
128 return new MapView( name, boundingbox );
129 }
130
131 /**
132 * creates a <tt>MapView</tt> with a name, a boundingbox describing the
133 * area coverd by the <tt>MapView</tt> and a CRS. All data (Themes, Layers)
134 * passed to the <tt>MapView</tt> will be converted to this CRS.
135 */
136 public static synchronized MapView createMapView( String name, Envelope boundingbox,
137 CoordinateSystem crs ) {
138 return new MapView( name, boundingbox, crs );
139 }
140
141 /**
142 * creates a <tt>MapView</tt> with a name, a boundingbox describing the
143 * area coverd by the <tt>MapView</tt>, a CRS and n <tt>Theme</tt>s.
144 */
145 public static synchronized MapView createMapView( String name, Envelope boundingbox,
146 CoordinateSystem crs, Theme[] themes )
147 throws Exception {
148 MapView mv = new MapView( name, boundingbox, crs );
149
150 for ( int i = 0; i < themes.length; i++ ) {
151 mv.addTheme( themes[i] );
152 }
153
154 return mv;
155 }
156
157 /**
158 * creates a <tt>MapView</tt> with a name, a boundingbox describing the
159 * area coverd by the <tt>MapView</tt>, a CRS and n <tt>Layer</tt>s. For
160 * each submitted <tt>Layer</tt> a Theme having the same name as the Layer
161 * will be created.
162 */
163 public static synchronized MapView createMapView( String name, Envelope boundingbox,
164 CoordinateSystem crs, Layer[] layers )
165 throws Exception {
166 MapView mv = new MapView( name, boundingbox, crs );
167
168 for ( int i = 0; i < layers.length; i++ ) {
169 Theme theme = createTheme( layers[i].getName(), layers[i] );
170 mv.addTheme( theme );
171 }
172
173 return mv;
174 }
175 }/* ********************************************************************
176 Changes to this class. What the people have been up to:
177 $Log$
178 Revision 1.8 2007/02/09 17:28:00 poth
179 *** empty log message ***
180
181 Revision 1.7 2006/11/27 09:07:52 poth
182 JNI integration of proj4 has been removed. The CRS functionality now will be done by native deegree code.
183
184 Revision 1.6 2006/07/12 14:46:18 poth
185 comment footer added
186
187 ********************************************************************** */