Project

General

Profile

1 3035 perry
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2003 Regents of the University of California.
4
 *
5
 * Author: Matthew Perry
6
 * '$Date$'
7
 * '$Revision$'
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 */
23
package edu.ucsb.nceas.metacat.spatial;
24
25
import edu.ucsb.nceas.metacat.MetaCatUtil;
26
27
import com.vividsolutions.jts.geom.MultiPolygon;
28
import com.vividsolutions.jts.geom.MultiPoint;
29
import org.geotools.feature.AttributeType;
30
import org.geotools.feature.AttributeTypeFactory;
31
import org.geotools.feature.FeatureType;
32
import org.geotools.feature.FeatureTypeFactory;
33
import org.geotools.feature.SchemaException;
34
35
import org.apache.log4j.Logger;
36
37 3040 perry
/**
38
 * Class representing the geotools feature schemas and file paths
39
 * for the spatial data cache.
40
 */
41 3035 perry
public class SpatialFeatureSchema {
42
43
  private static Logger log =
44
      Logger.getLogger(SpatialFeatureSchema.class.getName());
45
46
  public static String polygonShpUri = MetaCatUtil.getOption("certPath") + "data/metacat_shps/data_bounds.shp";
47
  public static String pointShpUri = MetaCatUtil.getOption("certPath")+ "data/metacat_shps/data_points.shp";
48
49
  // EPSG for latlong coordinate system w/ WGS84 datum
50
  public static int srid = 4326;
51
52
  /** empty constructor **/
53
  public SpatialFeatureSchema() {
54
55
  }
56
57 3040 perry
  /**
58 3035 perry
   * Creates the featuretype schema for polygon bounds
59
   */
60
  public static FeatureType getPolygonFeatureType() {
61
    try {
62
        AttributeType[] types = new AttributeType[4];
63
        types[0] = AttributeTypeFactory.newAttributeType("the_geom", com.vividsolutions.jts.geom.MultiPolygon.class);
64
        types[1] = AttributeTypeFactory.newAttributeType("docid", String.class);
65
        types[2] = AttributeTypeFactory.newAttributeType("url", String.class);
66
        types[3] = AttributeTypeFactory.newAttributeType("title", String.class);
67
        FeatureType boundsType = FeatureTypeFactory.newFeatureType(types, "bounds");
68
        return boundsType;
69
    } catch(SchemaException e) {
70
        log.error("schema exception : "+e);
71
        return null;
72
    }
73
  }
74
75 3040 perry
  /**
76 3035 perry
   * Creates the featuretype schema for point centroids
77
   */
78
  public static FeatureType getPointFeatureType() {
79
    try {
80
        AttributeType[] types = new AttributeType[4];
81
        types[0] = AttributeTypeFactory.newAttributeType("the_geom", com.vividsolutions.jts.geom.MultiPoint.class);
82
        types[1] = AttributeTypeFactory.newAttributeType("docid", String.class);
83
        types[2] = AttributeTypeFactory.newAttributeType("url", String.class);
84
        types[3] = AttributeTypeFactory.newAttributeType("title", String.class);
85
        FeatureType centroidsType = FeatureTypeFactory.newFeatureType(types, "centroids");
86
        return centroidsType;
87
    } catch(SchemaException e) {
88
        log.error("schema exception : "+e);
89
        return null;
90
    }
91
  }
92
93
}