Project

General

Profile

« Previous | Next » 

Revision 2970

Added by sgarg over 18 years ago

Changes in the spatial query. The spatial query can be generated on the client side in form of an squery rather than specifically creating one on the server side.
Commented out the code which creates spatial query based on the coordinates sent to Metacat. Instead of that, a temporary method was added which creates the squery
and passes that.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
598 598
                }
599 599
            } else if ( action.trim().equals("spatial_query")) {
600 600

  
601
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
602
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
603
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
604
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
605
              logMetacat.fatal("******************* SPATIAL QUERY ********************");
606

  
607
              
601
              logMetacat.debug("******************* SPATIAL QUERY ********************");
608 602
              PrintWriter out = response.getWriter();
609 603
              handleSpatialQuery(out, params, response, username, groupnames, sess_id);
610 604
              out.close();
......
788 782
                                    String sess_id) {
789 783
      
790 784
      Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
785
      //MBJDELETED MetacatSpatialQuery _spatialQuery = new MetacatSpatialQuery();
791 786

  
792

  
793 787
	if (MetacatSpatialConstants.runSpatialOption == false ) {
794 788
        	response.setContentType("text/html");
795 789
        	out.println("<html> Metacat Spatial Option is turned off <html>");
......
801 795
      
802 796
      
803 797
      // switch -- html/xml print
804
      boolean printXML = false; 
798
      //MBJDELETED boolean printXML = false; 
805 799
      
806 800
      // get the spatial parameters
807
      logMetacat.warn("params: " +  params);
801
      logMetacat.debug("params: " +  params);
808 802
      //String _xmax =  (String)params.get("XMAX");
809 803
      float _xmax = Float.parseFloat( ((String[]) params.get("XMAX"))[0] );
810 804
      float _ymax = Float.parseFloat( ((String[]) params.get("YMAX"))[0] );
811 805
      float _xmin = Float.parseFloat( ((String[]) params.get("XMIN"))[0] );
812 806
      float _ymin = Float.parseFloat( ((String[]) params.get("YMIN"))[0] );
813
      logMetacat.warn("\nxmax: " + _xmax + " \nymax:" + _ymax +
807
      logMetacat.debug("\nxmax: " + _xmax + " \nymax:" + _ymax +
814 808
                      "\nxmin: " + _xmin + "\nymin: " + _ymin);
815 809

  
816 810

  
817 811

  
818 812
      // issue the Spatial query 
819
      MetacatSpatialDataset _data =  
820
        _spatialQuery.queryDatasetByCartesianBounds(_xmin, _ymin, _xmax, _ymax);
813
      //MBJ DELETED MetacatSpatialDataset _data =  
814
        //MBJ DELETED _spatialQuery.queryDatasetByCartesianBounds(_xmin, _ymin, _xmax, _ymax);
821 815

  
822 816
      // report the number of documents returned:
817
      //MBJ DELETED logMetacat.warn("\nThe number of documents in the BBOX query: " 
818
              //MBJ DELETED + _data.size()+" the doc. list: '" + _data.toTXT().trim()+"'" );
819
     
820
/* MBJ DELETED -- using Metacat query instead
821
if (  _data.size() > 0) { 
823 822
      logMetacat.warn("\nThe number of documents in the BBOX query: " 
824 823
              + _data.size()+" the doc. list: '" + _data.toTXT().trim()+"'" );
825 824
     
826
if (  _data.size() > 0) { 
827 825
      
828 826
      // create an s-query
829 827
      String[] queryArray = new String[1];
......
854 852
        out.println("<html>No Datasets Selected <html>");
855 853
        out.close();
856 854
}
855
*/
856
      	// create an s-query
857
        String spatialQuery = createSpatialQuery(_xmax, _ymax, _xmin, _ymin);
858
      	String[] queryArray = new String[1];
859
      	queryArray[0] = spatialQuery;
860
      	params.put("query", queryArray);
861
      	
862
      	// qformat        
863
      	String[] qformatArray = new String[1];
864
      	qformatArray[0] = "knp";
865
      	params.put("qformat", qformatArray);
866
	
867
      	// change the action 
868
      	String[] actionArray = new String[1];
869
      	actionArray[0] = "squery";
870
      	params.put("action", actionArray);
857 871

  
858
      return;
872
        handleSQuery(out, params, response, username, groupnames, sess_id);  
859 873
    }
860 874

  
875
    /**
876
     * Create a metacat squery for spatial data coordinates.
877
     */
878
    private String createSpatialQuery(float _xmin, float _ymin, float _xmax, float _ymax) {
879
	StringBuffer sb = new StringBuffer();
880
	    
881
	sb.append("<pathquery version=\"1.2\">");
882
	sb.append("<querytitle>Untitled-Search-3</querytitle>");
883
	sb.append("<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN</returndoctype>");
884
	sb.append("<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN</returndoctype>");
885
	sb.append("<returndoctype>-//NCEAS//eml-dataset-2.0//EN</returndoctype>");
886
	sb.append("<returndoctype>-//NCEAS//resource//EN</returndoctype>");
887
	sb.append("<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>");
888
	sb.append("<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>");
889
	sb.append("<returndoctype>metadata</returndoctype>");
890
	sb.append("<returnfield>dataset/title</returnfield>");
891
	sb.append("<returnfield>originator/individualName/surName</returnfield>");
892
	sb.append("<returnfield>originator/individualName/givenName</returnfield>");
893
	sb.append("<returnfield>originator/organizationName</returnfield>");
894
	sb.append("<returnfield>creator/individualName/surName</returnfield>");
895
	sb.append("<returnfield>creator/individualName/givenName</returnfield>");
896
	sb.append("<returnfield>creator/organizationName</returnfield>");
897
	sb.append("<returnfield>keyword</returnfield>");
898
	sb.append("<returnfield>entityName</returnfield>");
899
	sb.append("<returnfield>idinfo/citation/citeinfo/title</returnfield>");
900
	sb.append("<returnfield>idinfo/citation/citeinfo/origin</returnfield>");
901
	sb.append("<returnfield>idinfo/keywords/theme/themekey</returnfield>");
902
	sb.append("<querygroup operator=\"INTERSECT\">");
903
	sb.append("<queryterm searchmode=\"less-than\" casesensitive=\"false\">");
904
	sb.append("<value>" + _ymin + "</value>");
905
	sb.append("<pathexpr>northBoundingCoordinate</pathexpr>");
906
	sb.append("</queryterm>");
907
	sb.append("<queryterm searchmode=\"greater-than\" casesensitive=\"false\">");
908
	sb.append("<value>" + _ymax + "</value>");
909
	sb.append("<pathexpr>northBoundingCoordinate</pathexpr>");
910
	sb.append("</queryterm>");
911
	sb.append("<queryterm searchmode=\"less-than\" casesensitive=\"false\">");
912
	sb.append("<value>" + _xmin + "</value>");
913
	sb.append("<pathexpr>westBoundingCoordinate</pathexpr>");
914
	sb.append("</queryterm>");
915
	sb.append("<queryterm searchmode=\"greater-than\" casesensitive=\"false\">");
916
	sb.append("<value>" + _xmax + "</value>");
917
	sb.append("<pathexpr>westBoundingCoordinate</pathexpr>");
918
	sb.append("</queryterm>");
919
	sb.append("</querygroup>");
920
	sb.append("</pathquery>");
861 921

  
922
	return sb.toString();
923
    }
924

  
862 925
    // LOGIN & LOGOUT SECTION
863 926
    /**
864 927
     * Handle the login request. Create a new session object. Do user

Also available in: Unified diff