001: package org.geotools.feature.iso.simple;
002:
003: import java.util.Calendar;
004: import java.util.Collections;
005: import java.util.Date;
006:
007: import org.geotools.feature.iso.type.AttributeTypeImpl;
008: import org.geotools.feature.iso.type.GeometryTypeImpl;
009: import org.geotools.feature.iso.type.SchemaImpl;
010: import org.geotools.feature.type.TypeName;
011: import org.opengis.feature.type.AttributeType;
012: import org.opengis.feature.type.GeometryType;
013:
014: import com.vividsolutions.jts.geom.Geometry;
015: import com.vividsolutions.jts.geom.GeometryCollection;
016: import com.vividsolutions.jts.geom.LineString;
017: import com.vividsolutions.jts.geom.LinearRing;
018: import com.vividsolutions.jts.geom.MultiLineString;
019: import com.vividsolutions.jts.geom.MultiPoint;
020: import com.vividsolutions.jts.geom.MultiPolygon;
021: import com.vividsolutions.jts.geom.Point;
022: import com.vividsolutions.jts.geom.Polygon;
023:
024: /**
025: * Schema containing a simple set of types for import into
026: * the SimpleFeatureBuilder.
027: * <p>
028: * These types represent a good choice for default java bindings, for data
029: * sources that do not have specific or complicated needs. As such these
030: * types are made available as static final constants to be inlined in code
031: * where needed.
032: * </p>
033: * When would you not use this class?
034: * <ul>
035: * <li><b>For specific mappings:</b> Create a custom Schema when working with GML or where specific XML Schema
036: * mappings are useful to track.
037: * <li><b>For restricted basic types:</b> Create a custom Schema when working with a Data Source that has different
038: * needs for "basic" types. Shapefile for example needs a length restriction
039: * on its Text type and cannot make use of STRING as provided here.
040: * </ul>
041: *
042: * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
043: */
044: public class SimpleSchema extends SchemaImpl {
045:
046: public static final String NAMESPACE = "http://www.geotools.org/simple";
047: //
048: // Builtin Java Types
049: //
050: /** BOOLEAN to Boolean.class */
051: public static final AttributeType BOOLEAN = new AttributeTypeImpl(
052: new TypeName(NAMESPACE, "boolean"), Boolean.class, false,
053: false, Collections.EMPTY_SET, null, null);
054: /** String to String.class */
055: public static final AttributeType STRING = new AttributeTypeImpl(
056: new TypeName(NAMESPACE, "string"), String.class, false,
057: false, Collections.EMPTY_SET, null, null);
058: //
059: // Numerics
060: //
061: /** NUMBER to Number.class */
062: public static final AttributeType NUMBER = new AttributeTypeImpl(
063: new TypeName(NAMESPACE, "number"), Number.class, false,
064: false, Collections.EMPTY_SET, null, null);
065: /**
066: * INTEGER to java Integer.class
067: */
068: public static final AttributeType INTEGER = new AttributeTypeImpl(
069: new TypeName(NAMESPACE, "integer"), Integer.class, false,
070: false, Collections.EMPTY_SET, NUMBER, null);
071: /**
072: * FLOAT to java Float.class
073: */
074: public static final AttributeType FLOAT = new AttributeTypeImpl(
075: new TypeName(NAMESPACE, "float"), Float.class, false,
076: false, Collections.EMPTY_SET, NUMBER, null);
077: /** DOUBLE to Double.class */
078: public static final AttributeType DOUBLE = new AttributeTypeImpl(
079: new TypeName(NAMESPACE, "double"), Double.class, false,
080: false, Collections.EMPTY_SET, NUMBER, null);
081: /** LONG to Long.class */
082: public static final AttributeType LONG = new AttributeTypeImpl(
083: new TypeName(NAMESPACE, "long"), Long.class, false, false,
084: Collections.EMPTY_SET, NUMBER, null);
085: /** SHORT to Short.class */
086: public static final AttributeType SHORT = new AttributeTypeImpl(
087: new TypeName(NAMESPACE, "short"), Short.class, false,
088: false, Collections.EMPTY_SET, NUMBER, null);
089: /** BYTE to Byte.class */
090: public static final AttributeType BYTE = new AttributeTypeImpl(
091: new TypeName(NAMESPACE, "byte"), Byte.class, false, false,
092: Collections.EMPTY_SET, NUMBER, null);
093:
094: //
095: // TEMPORAL
096: //
097: /** DATE to Data.class */
098: public static final AttributeType DATE = new AttributeTypeImpl(
099: new TypeName(NAMESPACE, "date"), Date.class, false, false,
100: Collections.EMPTY_SET, null, null);
101: /**
102: * DATETIME to Calendar.class.
103: * <p>
104: * Data and a Time like a timestamp.
105: */
106: public static final AttributeType DATETIME = new AttributeTypeImpl(
107: new TypeName(NAMESPACE, "datetime"), Calendar.class, false,
108: false, Collections.EMPTY_SET, null, null);
109:
110: //
111: // Geomtries
112: //
113: /** Geometry to Geometry.class */
114: public static final GeometryType GEOMETRY = new GeometryTypeImpl(
115: new TypeName(NAMESPACE, "geometry"), Geometry.class, null,
116: false, false, Collections.EMPTY_SET, null, null);
117: /** POINT (extends GEOMETRY) binds to Point.class */
118: public static final GeometryType POINT = new GeometryTypeImpl(
119: new TypeName(NAMESPACE, "point"), Point.class, null, false,
120: false, Collections.EMPTY_SET, GEOMETRY, null);
121: /** LINESTRING (extends GEOMETRY) binds to LineString.class */
122: public static final GeometryType LINESTRING = new GeometryTypeImpl(
123: new TypeName(NAMESPACE, "linestring"), LineString.class,
124: null, false, false, Collections.EMPTY_SET, GEOMETRY, null);
125: /** LINEARRING (extends GEOMETRY) binds to LinearRing.class */
126: public static final GeometryType LINEARRING = new GeometryTypeImpl(
127: new TypeName(NAMESPACE, "linearring"), LinearRing.class,
128: null, false, false, Collections.EMPTY_SET, LINESTRING, null);
129: /** POLYGON (extends GEOMETRY) binds to Polygon.class */
130: public static final GeometryType POLYGON = new GeometryTypeImpl(
131: new TypeName(NAMESPACE, "polygon"), Polygon.class, null,
132: false, false, Collections.EMPTY_SET, GEOMETRY, null);
133: /** MULTIGEOMETRY (extends GEOMETRY) binds to GeometryCollection.class */
134: public static final GeometryType MULTIGEOMETRY = new GeometryTypeImpl(
135: new TypeName(NAMESPACE, "multigeometry"),
136: GeometryCollection.class, null, false, false,
137: Collections.EMPTY_SET, GEOMETRY, null);
138:
139: /** MULTIPOINT (extends MULTIGEOMETRY) binds to MultiPoint.class */
140: public static final GeometryType MULTIPOINT = new GeometryTypeImpl(
141: new TypeName(NAMESPACE, "multipoint"), MultiPoint.class,
142: null, false, false, Collections.EMPTY_SET, MULTIGEOMETRY,
143: null);
144:
145: /** MULTILINESTRING (extends MULTIGEOMETRY) binds to MultiLineString.class */
146: public static final GeometryType MULTILINESTRING = new GeometryTypeImpl(
147: new TypeName(NAMESPACE, "multilinestring"),
148: MultiLineString.class, null, false, false,
149: Collections.EMPTY_SET, MULTIGEOMETRY, null);
150:
151: /** MULTIPOLYGON (extends MULTIGEOMETRY) binds to MultiPolygon.class */
152: public static final GeometryType MULTIPOLYGON = new GeometryTypeImpl(
153: new TypeName(NAMESPACE, "multipolygon"),
154: MultiPolygon.class, null, false, false,
155: Collections.EMPTY_SET, MULTIGEOMETRY, null);
156:
157: public SimpleSchema() {
158: super(NAMESPACE);
159:
160: put(INTEGER.getName(), INTEGER);
161: put(DOUBLE.getName(), DOUBLE);
162: put(LONG.getName(), LONG);
163: put(FLOAT.getName(), FLOAT);
164: put(SHORT.getName(), SHORT);
165: put(BYTE.getName(), BYTE);
166: put(NUMBER.getName(), NUMBER);
167: put(STRING.getName(), STRING);
168: put(BOOLEAN.getName(), BOOLEAN);
169: put(DATE.getName(), DATE);
170: put(DATETIME.getName(), DATETIME);
171:
172: put(GEOMETRY.getName(), GEOMETRY);
173: put(POINT.getName(), POINT);
174: put(LINESTRING.getName(), LINESTRING);
175: put(LINEARRING.getName(), LINEARRING);
176: put(POLYGON.getName(), POLYGON);
177: put(MULTIGEOMETRY.getName(), MULTIGEOMETRY);
178: put(MULTIGEOMETRY.getName(), MULTIGEOMETRY);
179: put(MULTIPOINT.getName(), MULTIPOINT);
180: put(MULTILINESTRING.getName(), MULTILINESTRING);
181: put(MULTIPOLYGON.getName(), MULTIPOLYGON);
182:
183: }
184:
185: }
|