Changeset 4640


Ignore:
Timestamp:
Jul 25, 2007, 1:52:26 PM (17 years ago)
Author:
nick
Message:

added the functionality to get_data_points as_lat_long in the northern hemisphere. Plus added a test

Location:
anuga_core/source/anuga/geospatial_data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4633 r4640  
    360360       
    361361    def get_data_points(self, absolute=True, geo_reference=None,
    362                         as_lat_long=False):
     362                        as_lat_long=False,isSH=True):
    363363        """Get coordinates for all data points as an Nx2 array
    364364
     
    369369        If a geo_reference is passed the points are returned relative
    370370        to that geo_reference.
     371       
     372        isSH (isSouthHemisphere) is only used when getting data
     373        points "as_lat_long" is True and if FALSE will return lats and
     374        longs valid for the Northern Hemisphere.
    371375
    372376        Default: absolute is True.
     
    380384            for point in self.get_data_points(True):
    381385                ### UTMtoLL(northing, easting, zone,
    382                 lat_calced, long_calced = UTMtoLL(point[1],point[0], zone)
     386                lat_calced, long_calced = UTMtoLL(point[1],point[0],
     387                                                  zone, isSH)
    383388                lats_longs.append((lat_calced, long_calced)) # to hash
    384389            return lats_longs
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r4549 r4640  
    210210        assert allclose(seg_lat_long[0][0], lat_result)#lat
    211211        assert allclose(seg_lat_long[0][1], long_result)#long
     212
     213
     214    def test_get_data_points_lat_longIII(self):
     215        # x,y  North,east long,lat
     216        #for northern hemisphere
     217        boundary_polygon = [[419944.8, 918642.4]]
     218        zone = 47
     219       
     220        geo_reference = Geo_reference(zone=zone)
     221        geo = Geospatial_data(boundary_polygon,geo_reference=geo_reference)
     222        seg_lat_long = geo.get_data_points(as_lat_long=True,isSH=False)
     223        lat_result = degminsec2decimal_degrees(8.31,0,0)
     224        long_result = degminsec2decimal_degrees(98.273,0,0)
     225        #print "seg_lat_long", seg_lat_long [0]
     226        #print "lat_result",lat_result
     227        assert allclose(seg_lat_long[0][0], lat_result)#lat
     228        assert allclose(seg_lat_long[0][1], long_result)#long
     229
    212230
    213231             
     
    23482366
    23492367    #suite = unittest.makeSuite(Test_Geospatial_data, 'test_write_csv_attributes_lat_long')
    2350     #suite = unittest.makeSuite(Test_Geospatial_data, 'test_export_xya_file')
     2368    #suite = unittest.makeSuite(Test_Geospatial_data, 'test_get_data_points_lat_longIII')
    23512369    suite = unittest.makeSuite(Test_Geospatial_data, 'test')
    23522370    runner = unittest.TextTestRunner()
Note: See TracChangeset for help on using the changeset viewer.