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 schmitzm.geotools.feature.FeatureUtil.GeometryForm; |
52 |
|
import skrueger.AttributeMetadataImpl; |
53 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
54 |
|
|
55 |
/** |
/** |
68 |
implements StyledFeatureCollectionInterface { |
implements StyledFeatureCollectionInterface { |
69 |
|
|
70 |
/** Holds the meta data for displaying a legend. */ |
/** Holds the meta data for displaying a legend. */ |
71 |
protected AttributeMetadataMap attrMetaData = null; |
protected AttributeMetadataMap<AttributeMetadataImpl> attrMetaData = null; |
72 |
|
|
73 |
/** |
/** |
74 |
* We be filled with a "virtual" {@link FeatureSource} on demand. |
* We be filled with a "virtual" {@link FeatureSource} on demand. |
317 |
*/ |
*/ |
318 |
public static AttributeMetadataMap createDefaultAttributeMetaDataMap( |
public static AttributeMetadataMap createDefaultAttributeMetaDataMap( |
319 |
FeatureCollection<SimpleFeatureType, SimpleFeature> fc) { |
FeatureCollection<SimpleFeatureType, SimpleFeature> fc) { |
320 |
AttributeMetadataMap metaDataMap = new AttributeMetadataMap(); |
AttributeMetadataMap metaDataMap = new AttributeMetadataImplMap(); |
321 |
SimpleFeatureType ftype = fc.getSchema(); |
SimpleFeatureType ftype = fc.getSchema(); |
322 |
for (int i = 0; i < ftype.getAttributeCount(); i++) { |
for (int i = 0; i < ftype.getAttributeCount(); i++) { |
323 |
AttributeDescriptor aDesc = ftype.getAttributeDescriptors().get(i); |
AttributeDescriptor aDesc = ftype.getAttributeDescriptors().get(i); |
324 |
if (aDesc != ftype.getGeometryDescriptor()) |
if (!FeatureUtil.isGeometryAttribute(aDesc)) |
325 |
metaDataMap.put(aDesc.getName(), new AttributeMetadata(aDesc.getName(), |
metaDataMap.put(aDesc.getName(), new AttributeMetadataImpl( |
326 |
true, // visible |
new NameImpl(aDesc.getName().getNamespaceURI(), aDesc |
327 |
|
.getName().getLocalPart()), true, // visible |
328 |
new Translation(aDesc.getLocalName()), // Column name |
new Translation(aDesc.getLocalName()), // Column name |
329 |
new Translation(aDesc.getLocalName()), // description |
new Translation(aDesc.getLocalName()), // description |
330 |
"" // Unit |
"" // Unit |
360 |
/** It will be recreated on the next getFetureSource() **/ |
/** It will be recreated on the next getFetureSource() **/ |
361 |
featureSource = null; |
featureSource = null; |
362 |
|
|
363 |
LOGGER |
LOGGER.warn("Uncache onyl uncached any virtual FeatureSource. Object remains in memory."); |
|
.warn("Uncache onyl uncached any virtual FeatureSource. Object remains in memory."); |
|
364 |
} |
} |
365 |
|
|
366 |
/* |
/* |
440 |
return getGeoObject().getSchema(); |
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 |
} |
} |