Changeset 3398


Ignore:
Timestamp:
Jul 21, 2006, 2:26:18 PM (18 years ago)
Author:
duncan
Message:

if csv files don't have lat.long, check for x,y

Location:
inundation/pyvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r3336 r3398  
    729729class Exposure_csv:
    730730    def __init__(self,file_name, latitude_title=LAT_TITLE,
    731                  longitude_title=LONG_TITLE, is_x_y_locations=False,
     731                 longitude_title=LONG_TITLE, is_x_y_locations=None,
    732732                 x_title=X_TITLE, y_title=Y_TITLE,
    733733                 refine_polygon=None):
     
    777777        except KeyError:
    778778            # maybe a warning..
     779            #Let's see if this works..
     780            if False != is_x_y_locations:
     781                is_x_y_locations = True
    779782            pass
    780783        else:
     
    782785                 longitudes = longs)
    783786
    784         if is_x_y_locations:
     787        if is_x_y_locations is True:
    785788            if self._geospatial is not None:
    786789                pass #fixme throw an error
  • inundation/pyvolution/test_data_manager.py

    r3336 r3398  
    49134913
    49144914        os.remove(file_name)
     4915
     4916           
     4917    def test_exposure_csv_loading_x_y2(self):
     4918       
     4919        csv_file = tempfile.mktemp(".csv")
     4920        fd = open(csv_file,'wb')
     4921        writer = csv.writer(fd)
     4922        writer.writerow(['x','y','STR_VALUE','C_VALUE','ROOF_TYPE','WALLS', 'SHORE_DIST'])
     4923        writer.writerow([5.5,0.5,'199770','130000','Metal','Timber',20])
     4924        writer.writerow([4.5,1.0,'150000','76000','Metal','Double Brick',20])
     4925        writer.writerow([4.5,1.5,'150000','76000','Metal','Brick Veneer',20])
     4926        fd.close()
     4927
     4928        e1 = Exposure_csv(csv_file)
     4929        gsd = e1.get_location()
     4930       
     4931        points = gsd.get_data_points(absolute=True)
     4932        assert allclose(points[0][0], 5.5)
     4933        assert allclose(points[0][1], 0.5)
     4934        assert allclose(points[1][0], 4.5)
     4935        assert allclose(points[1][1], 1.0)
     4936        assert allclose(points[2][0], 4.5)
     4937        assert allclose(points[2][1], 1.5)
     4938        self.failUnless(gsd.get_geo_reference().get_zone() == -1,
     4939                        'Bad zone error!')
     4940
     4941        os.remove(csv_file)
    49154942       
    49164943#-------------------------------------------------------------
    49174944if __name__ == "__main__":
    4918     #suite = unittest.makeSuite(Test_Data_Manager,'test_exposure_csv_loadiny')
     4945    #suite = unittest.makeSuite(Test_Data_Manager,'test_exposure_csv_loading_x_y2')
    49194946    suite = unittest.makeSuite(Test_Data_Manager,'test')
    49204947    runner = unittest.TextTestRunner()
    49214948    runner.run(suite)
    49224949
     4950
Note: See TracChangeset for help on using the changeset viewer.