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

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

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

revision 894 by alfonx, Fri Jun 4 09:19:07 2010 UTC revision 1203 by alfonx, Tue Nov 2 22:53:55 2010 UTC
# Line 42  import org.apache.log4j.Logger; Line 42  import org.apache.log4j.Logger;
42  import org.geotools.data.FeatureSource;  import org.geotools.data.FeatureSource;
43  import org.geotools.feature.FeatureCollection;  import org.geotools.feature.FeatureCollection;
44  import org.geotools.feature.NameImpl;  import org.geotools.feature.NameImpl;
45    import org.geotools.geometry.jts.ReferencedEnvelope;
46  import org.geotools.styling.Style;  import org.geotools.styling.Style;
47  import org.opengis.feature.simple.SimpleFeature;  import org.opengis.feature.simple.SimpleFeature;
48  import org.opengis.feature.simple.SimpleFeatureType;  import org.opengis.feature.simple.SimpleFeatureType;
# Line 76  public class StyledFS implements StyledF Line 77  public class StyledFS implements StyledF
77           * A unique ID which identifies the Layer in the Atlas. It's more important           * A unique ID which identifies the Layer in the Atlas. It's more important
78           * than it should be ;-)           * than it should be ;-)
79           */           */
80          private String id;          final private String id;
81    
82          private Style style;          private Style style;
83    
# Line 101  public class StyledFS implements StyledF Line 102  public class StyledFS implements StyledF
102           * @param sldFile           * @param sldFile
103           *            may be <code>null</code>. Otherwise the SLD {@link File} to           *            may be <code>null</code>. Otherwise the SLD {@link File} to
104           *            import and associate with this {@link StyledFS}           *            import and associate with this {@link StyledFS}
105             *
106             * @param id
107             *            <code>null</code> is allowed and will autogenerate an id
108           */           */
109          public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs,          public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs,
110                          File sldFile) {                          File sldFile, String id) {
111    
112                  this.fs = fs;                  this.fs = fs;
113    
114                  id = StyledFS.class.getSimpleName()                  if (id == null) {
115                                  + new Random(new Date().getTime()).nextInt(10000000);                          this.id = StyledFS.class.getSimpleName()
116                                            + new Random(new Date().getTime()).nextInt(10000000);
117                    } else {
118                            this.id = id;
119                    }
120    
121                  this.sldFile = sldFile;                  this.sldFile = sldFile;
122    
# Line 133  public class StyledFS implements StyledF Line 141  public class StyledFS implements StyledF
141          }          }
142    
143          public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs) {          public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs) {
144                  this(fs, null);                  this(fs, (File) null, null);
145            }
146    
147            public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs,
148                            String id) {
149                    this(fs, null, id);
150          }          }
151    
152          public void dispose() {          public void dispose() {
# Line 160  public class StyledFS implements StyledF Line 173  public class StyledFS implements StyledF
173    
174                                  crs = fs.getSchema().getGeometryDescriptor()                                  crs = fs.getSchema().getGeometryDescriptor()
175                                                  .getCoordinateReferenceSystem();                                                  .getCoordinateReferenceSystem();
176                                    
177                                  if (crs == null) {                                  if (crs == null) {
178                                          LOGGER.warn("Could not determine the CRS of " + getTitle()                                          LOGGER.warn("Could not determine the CRS of " + getTitle()
179                                                          + ". Using default "                                                          + ". Using default "
# Line 282  public class StyledFS implements StyledF Line 295  public class StyledFS implements StyledF
295                                  // with Translations ;-)                                  // with Translations ;-)
296                                  AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(                                  AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
297                                                  new NameImpl(attDesc.getName().getNamespaceURI(),                                                  new NameImpl(attDesc.getName().getNamespaceURI(),
298                                                                  attDesc.getName().getLocalPart()), map                                                                  attDesc.getName().getLocalPart()),
299                                                                  .getLanguages());                                                  map.getLanguages());
300                                  if (String.class.isAssignableFrom(attDesc.getType()                                  if (String.class.isAssignableFrom(attDesc.getType()
301                                                  .getBinding())) {                                                  .getBinding())) {
302                                          // For Strings we add the "" as NODATA values                                          // For Strings we add the "" as NODATA values
# Line 305  public class StyledFS implements StyledF Line 318  public class StyledFS implements StyledF
318                  return sldFile;                  return sldFile;
319          }          }
320    
321            /**
322             * Associates this .sld with the {@link FeatureSource}, but does not
323             * automatically load the file. It must not even exist.
324             *
325             * @param sldFile
326             */
327          public void setSldFile(File sldFile) {          public void setSldFile(File sldFile) {
328                  this.sldFile = sldFile;                  this.sldFile = sldFile;
329          }          }
# Line 348  public class StyledFS implements StyledF Line 367  public class StyledFS implements StyledF
367                  // return fc.subCollection(filter);                  // return fc.subCollection(filter);
368    
369                  try {                  try {
370                          return getFeatureSource().getFeatures(filter);                          if (filter != Filter.INCLUDE)
371                                    return getFeatureSource().getFeatures(filter);
372                            else
373                                    return getFeatureSource().getFeatures();
374                  } catch (IOException e) {                  } catch (IOException e) {
375                          throw new RuntimeException(e);                          throw new RuntimeException(e);
376                  }                  }
# Line 389  public class StyledFS implements StyledF Line 411  public class StyledFS implements StyledF
411    
412          }          }
413    
414            public void setTitle(String title) {
415                    setTitle(new Translation(title));
416            }
417    
418            public void setDesc(String desc) {
419                    setDesc(new Translation(desc));
420            }
421    
422            public void setCRS(CoordinateReferenceSystem crs2) {
423                    crs = crs2;
424            }
425    
426            @Override
427            public ReferencedEnvelope getReferencedEnvelope() {
428                    return new ReferencedEnvelope(getEnvelope(), getCrs());
429            }
430    
431  }  }

Legend:
Removed from v.894  
changed lines
  Added in v.1203

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26