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 4080 daigle
import edu.ucsb.nceas.metacat.util.SystemUtil;
26
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
27 3035 perry
28
import com.vividsolutions.jts.geom.MultiPolygon;
29
import com.vividsolutions.jts.geom.MultiPoint;
30
import org.geotools.feature.AttributeType;
31
import org.geotools.feature.AttributeTypeFactory;
32
import org.geotools.feature.FeatureType;
33
import org.geotools.feature.FeatureTypeFactory;
34
import org.geotools.feature.SchemaException;
35
36
import org.apache.log4j.Logger;
37
38 3040 perry
/**
39
 * Class representing the geotools feature schemas and file paths
40
 * for the spatial data cache.
41
 */
42 3035 perry
public class SpatialFeatureSchema {
43
44 4080 daigle
	private static Logger log = Logger.getLogger(SpatialFeatureSchema.class.getName());
45 3035 perry
46 4080 daigle
	private static String certPath;
47
	static {
48
		try {
49
			certPath = SystemUtil.getContextDir();
50
		} catch (PropertyNotFoundException pnfe) {
51
			System.err.println("Error in SpatialFeatureSchema static block:"
52
                    + pnfe.getMessage());
53
            pnfe.printStackTrace();
54
		}
55
	}
56 4167 leinfelder
	public static String polygonShpUri = certPath + "/data/metacat_shps/data_bounds.shp";
57
	public static String pointShpUri = certPath + "/data/metacat_shps/data_points.shp";
58 3035 perry
59 4080 daigle
60 3035 perry
  // EPSG for latlong coordinate system w/ WGS84 datum
61
  public static int srid = 4326;
62
63
  /** empty constructor **/
64
  public SpatialFeatureSchema() {
65
66
  }
67
68 3040 perry
  /**
69 3035 perry
   * Creates the featuretype schema for polygon bounds
70
   */
71
  public static FeatureType getPolygonFeatureType() {
72
    try {
73
        AttributeType[] types = new AttributeType[4];
74
        types[0] = AttributeTypeFactory.newAttributeType("the_geom", com.vividsolutions.jts.geom.MultiPolygon.class);
75
        types[1] = AttributeTypeFactory.newAttributeType("docid", String.class);
76
        types[2] = AttributeTypeFactory.newAttributeType("url", String.class);
77
        types[3] = AttributeTypeFactory.newAttributeType("title", String.class);
78
        FeatureType boundsType = FeatureTypeFactory.newFeatureType(types, "bounds");
79
        return boundsType;
80
    } catch(SchemaException e) {
81
        log.error("schema exception : "+e);
82
        return null;
83
    }
84
  }
85
86 3040 perry
  /**
87 3035 perry
   * Creates the featuretype schema for point centroids
88
   */
89
  public static FeatureType getPointFeatureType() {
90
    try {
91
        AttributeType[] types = new AttributeType[4];
92
        types[0] = AttributeTypeFactory.newAttributeType("the_geom", com.vividsolutions.jts.geom.MultiPoint.class);
93
        types[1] = AttributeTypeFactory.newAttributeType("docid", String.class);
94
        types[2] = AttributeTypeFactory.newAttributeType("url", String.class);
95
        types[3] = AttributeTypeFactory.newAttributeType("title", String.class);
96
        FeatureType centroidsType = FeatureTypeFactory.newFeatureType(types, "centroids");
97
        return centroidsType;
98
    } catch(SchemaException e) {
99
        log.error("schema exception : "+e);
100
        return null;
101
    }
102
  }
103
104
}