1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2000 Regents of the University of California and the
|
4
|
* National Center for Ecological Analysis and Synthesis
|
5
|
*
|
6
|
* Author: John Harris
|
7
|
* '$Date: 2006-02-19 21:11:53 -0800 (Sun, 19 Feb 2006) $'
|
8
|
* '$Revision: 2910 $'
|
9
|
*
|
10
|
* This program is free software; you can redistribute it and/or modify
|
11
|
* it under the terms of the GNU General Public License as published by
|
12
|
* the Free Software Foundation; either version 2 of the License, or
|
13
|
* (at your option) any later version.
|
14
|
*
|
15
|
* This program is distributed in the hope that it will be useful,
|
16
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
* GNU General Public License for more details.
|
19
|
*
|
20
|
* You should have received a copy of the GNU General Public License
|
21
|
* along with this program; if not, write to the Free Software
|
22
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
*/
|
24
|
|
25
|
package edu.ucsb.nceas.metacat.spatial;
|
26
|
|
27
|
import java.util.Vector;
|
28
|
|
29
|
import org.apache.log4j.Logger;
|
30
|
|
31
|
/**
|
32
|
* Class that reflects a dataset of Metacat Documents in a spatially represented
|
33
|
* sense. This dataset class is comprised of multiple MetacatSpatialDocument
|
34
|
* and uses the PersistentMetacatSpatialDataset class for IO with databases
|
35
|
* and the file system
|
36
|
*/
|
37
|
public class MetacatSpatialDataset {
|
38
|
|
39
|
private boolean initialized = false;
|
40
|
|
41
|
private static Logger log = Logger.getLogger(MetacatSpatialDataset.class.getName());
|
42
|
|
43
|
private Vector docs; // vector of MetacatSpatialDocument's
|
44
|
|
45
|
|
46
|
/** empty constructor **/
|
47
|
public MetacatSpatialDataset() {
|
48
|
this.initialized = true;
|
49
|
docs = new Vector();
|
50
|
}
|
51
|
|
52
|
/*
|
53
|
* Adds a new MetacatSpatialDocument to this dataset
|
54
|
*/
|
55
|
public void add(MetacatSpatialDocument msdoc) {
|
56
|
docs.add(msdoc);
|
57
|
}
|
58
|
|
59
|
|
60
|
/**
|
61
|
* Returns the size (or number of documents) of the dataset
|
62
|
*/
|
63
|
public int size() {
|
64
|
return docs.size();
|
65
|
}
|
66
|
|
67
|
|
68
|
/**
|
69
|
* returns the data set as a flat-ascii table like:
|
70
|
*
|
71
|
* x y z segid
|
72
|
*
|
73
|
* the data are delimited by spaces and each line is terminated bt '\n'
|
74
|
*/
|
75
|
public StringBuffer getExtentsDataAsAscii() {
|
76
|
StringBuffer _sb = new StringBuffer();
|
77
|
for (int i = 0; i < docs.size(); i++) {
|
78
|
MetacatSpatialDocument _doc = (MetacatSpatialDocument)docs.elementAt(i);
|
79
|
if ( ! _doc.getIsPoint() ) {
|
80
|
_sb.append( _doc.getXMin()+ " " + _doc.getYMin() + " 0 " + _doc.getDocid()+"\n");
|
81
|
_sb.append( _doc.getXMax()+ " " + _doc.getYMin() + " 0 " + _doc.getDocid()+"\n");
|
82
|
_sb.append( _doc.getXMax()+ " " + _doc.getYMax() + " 0 " + _doc.getDocid()+"\n");
|
83
|
_sb.append( _doc.getXMin()+ " " + _doc.getYMax() + " 0 " + _doc.getDocid()+"\n");
|
84
|
}
|
85
|
}
|
86
|
return _sb;
|
87
|
}
|
88
|
|
89
|
|
90
|
/*
|
91
|
* Writes the dataset to the file system
|
92
|
*/
|
93
|
public void writeTextQueryData() {
|
94
|
|
95
|
// write the data stored in this object using the persistent layer
|
96
|
PersistentMetacatSpatialDataset _writer = new PersistentMetacatSpatialDataset();
|
97
|
_writer.writeTextQueryData(this);
|
98
|
|
99
|
}
|
100
|
|
101
|
|
102
|
|
103
|
|
104
|
}
|