/[schmitzm]/trunk/src/skrueger/geotools/StyledFeatureCollection.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/StyledFeatureCollection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 40 by alfonx, Mon Apr 6 19:31:02 2009 UTC revision 1261 by alfonx, Thu Nov 11 13:12:50 2010 UTC
# Line 1  Line 1 
1  package skrueger.geotools;  /*******************************************************************************
2     * Copyright (c) 2009 Martin O. J. Schmitz.
3  import java.net.URL;   *
4  import java.util.Map;   * This file is part of the SCHMITZM library - a collection of utility
5  import java.util.HashMap;   * classes based on Java 1.6, focusing (not only) on Java Swing
6  import javax.swing.ImageIcon;   * and the Geotools library.
7     *
8  import org.geotools.styling.Style;   * The SCHMITZM project is hosted at:
9  import org.geotools.feature.FeatureCollection;   * http://wald.intevation.org/projects/schmitzm/
10  import org.geotools.feature.FeatureType;   *
11  import org.geotools.feature.AttributeType;   * This program is free software; you can redistribute it and/or
12     * modify it under the terms of the GNU Lesser General Public License
13  import schmitzm.geotools.feature.FeatureUtil;   * as published by the Free Software Foundation; either version 3
14     * of the License, or (at your option) any later version.
15  import skrueger.i8n.Translation;   *
16  import skrueger.AttributeMetaData;   * This program is distributed in the hope that it will be useful,
17     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  /**   * GNU General Public License for more details.
20   * This class provides a simple implementation of {@link StyledMapInterface}   *
21   * for {@link FeatureCollection}. The uncache functionality is not supported,   * You should have received a copy of the GNU Lesser General Public License (license.txt)
22   * because this class bases on an existing {@link FeatureCollection} object in   * along with this program; if not, write to the Free Software
23   * memory.   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24   * @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany)   * or try this link: http://www.gnu.org/licenses/lgpl.html
25   * @version 1.0   *
26   */   * Contributors:
27  public class StyledFeatureCollection extends AbstractStyledMap<FeatureCollection> implements StyledFeatureCollectionInterface {   *     Martin O. J. Schmitz - initial API and implementation
28     *     Stefan A. Tzeggai - additional utility classes
29    /** Holds the meta data for displaying a legend. */   ******************************************************************************/
30    protected Map<Integer,AttributeMetaData> attrMetaData = null;  package skrueger.geotools;
31    
32    /**  import java.io.IOException;
33     * Creates a styled {@link FeatureCollection} with language-specific informations.  import java.net.URL;
34     * @param fc the {@link FeatureCollection}  
35     * @param id a unique ID for the object  import javax.swing.ImageIcon;
36     * @param title a (language-specific) short description  
37     * @param desc a (language-specific) long description  import org.geotools.data.FeatureSource;
38     * @param keywords (language-specific) keywords for the geo objects  import org.geotools.data.collection.CollectionDataStore;
39     * @param style a display style (if {@code null}, a default style is created)  import org.geotools.data.store.EmptyFeatureCollection;
40     * @param attrMetaData meta data for displaying a legend  import org.geotools.feature.FeatureCollection;
41     * @param icon an icon for the object (can be {@code null})  import org.geotools.feature.NameImpl;
42     * @exception IllegalArgumentException if {@code null} is given as ID or geo object  import org.geotools.feature.collection.SubFeatureCollection;
43     */  import org.geotools.geometry.jts.ReferencedEnvelope;
44    public StyledFeatureCollection(FeatureCollection fc, String id, Translation title, Translation desc, Translation keywords, Style style, Map<Integer,AttributeMetaData> attrMetaData, ImageIcon icon) {  import org.geotools.styling.Style;
45      super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry().getCoordinateSystem(), id, title, desc, keywords, style, icon);  import org.opengis.feature.simple.SimpleFeature;
46      setAttributeMetaData( attrMetaData );  import org.opengis.feature.simple.SimpleFeatureType;
47    }  import org.opengis.feature.type.AttributeDescriptor;
48    import org.opengis.filter.Filter;
49    /**  
50     * Creates a styled {@link FeatureCollection} with language-specific informations.  import schmitzm.geotools.feature.FeatureUtil;
51     * @param fc the {@link FeatureCollection}  import schmitzm.geotools.feature.FeatureUtil.GeometryForm;
52     * @param id a unique ID for the object  import skrueger.AttributeMetadataImpl;
53     * @param title a (language-specific) short description  import skrueger.i8n.Translation;
54     * @param desc a (language-specific) long description  
55     * @param keywords (language-specific) keywords for the geo objects  /**
56     * @param style a display style with attribute meta data information   * This class provides a simple implementation of {@link StyledLayerInterface}
57     * @param icon an icon for the object (can be {@code null})   * for {@link FeatureCollection}. The uncache functionality is not supported,
58     * @exception IllegalArgumentException if {@code null} is given as ID or geo object   * because this class bases on an existing {@link FeatureCollection} object in
59     */   * memory.
60    public StyledFeatureCollection(FeatureCollection fc, String id, Translation title, Translation desc, Translation keywords, StyledMapStyle<Map<Integer,AttributeMetaData>> style, ImageIcon icon) {   *
61      super(fc, fc.getBounds(), fc.getSchema().getDefaultGeometry().getCoordinateSystem(), id, title, desc, keywords, style != null ? style.getGeoObjectStyle() : null, icon);   * @author <a href="mailto:[email protected]">Martin Schmitz</a>
62      setAttributeMetaData( style != null ? style.getMetaData() : null );   *         (University of Bonn/Germany)
63    }   * @version 1.0
64     */
65    /**  public class StyledFeatureCollection
66     * Creates a styled {@link FeatureCollection} with a language-specific title,                  extends
67     * no long description, no keywords, default attribute meta data and no icon.                  AbstractStyledLayer<FeatureCollection<SimpleFeatureType, SimpleFeature>>
68     * @param fc the {@link FeatureCollection}                  implements StyledFeatureCollectionInterface {
69     * @param id a unique ID for the object  
70     * @param title a short description          /** Holds the meta data for displaying a legend. */
71     * @param style a display style (if {@code null}, a default style is created)          protected AttributeMetadataMap<AttributeMetadataImpl> attrMetaData = null;
72     * @exception IllegalArgumentException if {@code null} is given as ID or geo object  
73     * @see #createDefaultAttributeMetaDataMap(FeatureCollection)          /**
74     */           * We be filled with a "virtual" {@link FeatureSource} on demand.
75    public StyledFeatureCollection(FeatureCollection fc, String id, Translation title, Style style) {           */
76      this(fc, id, title, null, null, style, null, null);          private FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = null;
77    }  
78            /**
79    /**           * A Filter that will be applied internally applied to this
80     * Creates a styled {@link FeatureCollection} with non-translated informations.           * FeatureCollection
81     * @param fc the {@link FeatureCollection}           **/
82     * @param id a unique ID for the object          private Filter filter = Filter.INCLUDE;
83     * @param title a short description  
84     * @param desc a long description          /**
85     * @param keywords keywords for the geo objects           * Creates a styled {@link FeatureCollection} with language-specific
86     * @param style a display style (if {@code null}, a default style is created)           * informations.
87     * @param attrMetaData meta data for displaying a legend           *
88     * @param icon an icon for the object (can be {@code null})           * @param fc
89     * @exception IllegalArgumentException if {@code null} is given as ID or geo object           *            the {@link FeatureCollection}
90     */           * @param id
91    public StyledFeatureCollection(FeatureCollection fc, String id, String title, String desc, String keywords, Style style, Map<Integer,AttributeMetaData> attrMetaData, ImageIcon icon) {           *            a unique ID for the object
92      this(fc, id, (Translation)null, null, null, style, attrMetaData, icon);           * @param title
93      setTitle(title);           *            a (language-specific) short description
94      setDesc(desc);           * @param desc
95      setKeywords(keywords);           *            a (language-specific) long description
96    }           * @param keywords
97             *            (language-specific) keywords for the geo objects
98    /**           * @param style
99     * Creates a styled {@link FeatureCollection} with non-translated informations.           *            a display style (if {@code null}, a default style is created)
100     * @param fc the {@link FeatureCollection}           * @param attrMetaData
101     * @param id a unique ID for the object           *            meta data for displaying a legend
102     * @param title a short description           * @param icon
103     * @param desc a long description           *            an icon for the object (can be {@code null})
104     * @param keywords keywords for the geo objects           * @exception IllegalArgumentException
105     * @param style a display style with attribute meta data information           *                if {@code null} is given as ID or geo object
106     * @param icon an icon for the object (can be {@code null})           */
107     * @exception IllegalArgumentException if {@code null} is given as ID or geo object          public StyledFeatureCollection(
108     */                          FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
109    public StyledFeatureCollection(FeatureCollection fc, String id, String title, String desc, String keywords, StyledMapStyle<Map<Integer,AttributeMetaData>> style, ImageIcon icon) {                          Translation title, Translation desc, Translation keywords,
110      this(fc,                          Style style, AttributeMetadataMap attrMetaData, ImageIcon icon) {
111           id,                  super(fc, fc.getBounds(), fc.getSchema().getGeometryDescriptor()
112           title,                                  .getCoordinateReferenceSystem(), id, title, desc, keywords,
113           desc,                                  style, icon);
114           keywords,                  setAttributeMetaData(attrMetaData);
115           style != null ? style.getGeoObjectStyle() : null,          }
116           style != null ? style.getMetaData() : null,  
117           icon          /**
118      );           * Creates a styled {@link FeatureCollection} with language-specific
119    }           * informations.
120             *
121    /**           * @param fc
122     * Creates a styled {@link FeatureCollection} with a non-translated title,           *            the {@link FeatureCollection}
123     * no long description, no keywords, default attribute meta data and no icon.           * @param id
124     * @param fc the {@link FeatureCollection}           *            a unique ID for the object
125     * @param id a unique ID for the object           * @param title
126     * @param title a short description           *            a (language-specific) short description
127     * @param style a display style (if {@code null}, a default style is created)           * @param desc
128     * @exception IllegalArgumentException if {@code null} is given as ID or geo object           *            a (language-specific) long description
129     * @see #createDefaultAttributeMetaDataMap(FeatureCollection)           * @param keywords
130     */           *            (language-specific) keywords for the geo objects
131    public StyledFeatureCollection(FeatureCollection fc, String id, String title, Style style) {           * @param style
132      this(fc, id, title, null, null, style, null, null);           *            a display style with attribute meta data information
133    }           * @param icon
134             *            an icon for the object (can be {@code null})
135    /**           * @exception IllegalArgumentException
136     * Creates a styled {@link FeatureCollection} with a non-translated title,           *                if {@code null} is given as ID or geo object
137     * no long description, no keywords, default attribute meta data and no icon.           */
138     * @param fc the {@link FeatureCollection}          public StyledFeatureCollection(
139     * @param id a unique ID for the object                          FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
140     * @param title a short description                          Translation title, Translation desc, Translation keywords,
141     * @param style a display style (if {@code null}, a default style is created)                          StyledLayerStyle<AttributeMetadataMap> style, ImageIcon icon) {
142     * @exception IllegalArgumentException if {@code null} is given as ID or geo object                  super(fc, fc.getBounds(), fc.getSchema().getGeometryDescriptor()
143     * @see #createDefaultAttributeMetaDataMap(FeatureCollection)                                  .getCoordinateReferenceSystem(), id, title, desc, keywords,
144     */                                  style != null ? style.getGeoObjectStyle() : null, icon);
145    public StyledFeatureCollection(FeatureCollection fc, String id, String title, StyledMapStyle<Map<Integer,AttributeMetaData>> style) {                  setAttributeMetaData(style != null ? style.getMetaData() : null);
146      this(          }
147        fc,  
148        id,          /**
149        title,           * Creates a styled {@link FeatureCollection} with a language-specific
150        null,           * title, no long description, no keywords, default attribute meta data and
151        null,           * no icon.
152        style != null ? style.getGeoObjectStyle() : null,           *
153        style != null ? style.getMetaData() : null,           * @param fc
154        null           *            the {@link FeatureCollection}
155      );           * @param id
156    }           *            a unique ID for the object
157             * @param title
158    /**           *            a short description
159     * Creates a default style for the {@link FeatureCollection}.           * @param style
160     * @see FeatureUtil#createDefaultStyle(FeatureCollection)           *            a display style (if {@code null}, a default style is created)
161     */           * @exception IllegalArgumentException
162    protected Style createDefaultStyle() {           *                if {@code null} is given as ID or geo object
163      return FeatureUtil.createDefaultStyle( geoObject );           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
164    }           */
165            public StyledFeatureCollection(
166    /**                          FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
167     * Returns the meta data needed for displaying a legend.                          Translation title, Style style) {
168     */                  this(fc, id, title, null, null, style, null, null);
169    public Map<Integer,AttributeMetaData> getAttributeMetaDataMap() {          }
170      return attrMetaData;  
171    }          /**
172             * Creates a styled {@link FeatureCollection} with non-translated
173    /**           * informations.
174     * Sets the meta data needed for displaying a legend.           *
175     * If {@code legendData} is {@code null} an empty map is set, so           * @param fc
176     * {@link #getAttributeMetaDataMap()} never returns {@code null}.           *            the {@link FeatureCollection}
177     * @param attrMetaData map of attribute meta data           * @param id
178     */           *            a unique ID for the object
179    public void setAttributeMetaData(Map<Integer,AttributeMetaData> attrMetaData) {           * @param title
180      this.attrMetaData = (attrMetaData != null) ? attrMetaData : createDefaultAttributeMetaDataMap(geoObject);           *            a short description
181    }           * @param desc
182             *            a long description
183    /**           * @param keywords
184     * Creates non-translated default meta data for a {@link FeatureCollection}           *            keywords for the geo objects
185     * with all attributes visible and no unit set.           * @param style
186     * @param fc a {@link FeatureCollection}           *            a display style (if {@code null}, a default style is created)
187     */           * @param attrMetaData
188    public static Map<Integer,AttributeMetaData> createDefaultAttributeMetaDataMap(FeatureCollection fc) {           *            meta data for displaying a legend
189      HashMap<Integer,AttributeMetaData> metaDataMap = new HashMap<Integer,AttributeMetaData>();           * @param icon
190      FeatureType ftype = fc.getSchema();           *            an icon for the object (can be {@code null})
191      for (int i=0; i<ftype.getAttributeCount(); i++) {           * @exception IllegalArgumentException
192        AttributeType aType = ftype.getAttributeType(i);           *                if {@code null} is given as ID or geo object
193        if ( aType != ftype.getDefaultGeometry() )           */
194          metaDataMap.put(          public StyledFeatureCollection(
195            i,                          FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
196            new AttributeMetaData(                          String title, String desc, String keywords, Style style,
197              i,  // Column no.                          AttributeMetadataMap attrMetaData, ImageIcon icon) {
198              true, // visible                  this(fc, id, (Translation) null, null, null, style, attrMetaData, icon);
199              new Translation( aType.getName() ), // Column name                  setTitle(title);
200              new Translation(), // description                  setDesc(desc);
201              "" // Unit                  setKeywords(keywords);
202            )          }
203          );  
204      }          /**
205      return metaDataMap;           * Creates a styled {@link FeatureCollection} with non-translated
206    }           * informations.
207             *
208    /**           * @param fc
209     * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and           *            the {@link FeatureCollection}
210     * {@link #attrMetaData} to {@code null}.           * @param id
211     */           *            a unique ID for the object
212    public void dispose() {           * @param title
213      this.geoObject    = null;           *            a short description
214      this.envelope     = null;           * @param desc
215      this.crs          = null;           *            a long description
216      this.attrMetaData = null;           * @param keywords
217    }           *            keywords for the geo objects
218             * @param style
219    /**           *            a display style with attribute meta data information
220     * Tests whether the geo object is disposed.           * @param icon
221     */           *            an icon for the object (can be {@code null})
222    public boolean isDisposed() {           * @exception IllegalArgumentException
223      return geoObject == null;           *                if {@code null} is given as ID or geo object
224    }           */
225            public StyledFeatureCollection(
226    /**                          FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
227     * Does nothing, because the {@link AbstractStyledMap} bases on existing                          String title, String desc, String keywords,
228     * objects (in memory) which can not be uncached and reloaded.                          StyledLayerStyle<AttributeMetadataMap> style, ImageIcon icon) {
229     */                  this(fc, id, title, desc, keywords, style != null ? style
230    public void uncache() {                                  .getGeoObjectStyle() : null, style != null ? style
231      LOGGER.warn("Uncache functionality is not supported. Object remains in memory.");                                  .getMetaData() : null, icon);
232    }          }
233    
234            /**
235    /*           * Creates a styled {@link FeatureCollection} with a non-translated title,
236     * (non-Javadoc)           * no long description, no keywords, default attribute meta data and no
237     * @see skrueger.geotools.StyledMapInterface#getInfoURL()           * icon.
238     */           *
239          public URL getInfoURL() {           * @param fc
240                  return null;           *            the {@link FeatureCollection}
241          }           * @param id
242             *            a unique ID for the object
243          /**           * @param title
244           * If true, this layer will not be shown in the legend. Default = false           *            a short description
245           */           * @param style
246          /**           *            a display style (if {@code null}, a default style is created)
247           *           * @exception IllegalArgumentException
248           * Killed by SK: 6. April 09: Ein Layer soll nicht generell auf           *                if {@code null} is given as ID or geo object
249           * verstecken/nicht verstecken gestellt werden können. Das sind           * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
250           * Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer.           */
251           * Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer          public StyledFeatureCollection(
252           * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher                          FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
253           * die Funktion genutzt.                          String title, Style style) {
254           *                  this(fc, id, title, null, null, style, null, null);
255          public boolean isHideInLegend() {          }
256                  return false;  
257          }          /**
258           */           * Creates a styled {@link FeatureCollection} with a non-translated title,
259  }           * no long description, no keywords, default attribute meta data and no
260             * icon.
261             *
262             * @param fc
263             *            the {@link FeatureCollection}
264             * @param id
265             *            a unique ID for the object
266             * @param title
267             *            a short description
268             * @param style
269             *            a display style (if {@code null}, a default style is created)
270             * @exception IllegalArgumentException
271             *                if {@code null} is given as ID or geo object
272             * @see #createDefaultAttributeMetaDataMap(FeatureCollection)
273             */
274            public StyledFeatureCollection(
275                            FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String id,
276                            String title, StyledLayerStyle<AttributeMetadataMap> style) {
277                    this(fc, id, title, null, null, style != null ? style
278                                    .getGeoObjectStyle() : null, style != null ? style
279                                    .getMetaData() : null, null);
280            }
281    
282            /**
283             * Creates a default style for the {@link FeatureCollection}.
284             *
285             * @see FeatureUtil#createDefaultStyle(FeatureCollection)
286             */
287            protected Style createDefaultStyle() {
288                    return FeatureUtil.createDefaultStyle(geoObject);
289            }
290    
291            /**
292             * Returns the meta data needed for displaying a legend.
293             */
294            public AttributeMetadataMap getAttributeMetaDataMap() {
295                    return attrMetaData;
296            }
297    
298            /**
299             * Sets the meta data needed for displaying a legend. If {@code legendData}
300             * is {@code null} an empty map is set, so
301             * {@link #getAttributeMetaDataMap()} never returns {@code null}.
302             *
303             * @param attrMetaData
304             *            map of attribute meta data
305             */
306            public void setAttributeMetaData(AttributeMetadataMap attrMetaData) {
307                    this.attrMetaData = (attrMetaData != null) ? attrMetaData
308                                    : createDefaultAttributeMetaDataMap(geoObject);
309            }
310    
311            /**
312             * Creates non-translated default meta data for a {@link FeatureCollection}
313             * with all attributes visible and no unit set.
314             *
315             * @param fc
316             *            a {@link FeatureCollection}
317             */
318            public static AttributeMetadataMap createDefaultAttributeMetaDataMap(
319                            FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
320                    AttributeMetadataMap metaDataMap = new AttributeMetadataImplMap();
321                    SimpleFeatureType ftype = fc.getSchema();
322                    for (int i = 0; i < ftype.getAttributeCount(); i++) {
323                            AttributeDescriptor aDesc = ftype.getAttributeDescriptors().get(i);
324                            if (!FeatureUtil.isGeometryAttribute(aDesc))
325                                    metaDataMap.put(aDesc.getName(), new AttributeMetadataImpl(
326                                                    new NameImpl(aDesc.getName().getNamespaceURI(), aDesc
327                                                                    .getName().getLocalPart()), true, // visible
328                                                    new Translation(aDesc.getLocalName()), // Column name
329                                                    new Translation(aDesc.getLocalName()), // description
330                                                    "" // Unit
331                                    ));
332                    }
333                    return metaDataMap;
334            }
335    
336            /**
337             * Simply sets the {@link #geoObject}, {@link #crs}, {@link #envelope} and
338             * {@link #attrMetaData} to {@code null}.
339             */
340            public void dispose() {
341                    this.geoObject = null;
342                    this.envelope = null;
343                    this.crs = null;
344                    this.attrMetaData = null;
345            }
346    
347            /**
348             * Tests whether the geo object is disposed.
349             */
350            public boolean isDisposed() {
351                    return geoObject == null;
352            }
353    
354            /**
355             * Does nothing, because the {@link AbstractStyledLayer} bases on existing
356             * objects (in memory) which can not be uncached and reloaded.
357             */
358            public void uncache() {
359    
360                    /** It will be recreated on the next getFetureSource() **/
361                    featureSource = null;
362    
363                    LOGGER.warn("Uncache onyl uncached any virtual FeatureSource. Object remains in memory.");
364            }
365    
366            /*
367             * (non-Javadoc)
368             *
369             * @see skrueger.geotools.StyledLayerInterface#getInfoURL()
370             */
371            public URL getInfoURL() {
372                    return null;
373            }
374    
375            /**
376             * Same as {@link #getGeoObject()} method, but complies to the
377             * {@link StyledFeaturesInterface}. The associated {@link Filter} is NOT
378             * automatically applied.
379             *
380             * @see {@link StyledFeaturesInterface}
381             * @see #getFeatureCollectionFiltered()
382             */
383            @Override
384            public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatureCollection() {
385                    return getGeoObject();
386            }
387    
388            /**
389             * Same as {@link #getGeoObject()} method, but complies to the
390             * {@link StyledFeaturesInterface}. The associated {@link Filter} is
391             * automatically applied by creating a {@link SubFeatureCollection}.
392             *
393             * @see {@link StyledFeaturesInterface}
394             * @see #getFeatureCollectionFiltered()
395             */
396            @Override
397            public FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatureCollectionFiltered() {
398                    final FeatureCollection<SimpleFeatureType, SimpleFeature> fc = getFeatureCollection();
399                    if (filter == Filter.EXCLUDE)
400                            return new EmptyFeatureCollection(fc.getSchema());
401                    if (filter == Filter.INCLUDE)
402                            return fc;
403                    return fc.subCollection(filter);
404            }
405    
406            /**
407             * Returns a virtual {@link FeatureSource} to access the
408             * {@link FeatureCollection}. Once created, it will be reused until
409             * {@link #uncache()} is called.<br/>
410             *
411             * @see {@link StyledFeaturesInterface}
412             */
413            @Override
414            public FeatureSource<SimpleFeatureType, SimpleFeature> getFeatureSource() {
415                    if (featureSource == null) {
416                            CollectionDataStore store = new CollectionDataStore(getGeoObject());
417                            try {
418                                    featureSource = store.getFeatureSource(store.getTypeNames()[0]);
419                            } catch (IOException e) {
420                                    throw new RuntimeException(
421                                                    "Could not create a FeatureSource from the CollectionDataStore:",
422                                                    e);
423                            }
424                    }
425                    return featureSource;
426            }
427    
428            @Override
429            public Filter getFilter() {
430                    return filter;
431            }
432    
433            @Override
434            public void setFilter(Filter filter) {
435                    this.filter = filter;
436            }
437    
438            @Override
439            public SimpleFeatureType getSchema() {
440                    return getGeoObject().getSchema();
441            }
442    
443            @Override
444            public ReferencedEnvelope getReferencedEnvelope() {
445                    return new ReferencedEnvelope(getEnvelope(), getCrs());
446            }
447    
448            /**
449             * Defaults to the GeometryForm determined with FeatureUtil.getGeometryForm,
450             * but can be set to override ANY.
451             */
452            private GeometryForm geometryForm;
453    
454            /**
455             * Defaults to the GeometryForm determined with FeatureUtil.getGeometryForm,
456             * but can be set to override ANY.
457             */
458    
459            @Override
460            public GeometryForm getGeometryForm() {
461                    if (geometryForm == null) {
462                            geometryForm = FeatureUtil.getGeometryForm(getSchema());
463                    }
464                    return geometryForm;
465            }
466    
467            /**
468             * Defaults to the GeometryForm determined with FeatureUtil.getGeometryForm,
469             * but can be set to override ANY.
470             */
471            public void setGeometryForm(GeometryForm geometryForm) {
472                    this.geometryForm = geometryForm;
473            }
474    
475    }

Legend:
Removed from v.40  
changed lines
  Added in v.1261

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26