[Schmitzm-commits] r335 - in branches/1.0-gt2-2.6/src: schmitzm/geotools/feature schmitzm/geotools/gui skrueger/geotools skrueger/geotools/labelsearch
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Aug 26 20:09:40 CEST 2009
Author: alfonx
Date: 2009-08-26 20:09:39 +0200 (Wed, 26 Aug 2009)
New Revision: 335
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureOperationTree.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java
Log:
Migrating to GT2.6...
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureOperationTree.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureOperationTree.java 2009-08-26 17:39:09 UTC (rev 334)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureOperationTree.java 2009-08-26 18:09:39 UTC (rev 335)
@@ -106,7 +106,7 @@
if ( opTreeNode instanceof AttributeNameReferenceNode ) {
String attrName = ((AttributeNameReferenceNode)opTreeNode).getObject();
Object object = feature.getAttribute( attrName );
- if ( feature.getFeatureType().getAttributeType( attrName ) == null )
+ if ( feature.getFeatureType().getAttributeDesc( attrName ) == null )
throw new UnsupportedOperationException( FeatureUtil.RESOURCE.getString("FeatureOperationTree.err.UnknownAttr",attrName) );
if ( object == null )
throw new UnsupportedOperationException( FeatureUtil.RESOURCE.getString("FeatureOperationTree.err.NullAttr",attrName) );
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java 2009-08-26 17:39:09 UTC (rev 334)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureTypeBuilderTableModel.java 2009-08-26 18:09:39 UTC (rev 335)
@@ -197,13 +197,13 @@
attrDefinitions.clear();
if ( featureTypeBuilder != null )
for (int i=0; i<featureTypeBuilder.getAttributeCount(); i++) {
- AttributeDescriptor type = featureTypeBuilder.get(i);
+ AttributeDescriptor aDesc = featureTypeBuilder.get(i);
attrDefinitions.add( new AttributeDefinition(
- type.getLocalName(),
- type.getBinding(),
- type.isNillable(),
+ aDesc.getLocalName(),
+ aDesc.getType().getBinding(),
+ aDesc.isNillable(),
false,
- type.createDefaultValue()
+ aDesc.getDefaultValue()
) );
}
this.fireTableDataChanged();
@@ -218,7 +218,7 @@
public void setFeatureType(SimpleFeatureType ftype) {
if ( ftype != null ) {
FeatureTypeBuilder builder = FeatureTypeBuilder.newInstance(ftype.getTypeName());
- builder.addTypes(ftype.getAttributeTypes());
+ builder.addTypes(ftype.getAttributeDescriptors());
setFeatureTypeBuilder(builder);
} else
setFeatureTypeBuilder(null);
@@ -235,11 +235,11 @@
this.featureTypeBuilder.removeType(0);
for (AttributeDefinition aDef : attrDefinitions) {
- AttributeDescriptor aType = aDef.createAttributeType();
- featureTypeBuilder.addType( aType );
+ AttributeDescriptor aDesc = aDef.createAttributeType();
+ featureTypeBuilder.addType( aDesc );
if ( featureTypeBuilder.getDefaultGeometry() == null &&
- aType instanceof GeometricAttributeType )
- featureTypeBuilder.setDefaultGeometry( (GeometricAttributeType)aType );
+ aDesc instanceof GeometricAttributeType )
+ featureTypeBuilder.setDefaultGeometry( (GeometricAttributeType)aDesc );
}
return this.featureTypeBuilder.getFeatureType();
} catch (SchemaException err) {
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-08-26 17:39:09 UTC (rev 334)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java 2009-08-26 18:09:39 UTC (rev 335)
@@ -2434,7 +2434,7 @@
* Sets the mapArea to smartly present the given features. Note: The method
* does not call {@link #repaint()} on the {@link JMapPane}.
*/
- public void zoomTo(org.geotools.feature.SimpleFeature feature) {
+ public void zoomTo(SimpleFeature feature) {
final MemoryFeatureCollection mfc = new MemoryFeatureCollection(feature
.getFeatureType());
mfc.add(feature);
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java 2009-08-26 17:39:09 UTC (rev 334)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/StyledFeatureCollectionTableModel.java 2009-08-26 18:09:39 UTC (rev 335)
@@ -39,7 +39,10 @@
import org.geotools.data.Query;
import org.geotools.data.memory.MemoryDataStore;
import org.geotools.feature.FeatureCollection;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
+import org.opengis.feature.type.FeatureType;
import org.opengis.filter.Filter;
import schmitzm.geotools.gui.FeatureCollectionTableModel;
@@ -140,7 +143,7 @@
* {@link AttributeMetaData}-Map to define the visible attributes
* and translation
*/
- protected void setFeatureSource(FeatureSource fs,
+ protected void setFeatureSource(FeatureSource<SimpleFeatureType, SimpleFeature> fs,
Map<Integer, AttributeMetaData> amd, Filter filter)
throws Exception {
if (filter == null)
@@ -156,14 +159,14 @@
bounds = fs.getBounds();
- Query query = new DefaultQuery(fs.getSchema().getTypeName(), filter);
+ Query query = new DefaultQuery(fs.getSchema().getName().getLocalPart(), filter);
if (amd != null) {
// determine the names of the visible Attributes
this.visibleAMD = StyledLayerUtil.getVisibleAttributeMetaData(
amd, true);
Vector<String> visibleAttrNames = new Vector<String>();
// Add the column with the geometry (usually "the_geom")
- visibleAttrNames.add(fs.getSchema().getDefaultGeometry()
+ visibleAttrNames.add(fs.getSchema().getGeometryDescriptor()
.getLocalName());
for (int attrIdx : visibleAMD.keySet()) {
@@ -175,7 +178,7 @@
*/
if (attrIdx < fs.getSchema().getAttributeCount()) {
final AttributeDescriptor attributeTypeAtIdx = fs.getSchema()
- .getAttributeType(attrIdx);
+ .getAttributeDescriptors().get(attrIdx);
visibleAttrNames.add(attributeTypeAtIdx.getLocalName());
} else {
LOGGER.warn("AttributeMetaData has been found for columnIdx="+attrIdx+", but fs.getSchema().getAttributeCount() = "+fs.getSchema().getAttributeCount()+". Ignored.");
@@ -227,7 +230,7 @@
setFeatureSource(null, null, null);
else {
FeatureCollection fc = layer.getFeatureCollection();
- String fcName = fc.getSchema().getTypeName();
+ String fcName = fc.getSchema().getName().getLocalPart();
FeatureSource fs = new MemoryDataStore(fc)
.getFeatureSource(fcName);
setFeatureSource(fs, layer.getAttributeMetaDataMap(), filter);
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java 2009-08-26 17:39:09 UTC (rev 334)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/labelsearch/LabelSearch.java 2009-08-26 18:09:39 UTC (rev 335)
@@ -38,13 +38,16 @@
import org.apache.log4j.Logger;
import org.geotools.data.DefaultQuery;
+import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.map.MapLayer;
import org.geotools.styling.Style;
import org.geotools.styling.TextSymbolizer;
+import org.opengis.feature.Feature;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
+import org.opengis.feature.type.FeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.expression.Expression;
import org.opengis.filter.expression.PropertyName;
@@ -81,22 +84,26 @@
this.mapPane = mapPane;
}
+ /**
+ * The Attribute that provides the labels for this text symbolizer.
+ */
private AttributeDescriptor getLabelAttribute(final TextSymbolizer ts,
final SimpleFeatureType schema) {
if (ts == null) {
// This layer has no labels
return null;
}
+
final Expression labelExp = ts.getLabel();
if (labelExp instanceof PropertyName) {
final PropertyName pn = (PropertyName) labelExp;
final String propertyName = pn.getPropertyName();
- return schema.getAttributeType(propertyName);
+ return schema.getDescriptor(propertyName);
} else {
// When does this happen
+ throw new RuntimeException("labelExp "+labelExp+" IS NOT instanceof PropertyName!");
}
- return null;
}
public List<SearchResult> search(final String string) {
@@ -121,8 +128,11 @@
continue;
}
- final String typeName = ml.getFeatureSource().getSchema()
- .getTypeName();
+ // 26 CAST!
+ final FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>) ml.getFeatureSource();
+
+ final String typeName = featureSource.getSchema()
+ .getName().getLocalPart();
// Expression labelExp = ts.getLabel();
// ff.like(labelExp, "*"+searchMe+"*");
@@ -131,7 +141,7 @@
// new DefaultQuery(typeName, ff.like(labelExp,
// "*"+searchMe+"*"), properties));
- final FeatureCollection features = ml.getFeatureSource().getFeatures(
+ final FeatureCollection<SimpleFeatureType, SimpleFeature> features = featureSource.getFeatures(
new DefaultQuery(typeName, Filter.INCLUDE));
// new MemoryDataStore().getFeatureSource(typeName)
@@ -150,8 +160,7 @@
if (ts == null)
continue;
- final AttributeDescriptor labelAttribute = getLabelAttribute(ts, ml
- .getFeatureSource().getSchema());
+ final AttributeDescriptor labelAttribute = getLabelAttribute(ts, featureSource.getSchema());
if (labelAttribute == null) {
continue;
More information about the Schmitzm-commits
mailing list