Project

General

Profile

« Previous | Next » 

Revision 3070

Added by perry about 18 years ago

Changed float object handling in spatial components in order to compile on jdk 1.4.2

View differences:

src/edu/ucsb/nceas/metacat/spatial/SpatialQuery.java
85 85
   * @param n North bounding coordinate 
86 86
   *
87 87
   */
88
  public Vector filterByBbox( Float w, Float s, Float e, Float n ) {
88
  public Vector filterByBbox( float w, float s, float e, float n ) {
89 89
      Vector docids = new Vector();
90 90
      SpatialFeatureSchema featureSchema = new SpatialFeatureSchema();
91 91
      
src/edu/ucsb/nceas/metacat/spatial/SpatialDocument.java
103 103
      rs = pstmt.getResultSet();
104 104
      while (rs.next()) {
105 105
        if ( rs.getString(1).equals( MetaCatUtil.getOption("westBoundingCoordinatePath") ) )
106
            this.west.add( rs.getFloat(2) );
106
            this.west.add( new Float(rs.getFloat(2)) );
107 107
        else if ( rs.getString(1).equals( MetaCatUtil.getOption("southBoundingCoordinatePath") ) )
108
            this.south.add( rs.getFloat(2) );
108
            this.south.add( new Float(rs.getFloat(2)));
109 109
        else if ( rs.getString(1).equals( MetaCatUtil.getOption("eastBoundingCoordinatePath") ) )
110
            this.east.add( rs.getFloat(2) );
110
            this.east.add( new Float(rs.getFloat(2)) );
111 111
        else if ( rs.getString(1).equals( MetaCatUtil.getOption("northBoundingCoordinatePath") ) )
112
            this.north.add( rs.getFloat(2) );
112
            this.north.add( new Float(rs.getFloat(2)) );
113 113
        else
114 114
            log.error("** An xml path not related to your bounding coordinates was returned by this query \n" + query + "\n");
115 115
      }
......
232 232
    PrecisionModel precModel = new PrecisionModel(); // default: Floating point
233 233
    GeometryFactory geomFac = new GeometryFactory( precModel, featureSchema.srid );
234 234
    Vector polygons = new Vector();
235
    Float w;
236
    Float s;
237
    Float e;
238
    Float n;
235
    float w;
236
    float s;
237
    float e;
238
    float n;
239 239

  
240 240
    if ( west.size() == south.size() && south.size() == east.size() && east.size() == north.size() ) {
241 241
        for (int i = 0; i < west.size(); i++) {
242 242

  
243
            w = (Float)west.elementAt(i);
244
            s = (Float)south.elementAt(i);
245
            e = (Float)east.elementAt(i);
246
            n = (Float)north.elementAt(i);
243
            w = ((Float)west.elementAt(i)).floatValue();
244
            s = ((Float)south.elementAt(i)).floatValue();
245
            e = ((Float)east.elementAt(i)).floatValue();
246
            n = ((Float)north.elementAt(i)).floatValue();
247 247

  
248 248
            // Check if it's actually a valid polygon
249 249
            if (  w == 0.0 && s == 0.0 && e == 0.0 && n == 0.0) {
250 250
                log.warn("        Invalid or empty coodinates ... skipping");
251 251
                continue;
252
            } else if( w.compareTo( e ) == 0 && n.compareTo( s ) == 0 ) {
252
            } else if( Float.compare(w, e) == 0 && Float.compare(n,s) == 0 ) {
253 253
                log.warn("        Point coordinates only.. skipping polygon generation");
254 254
                continue;
255 255
            }
......
258 258
            // dateline crossing is valid 
259 259
            // polar crossing is not ( so we swap north and south )
260 260
            // Assumes all coordinates are confined to -180 -90 180 90
261
            Float dl = new Float("180.0");
262
            Float _dl = new Float("-180.0");
261
            float dl = 180.0f;
262
            float _dl = -180.0f;
263 263
            
264 264
            if ( w > e && s > n ) {
265 265
                log.info( "Crosses both the dateline and the poles .. split into 2 polygons, swap n & s" );
......
297 297
  /**
298 298
   * Returns a polygon given the four bounding box coordinates
299 299
   */
300
  private Polygon createPolygonFromBbox( GeometryFactory geomFac, Float w, Float s, Float e, Float n ) {
300
  private Polygon createPolygonFromBbox( GeometryFactory geomFac, float w, float s, float e, float n ) {
301 301

  
302 302
        Coordinate[] linestringCoordinates = new Coordinate[5];
303 303

  
......
320 320

  
321 321
    PrecisionModel precModel = new PrecisionModel(); // default: Floating point
322 322
    GeometryFactory geomFac = new GeometryFactory( precModel, featureSchema.srid );
323
    Float w;
324
    Float s;
325
    Float e;
326
    Float n;
323
    float w;
324
    float s;
325
    float e;
326
    float n;
327 327

  
328 328
    PreparedStatement pstmt = null;
329 329
    ResultSet rs = null;
......
333 333
    if ( west.size() == south.size() && south.size() == east.size() && east.size() == north.size() ) {
334 334
        for (int i = 0; i < west.size(); i++) {
335 335

  
336
            w = (Float)west.elementAt(i);
337
            s = (Float)south.elementAt(i);
338
            e = (Float)east.elementAt(i);
339
            n = (Float)north.elementAt(i);
336
            w = ((Float)west.elementAt(i)).floatValue();
337
            s = ((Float)south.elementAt(i)).floatValue();
338
            e = ((Float)east.elementAt(i)).floatValue();
339
            n = ((Float)north.elementAt(i)).floatValue();
340 340

  
341 341
            // Check if it's actually a valid point
342
            if (  w == 0.0 && s == 0.0 && e == 0.0 && n == 0.0) {
342
            if (  w == 0.0f && s == 0.0f && e == 0.0f && n == 0.0f) {
343 343
                 log.warn("        Invalid or empty coodinates ... skipping");
344 344
                 continue;
345 345
            }
346 346

  
347
            Double xCenter;
348
            Double yCenter;
347
            float xCenter;
348
            float yCenter;
349 349

  
350 350
            // Handle the case of crossing the dateline and poles
351 351
            // Assumes all coordinates are confined to -180 -90 180 90
352 352

  
353 353
            if ( w > e ) {
354 354
                log.info( "Crosses the dateline .. " );
355
                xCenter = ((float)360.0 - w + e)/ (Double)2.0 + w;
356
                if( xCenter > 180 )
357
                    xCenter = xCenter - 360;
358
                yCenter = ( s + n ) / (Double) 2.0;
355
                xCenter = (360.0f - w + e)/ 2.0f + w;
356
                if( xCenter > 180.0f )
357
                    xCenter = xCenter - 360.0f;
358
                yCenter = ( s + n ) / 2.0f;
359 359
            } else {
360 360
                // Just a standard point that can be calculated by the average coordinates
361
                xCenter = ( w + e ) / (Double) 2.0;
362
                yCenter = ( s + n ) / (Double) 2.0;
361
                xCenter = ( w + e ) / 2.0f;
362
                yCenter = ( s + n ) / 2.0f;
363 363
            }
364 364

  
365 365
            points.add( geomFac.createPoint( new Coordinate( xCenter, yCenter)) );
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
800 800
        /* 
801 801
         * Perform spatial query against spatial cache
802 802
         */
803
        Float _xmax = Float.parseFloat( ((String[]) params.get("XMAX"))[0] );
804
        Float _ymax = Float.parseFloat( ((String[]) params.get("YMAX"))[0] );
805
        Float _xmin = Float.parseFloat( ((String[]) params.get("XMIN"))[0] );
806
        Float _ymin = Float.parseFloat( ((String[]) params.get("YMIN"))[0] );
803
        float _xmax = Float.valueOf( ((String[]) params.get("XMAX"))[0] ).floatValue();
804
        float _ymax = Float.valueOf( ((String[]) params.get("YMAX"))[0] ).floatValue();
805
        float _xmin = Float.valueOf( ((String[]) params.get("XMIN"))[0] ).floatValue();
806
        float _ymin = Float.valueOf( ((String[]) params.get("YMIN"))[0] ).floatValue();
807 807
        SpatialQuery sq = new SpatialQuery();
808 808
        Vector docids = sq.filterByBbox( _xmin, _ymin, _xmax, _ymax );
809
        logMetacat.info(" --- Spatial Query completed. Passing on the SQuery handler");
810
        logMetacat.warn("\n\n ******* after spatial query, we've got " + docids.size() + " docids \n\n");
809
        // logMetacat.info(" --- Spatial Query completed. Passing on the SQuery handler");
810
        // logMetacat.warn("\n\n ******* after spatial query, we've got " + docids.size() + " docids \n\n");
811 811

  
812 812
        /*
813 813
         * Create an array matching docids
......
819 819
         * Create squery string
820 820
         */
821 821
        String squery = DocumentIdQuery.createDocidQuery( docidArray );
822
        logMetacat.info("-----------\n" + squery + "\n------------------");
822
        // logMetacat.info("-----------\n" + squery + "\n------------------");
823 823
        String[] queryArray = new String[1];
824 824
        queryArray[0] = squery;
825 825
        params.put("query", queryArray);
src/edu/ucsb/nceas/metacat/DocumentImpl.java
2890 2890
       ForceReplicationHandler frh = new ForceReplicationHandler(
2891 2891
                        accnum, ForceReplicationHandler.DELETE, isXML, notifyServer);
2892 2892

  
2893
       // Deletes the docid from the spatial data cache 
2894
       /* MPTODO : getting "non-static variable cannot be reffered to from a static context" error
2895
       SpatialHarvester spatialHarvester = new SpatialHarvester();
2896
       logMetacat.warn(" --------- Attempting to delete the spatial cache for docid " + docid );
2897
       spatialHarvester.addToDeleteQue(docid);
2898
       spatialHarvester.destroy();
2899
       */
2900

  
2901 2893
    }
2902 2894

  
2903 2895
    private static String getDocTypeFromDB(DBConnection conn, String docidWithoutRev)

Also available in: Unified diff