/[schmitzm]/trunk/src/skrueger/geotools/StyledLayerUtil.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/StyledLayerUtil.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1225 by alfonx, Wed Nov 3 17:05:42 2010 UTC revision 1228 by alfonx, Wed Nov 3 20:44:16 2010 UTC
# Line 99  import skrueger.AttributeMetadataInterfa Line 99  import skrueger.AttributeMetadataInterfa
99  import skrueger.RasterLegendData;  import skrueger.RasterLegendData;
100  import skrueger.i8n.Translation;  import skrueger.i8n.Translation;
101    
102    import com.vividsolutions.jts.geom.Geometry;
103    
104  /**  /**
105   * This class provides static helper methods for dealing with   * This class provides static helper methods for dealing with
106   * {@link StyledLayerInterface} stuff.   * {@link StyledLayerInterface} stuff.
# Line 1363  public class StyledLayerUtil { Line 1365  public class StyledLayerUtil {
1365                  }                  }
1366                  return nicelyFormatted;                  return nicelyFormatted;
1367          }          }
1368    
1369            /**
1370             * Creates a new {@link AttributeMetadataMap} with instances of
1371             * {@link AttributeMetadataInterface} for every non-geometry attribute.
1372             * Default NODATA values (like "" for String) are set.
1373             */
1374            public static AttributeMetadataMap<AttributeMetadataImpl> createDefaultAttributeMetadataMap(
1375                            SimpleFeatureType schema) {
1376                    AttributeMetadataImplMap attMap = new AttributeMetadataImplMap();
1377    
1378                    for (int i = 0; i < schema.getAttributeCount(); i++) {
1379                            AttributeDescriptor attDesc = schema.getDescriptor(i);
1380    
1381                            if (Geometry.class.isAssignableFrom(attDesc.getType().getBinding())) {
1382                                    // Ignore the Geometry column
1383                                    continue;
1384                            }
1385    
1386                            // TODO AttributeMetadataAS would be nicer, which would not work
1387                            // with Translations ;-)
1388                            AttributeMetadataImpl attMetaData = new AttributeMetadataImpl(
1389                                            new NameImpl(attDesc.getName().getNamespaceURI(), attDesc
1390                                                            .getName().getLocalPart()), attMap.getLanguages());
1391    
1392                            if (String.class.isAssignableFrom(attDesc.getType().getBinding())) {
1393                                    // For Strings we add the "" as NODATA values
1394                                    attMetaData.addNodataValue("");
1395                            }
1396    
1397                            attMap.put(attDesc.getName(), attMetaData);
1398                    }
1399                    return attMap;
1400            }
1401  }  }

Legend:
Removed from v.1225  
changed lines
  Added in v.1228

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26