25 |
* |
* |
26 |
* Contributors: |
* Contributors: |
27 |
* Martin O. J. Schmitz - initial API and implementation |
* Martin O. J. Schmitz - initial API and implementation |
28 |
* Stefan A. Krüger - additional utility classes |
* Stefan A. Tzeggai - additional utility classes |
29 |
******************************************************************************/ |
******************************************************************************/ |
30 |
package skrueger.geotools; |
package skrueger.geotools; |
31 |
|
|
38 |
import org.geotools.data.collection.CollectionDataStore; |
import org.geotools.data.collection.CollectionDataStore; |
39 |
import org.geotools.data.store.EmptyFeatureCollection; |
import org.geotools.data.store.EmptyFeatureCollection; |
40 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.feature.FeatureCollection; |
41 |
|
import org.geotools.feature.NameImpl; |
42 |
import org.geotools.feature.collection.SubFeatureCollection; |
import org.geotools.feature.collection.SubFeatureCollection; |
43 |
|
import org.geotools.geometry.jts.ReferencedEnvelope; |
44 |
import org.geotools.styling.Style; |
import org.geotools.styling.Style; |
45 |
import org.opengis.feature.simple.SimpleFeature; |
import org.opengis.feature.simple.SimpleFeature; |
46 |
import org.opengis.feature.simple.SimpleFeatureType; |
import org.opengis.feature.simple.SimpleFeatureType; |
48 |
import org.opengis.filter.Filter; |
import org.opengis.filter.Filter; |
49 |
|
|
50 |
import schmitzm.geotools.feature.FeatureUtil; |
import schmitzm.geotools.feature.FeatureUtil; |
51 |
import skrueger.AttributeMetadata; |
import skrueger.AttributeMetadataImpl; |
52 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
53 |
|
|
54 |
/** |
/** |
67 |
implements StyledFeatureCollectionInterface { |
implements StyledFeatureCollectionInterface { |
68 |
|
|
69 |
/** Holds the meta data for displaying a legend. */ |
/** Holds the meta data for displaying a legend. */ |
70 |
protected AttributeMetadataMap attrMetaData = null; |
protected AttributeMetadataMap<AttributeMetadataImpl> attrMetaData = null; |
71 |
|
|
72 |
/** |
/** |
73 |
* We be filled with a "virtual" {@link FeatureSource} on demand. |
* We be filled with a "virtual" {@link FeatureSource} on demand. |
316 |
*/ |
*/ |
317 |
public static AttributeMetadataMap createDefaultAttributeMetaDataMap( |
public static AttributeMetadataMap createDefaultAttributeMetaDataMap( |
318 |
FeatureCollection<SimpleFeatureType, SimpleFeature> fc) { |
FeatureCollection<SimpleFeatureType, SimpleFeature> fc) { |
319 |
AttributeMetadataMap metaDataMap = new AttributeMetadataMap(); |
AttributeMetadataMap metaDataMap = new AttributeMetadataImplMap(); |
320 |
SimpleFeatureType ftype = fc.getSchema(); |
SimpleFeatureType ftype = fc.getSchema(); |
321 |
for (int i = 0; i < ftype.getAttributeCount(); i++) { |
for (int i = 0; i < ftype.getAttributeCount(); i++) { |
322 |
AttributeDescriptor aDesc = ftype.getAttributeDescriptors().get(i); |
AttributeDescriptor aDesc = ftype.getAttributeDescriptors().get(i); |
323 |
if (aDesc != ftype.getGeometryDescriptor()) |
if ( !FeatureUtil.isGeometryAttribute(aDesc) ) |
324 |
metaDataMap.put(aDesc.getName(), new AttributeMetadata(aDesc.getName(), |
metaDataMap.put(aDesc.getName(), new AttributeMetadataImpl( new NameImpl( aDesc.getName().getNamespaceURI(), aDesc.getName().getLocalPart()), |
325 |
true, // visible |
true, // visible |
326 |
new Translation(aDesc.getLocalName()), // Column name |
new Translation(aDesc.getLocalName()), // Column name |
327 |
new Translation(aDesc.getLocalName()), // description |
new Translation(aDesc.getLocalName()), // description |
440 |
} |
} |
441 |
|
|
442 |
|
|
443 |
|
@Override |
444 |
|
public ReferencedEnvelope getReferencedEnvelope() { |
445 |
|
return new ReferencedEnvelope(getEnvelope(), getCrs()); |
446 |
|
} |
447 |
|
|
448 |
} |
} |