39 |
import org.geotools.data.Query; |
import org.geotools.data.Query; |
40 |
import org.geotools.data.memory.MemoryDataStore; |
import org.geotools.data.memory.MemoryDataStore; |
41 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.feature.FeatureCollection; |
42 |
|
import org.opengis.feature.simple.SimpleFeature; |
43 |
|
import org.opengis.feature.simple.SimpleFeatureType; |
44 |
import org.opengis.feature.type.AttributeDescriptor; |
import org.opengis.feature.type.AttributeDescriptor; |
45 |
import org.opengis.filter.Filter; |
import org.opengis.filter.Filter; |
46 |
|
|
142 |
* {@link AttributeMetaData}-Map to define the visible attributes |
* {@link AttributeMetaData}-Map to define the visible attributes |
143 |
* and translation |
* and translation |
144 |
*/ |
*/ |
145 |
protected void setFeatureSource(FeatureSource fs, |
protected void setFeatureSource(FeatureSource<SimpleFeatureType, SimpleFeature> fs, |
146 |
Map<Integer, AttributeMetaData> amd, Filter filter) |
Map<Integer, AttributeMetaData> amd, Filter filter) |
147 |
throws Exception { |
throws Exception { |
148 |
if (filter == null) |
if (filter == null) |
158 |
|
|
159 |
bounds = fs.getBounds(); |
bounds = fs.getBounds(); |
160 |
|
|
161 |
Query query = new DefaultQuery(fs.getSchema().getTypeName(), filter); |
Query query = new DefaultQuery(fs.getSchema().getName().getLocalPart(), filter); |
162 |
if (amd != null) { |
if (amd != null) { |
163 |
// determine the names of the visible Attributes |
// determine the names of the visible Attributes |
164 |
this.visibleAMD = StyledLayerUtil.getVisibleAttributeMetaData( |
this.visibleAMD = StyledLayerUtil.getVisibleAttributeMetaData( |
165 |
amd, true); |
amd, true); |
166 |
Vector<String> visibleAttrNames = new Vector<String>(); |
Vector<String> visibleAttrNames = new Vector<String>(); |
167 |
// Add the column with the geometry (usually "the_geom") |
// Add the column with the geometry (usually "the_geom") |
168 |
visibleAttrNames.add(fs.getSchema().getDefaultGeometry() |
visibleAttrNames.add(fs.getSchema().getGeometryDescriptor() |
169 |
.getLocalName()); |
.getLocalName()); |
170 |
for (int attrIdx : visibleAMD.keySet()) { |
for (int attrIdx : visibleAMD.keySet()) { |
171 |
|
|
177 |
*/ |
*/ |
178 |
if (attrIdx < fs.getSchema().getAttributeCount()) { |
if (attrIdx < fs.getSchema().getAttributeCount()) { |
179 |
final AttributeDescriptor attributeTypeAtIdx = fs.getSchema() |
final AttributeDescriptor attributeTypeAtIdx = fs.getSchema() |
180 |
.getAttributeType(attrIdx); |
.getAttributeDescriptors().get(attrIdx); |
181 |
visibleAttrNames.add(attributeTypeAtIdx.getLocalName()); |
visibleAttrNames.add(attributeTypeAtIdx.getLocalName()); |
182 |
} else { |
} else { |
183 |
LOGGER.warn("AttributeMetaData has been found for columnIdx="+attrIdx+", but fs.getSchema().getAttributeCount() = "+fs.getSchema().getAttributeCount()+". Ignored."); |
LOGGER.warn("AttributeMetaData has been found for columnIdx="+attrIdx+", but fs.getSchema().getAttributeCount() = "+fs.getSchema().getAttributeCount()+". Ignored."); |
229 |
setFeatureSource(null, null, null); |
setFeatureSource(null, null, null); |
230 |
else { |
else { |
231 |
FeatureCollection fc = layer.getFeatureCollection(); |
FeatureCollection fc = layer.getFeatureCollection(); |
232 |
String fcName = fc.getSchema().getTypeName(); |
String fcName = fc.getSchema().getName().getLocalPart(); |
233 |
FeatureSource fs = new MemoryDataStore(fc) |
FeatureSource fs = new MemoryDataStore(fc) |
234 |
.getFeatureSource(fcName); |
.getFeatureSource(fcName); |
235 |
setFeatureSource(fs, layer.getAttributeMetaDataMap(), filter); |
setFeatureSource(fs, layer.getAttributeMetaDataMap(), filter); |