001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.feature.type;
017:
018: import java.util.logging.Level;
019: import java.util.logging.Logger;
020:
021: import org.geotools.feature.AttributeType;
022: import org.geotools.feature.FeatureType;
023: import org.geotools.feature.FeatureTypeFactory;
024:
025: /**
026: * Defines required attributes for Annotations.
027: *
028: * <p>
029: * Annotations represent a text based geographic feature.
030: * The geometry stored in the feature indicates where the
031: * text should be drawn and the attribute indicated by
032: * the {@link #ANNOTATION_ATTRIBUTE_NAME} attribute holds
033: * the text to be displayed for the feature.
034: * </p>
035: *
036: * <p>Example:
037: * <pre>
038: * if ( feature.getFeatureType().isDescendedFrom( AnnotationFeatureType.ANNOTATION ) )
039: * {
040: * String attributeName = (String)feature.getAttribute( AnnotationFeatureType.ANNOTATION_ATTRIBUTE_NAME );
041: * String annotationText = (String)feature.getAttribute( attributeName );
042: * ... // Do something with the annotation text and feature
043: * }
044: * </pre>
045: * </p>
046: *
047: * @author John Meagher
048: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/feature/type/BasicFeatureTypes.java $
049: */
050: public class BasicFeatureTypes {
051:
052: /**
053: * The FeatureType reference that should be used for Polygons
054: */
055: public static final FeatureType POLYGON;
056:
057: /**
058: * The FeatureType reference that should be used for Points
059: */
060: public static final FeatureType POINT;
061:
062: /**
063: * The FeatureType reference that should be used for Lines
064: */
065: public static final FeatureType LINE;
066:
067: /**
068: * The attribute name used to store the geometry
069: */
070: public static final String GEOMETRY_ATTRIBUTE_NAME = "the_geom";
071:
072: // Static initializer for the tyoe variables
073: static {
074: FeatureType tmpPoint = null;
075: FeatureType tmpPolygon = null;
076: FeatureType tmpLine = null;
077: try {
078:
079: AttributeType[] types = new AttributeType[] {};
080: tmpPoint = FeatureTypeFactory.newFeatureType(types,
081: "pointFeature");
082: tmpLine = FeatureTypeFactory.newFeatureType(types,
083: "lineFeature");
084: tmpPolygon = FeatureTypeFactory.newFeatureType(types,
085: "polygonFeature");
086: } catch (Exception ex) {
087: org.geotools.util.logging.Logging.getLogger(
088: "org.geotools.feature.type.BasicFeatureTypes").log(
089: Level.SEVERE, "Error creating basic feature types",
090: ex);
091: }
092: POINT = tmpPoint;
093: LINE = tmpLine;
094: POLYGON = tmpPolygon;
095:
096: }
097:
098: /**
099: * Noone else should be able to build me.
100: */
101: private BasicFeatureTypes() {
102: }
103: }
|