15 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
16 |
import org.geotools.data.FeatureSource; |
import org.geotools.data.FeatureSource; |
17 |
import org.geotools.feature.AttributeType; |
import org.geotools.feature.AttributeType; |
18 |
|
import org.geotools.feature.FeatureCollection; |
19 |
import org.geotools.styling.Style; |
import org.geotools.styling.Style; |
20 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
21 |
|
|
22 |
|
import schmitzm.geotools.feature.FeatureOperationTreeFilter; |
23 |
import schmitzm.geotools.styling.StylingUtil; |
import schmitzm.geotools.styling.StylingUtil; |
24 |
import skrueger.AttributeMetaData; |
import skrueger.AttributeMetaData; |
25 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
78 |
} catch (FileNotFoundException e) { |
} catch (FileNotFoundException e) { |
79 |
LOGGER |
LOGGER |
80 |
.debug("The SLD file passed was empty. Leaving the Style untouched. (We are in the constructor.. so its null"); |
.debug("The SLD file passed was empty. Leaving the Style untouched. (We are in the constructor.. so its null"); |
81 |
|
} catch (Exception e) { |
82 |
|
LOGGER.warn("Reading SLD failed: " + sldFile, e); |
83 |
} |
} |
84 |
} |
} |
|
|
|
85 |
title = new Translation(); |
title = new Translation(); |
86 |
title.fromOneLine(sldFile.getName()); |
title.fromOneLine(sldFile.getName()); |
87 |
|
|
123 |
} |
} |
124 |
} |
} |
125 |
|
|
126 |
public FeatureSource getGeoObject() throws Exception { |
public FeatureSource getGeoObject() { |
127 |
return fs; |
return fs; |
128 |
} |
} |
129 |
|
|
167 |
* nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher |
* nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher |
168 |
* die Funktion genutzt. |
* die Funktion genutzt. |
169 |
* |
* |
170 |
// public boolean isHideInLegend() { |
* // public boolean isHideInLegend() { // return false; // } |
|
// return false; |
|
|
// } |
|
171 |
*/ |
*/ |
172 |
|
|
173 |
public void setDesc(Translation dec) { |
public void setDesc(Translation dec) { |
198 |
*/ |
*/ |
199 |
public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() { |
public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() { |
200 |
if (map == null) { |
if (map == null) { |
201 |
|
|
202 |
map = new HashMap<Integer, AttributeMetaData>(); |
map = new HashMap<Integer, AttributeMetaData>(); |
203 |
|
|
204 |
// Leaving out the first one, it will be the_geom |
// Leaving out the first one, it will be the_geom |
205 |
for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) { |
for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) { |
206 |
AttributeType att = fs.getSchema().getAttributeType(i); |
AttributeType att = fs.getSchema().getAttributeType(i); |
207 |
|
|
208 |
AttributeMetaData attMetaData = new AttributeMetaData(i, att.getLocalName()); |
AttributeMetaData attMetaData = new AttributeMetaData(i, att |
209 |
|
.getLocalName()); |
210 |
map.put(i, attMetaData); |
map.put(i, attMetaData); |
211 |
} |
} |
212 |
} |
} |
215 |
|
|
216 |
/** |
/** |
217 |
* @return The {@link File} where the SLD was loaded from or |
* @return The {@link File} where the SLD was loaded from or |
218 |
* <code>null</code> if there didn't exist a {@link File}. (It |
* <code>null</code> if there didn't exist a {@link File}. (It could |
219 |
* could be a WFS or a PostGIS |
* be a WFS or a PostGIS |
220 |
* |
* |
221 |
* @author <a href="mailto:[email protected]">Stefan Alfons Krüger</a> |
* @author <a href="mailto:[email protected]">Stefan Alfons |
222 |
|
* Krüger</a> |
223 |
*/ |
*/ |
224 |
public File getSldFile() { |
public File getSldFile() { |
225 |
return sldFile; |
return sldFile; |
229 |
this.sldFile = sldFile; |
this.sldFile = sldFile; |
230 |
} |
} |
231 |
|
|
232 |
|
/** |
233 |
|
* Returns the features of the {@link FeatureSource}. |
234 |
|
* |
235 |
|
* @see {@link StyledFeaturesInterface} |
236 |
|
*/ |
237 |
|
@Override |
238 |
|
public FeatureCollection getFeatureCollection() { |
239 |
|
FeatureCollection features; |
240 |
|
try { |
241 |
|
features = getGeoObject().getFeatures(); |
242 |
|
} catch (IOException e) { |
243 |
|
throw new RuntimeException( |
244 |
|
"Error getting the features of the FeatureSource"); |
245 |
|
} |
246 |
|
return features; |
247 |
|
} |
248 |
|
|
249 |
|
/** |
250 |
|
* Same as {@link #getGeoObject()} method, but complies to the |
251 |
|
* {@link StyledFeaturesInterface} |
252 |
|
* |
253 |
|
* @see {@link StyledFeaturesInterface} |
254 |
|
*/ |
255 |
|
@Override |
256 |
|
public FeatureSource getFeatureSource() { |
257 |
|
return getGeoObject(); |
258 |
|
} |
259 |
|
|
260 |
} |
} |