Project

General

Profile

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

    
26
package edu.ucsb.nceas.metacat.spatial;
27

    
28
import org.apache.log4j.Logger;
29

    
30
/**
31
 * Class that reflects a query against Metacat to gather spatial data  -- this
32
 * could be a text query that returns a spatial dataset or a spatial query that
33
 * returns a spatially-referenced dataset.
34
 */
35
public class MetacatSpatialQuery {
36
  
37
  private static Logger log = Logger.getLogger(MetacatSpatialQuery.class.getName());
38

    
39
  private MetacatSpatialDocument msd;
40

    
41
  private SpatialQueryProcessor mqp;
42

    
43
  public MetacatSpatialQuery() { }
44

    
45
  /// query that returns a dataset constarined by a bounding box
46
  public MetacatSpatialDataset queryDatasetByCartesianBounds(float _xmin,
47
                                                             float _ymin, 
48
                                                             float _xmax, 
49
                                                             float _ymax) {
50
  
51
 
52
    /** all database querying is carried out in the Query Processor */
53
    mqp = new  SpatialQueryProcessor();
54
    
55
    // return the proc's results
56
    return mqp.queryDatasetByCartesianBounds(_xmin, _ymin, _xmax, _ymax);
57
 
58
  }
59

    
60

    
61
  /**
62
   * returns the metacat spatial document retrieved by this query
63
   */
64
  public MetacatSpatialDocument getSpatialDocument(String docid) {
65
    msd = new MetacatSpatialDocument(docid);
66
    
67
    log.info("creating spatial reference for docid: " + docid);
68
    
69
    /** all database querying is carried out in the Query Processor */
70
    mqp = new  SpatialQueryProcessor();
71
    
72
    // this call will return the extents (a class) of the docid
73
    MetacatSpatialExtents _extents = mqp.queryExtentsByDocid(docid);
74

    
75
    //set the elements on the spatialdocument
76
    msd.setDocid(docid);
77
    msd.setExtents(_extents);
78

    
79
    // destroy the processor
80
    mqp.close();
81
   
82
   return msd; 
83
  }
84

    
85
}
(5-5/10)