Changeset 4199 for anuga_core/source


Ignore:
Timestamp:
Jan 30, 2007, 5:20:08 PM (18 years ago)
Author:
duncan
Message:

fix up bug that was getting x and y round the wrong way in geospatial when lats and longs were used

Location:
anuga_core/source/anuga
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/coordinate_transforms/redfearn.py

    r3745 r4199  
    205205        new_geo = Geo_reference(zone)
    206206        old_geo.reconcile_zones(new_geo)       
    207         utm_points.append([easting, northing])
     207        utm_points.append([northing, easting])
    208208
    209209    return utm_points, old_geo.get_zone()
  • anuga_core/source/anuga/coordinate_transforms/test_redfearn.py

    r3745 r4199  
    158158        points, zone = convert_from_latlon_to_utm(latitudes=lats, longitudes=longs)
    159159
    160         assert allclose(points[0][0], 308728.009)
    161         assert allclose(points[0][1], 6180432.601)
    162         assert allclose(points[1][0],  222908.705)
    163         assert allclose(points[1][1], 6233785.284)
     160        assert allclose(points[0][0], 6180432.601)
     161        assert allclose(points[0][1], 308728.009)
     162        assert allclose(points[1][0], 6233785.284)
     163        assert allclose(points[1][1], 222908.705)
    164164        self.failUnless(zone == 56,
    165165                        'Bad zone error!')
     
    230230        points, zone = convert_from_latlon_to_utm(points=points)
    231231        #print "points",points
    232         assert allclose(points[0][0], 308728.009)
    233         assert allclose(points[0][1], 6180432.601)
    234         assert allclose(points[1][0],  222908.705)
    235         assert allclose(points[1][1], 6233785.284)
     232       
     233        assert allclose(points[0][0], 6180432.601)
     234        assert allclose(points[0][1], 308728.009)
     235        assert allclose(points[1][0], 6233785.284)
     236        assert allclose(points[1][1], 222908.705)
    236237        self.failUnless(zone == 56,
    237238                        'Bad zone error!')
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4195 r4199  
    1616   
    1717from anuga.utilities.numerical_tools import ensure_numeric
    18 from anuga.coordinate_transforms.geo_reference import Geo_reference, TitleError
     18
     19from anuga.coordinate_transforms.lat_long_UTM_conversion import UTMtoLL
     20from anuga.coordinate_transforms.geo_reference import Geo_reference, \
     21     TitleError, DEFAULT_ZONE
    1922from anuga.coordinate_transforms.redfearn import convert_from_latlon_to_utm
    2023from anuga.utilities.anuga_exceptions import ANUGAError
     
    332335        return self.geo_reference
    333336       
    334     def get_data_points(self, absolute=True, geo_reference=None):
    335         """Get coordinates for all data points as an Nx2 array
     337    def get_data_points(self, absolute=True, geo_reference=None,
     338                        as_lat_long=False):
     339        """Get coordinates for all data points as an Nx2 array.
     340        Column 0 is x values
     341        Column 1 is y values
    336342
    337343        If absolute is False returned coordinates are relative to the
     
    344350        Default: absolute is True.
    345351        """
    346 
     352        if as_lat_long is True:
     353            msg = "Points need a zone to be converted into lats and longs"
     354            assert self.geo_reference is not None, msg
     355            zone = self.geo_reference.get_zone()
     356            assert self.geo_reference.get_zone() is not DEFAULT_ZONE, msg
     357            lats_longs = []
     358            for point in self.get_data_points(True):
     359                ### UTMtoLL(northing, easting, zone,
     360                print "point[0]",point[0]
     361                print "point[1]",point[1]
     362                print "zone",zone
     363                results = UTMtoLL(point[0],point[1], zone)
     364                print "results", results
     365                lat_calced, long_calced = UTMtoLL(point[0],point[1], zone)
     366                print "lat_calced", lat_calced
     367                print "long_calced", long_calced
     368                lats_longs.append(UTMtoLL(point[0],point[1], zone))
     369           
     370           
    347371        if absolute is True and geo_reference is None:
    348372            return self.geo_reference.get_absolute(self.data_points)
     
    353377        else:
    354378            return self.data_points
    355        
    356379   
    357380    def get_attributes(self, attribute_name=None):
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r4181 r4199  
    162162        assert allclose(results, points_rel)
    163163
    164        
     164 
     165    def DSG_test_get_data_points_lat_long(self):
     166        # lat long [-30.],[130]
     167        #Zone:   52   
     168        #Easting:  596450.153  Northing: 6680793.777
     169        # lat long [-32.],[131]
     170        #Zone:   52   
     171        #Easting:  688927.638  Northing: 6457816.509
     172       
     173        points_Lat_long = [[-30.,130], [-32,131]]
     174       
     175        spatial = Geospatial_data(latitudes=[-30, -32.],
     176                                  longitudes=[130, 131])
     177
     178        results = spatial.get_data_points()
     179        print "results UTM",results
     180       
     181        results = spatial.get_data_points(as_lat_long=True)
     182        print "results",results
     183        assert allclose(results, points_rel)
     184       
     185        x_p = -1770
     186        y_p = 4.01
     187        geo_ref = Geo_reference(56, x_p, y_p)
     188        points_rel = geo_ref.change_points_geo_ref(points_ab)
     189        results = spatial.get_data_points \
     190                  ( geo_reference=geo_ref)
     191       
     192        assert allclose(results, points_rel)
     193
     194             
    165195    def test_set_geo_reference(self):
    166196        points_ab = [[12.5,34.7],[-4.5,-60.0]]
     
    18761906        points = results.get_data_points()
    18771907       
    1878         assert allclose(points[0][0], 308728.009)
    1879         assert allclose(points[0][1], 6180432.601)
    1880         assert allclose(points[1][0],  222908.705)
    1881         assert allclose(points[1][1], 6233785.284)
     1908
     1909        assert allclose(points[0][0], 6180432.601)
     1910        assert allclose(points[0][1], 308728.009)
     1911        assert allclose(points[1][0], 6233785.284)
     1912        assert allclose(points[1][1], 222908.705)
    18821913       
    18831914     
     
    18971928        points = results.get_data_points()
    18981929       
    1899         assert allclose(points[0][0], 308728.009)
    1900         assert allclose(points[0][1], 6180432.601)
    1901         assert allclose(points[1][0],  222908.705)
    1902         assert allclose(points[1][1], 6233785.284)
    1903 
     1930        assert allclose(points[0][0], 6180432.601)
     1931        assert allclose(points[0][1], 308728.009)
     1932        assert allclose(points[1][0], 6233785.284)
     1933        assert allclose(points[1][1], 222908.705)
     1934       
    19041935         
    19051936    def test_load_csv_lat_long_bad(self):
     
    19251956       
    19261957    def test_lat_long(self):
     1958        #Zone:   56   
     1959        #Easting:  308728.009  Northing: 6180432.601
     1960        #Latitude:   -34  30 ' 0.00000 ''  Longitude: 150  55 ' 0.00000 ''
     1961
    19271962        lat_gong = degminsec2decimal_degrees(-34,30,0.)
    19281963        lon_gong = degminsec2decimal_degrees(150,55,0.)
     
    19371972        points = gsd.get_data_points(absolute=True)
    19381973       
    1939         assert allclose(points[0][0], 308728.009)
    1940         assert allclose(points[0][1], 6180432.601)
    1941         assert allclose(points[1][0],  222908.705)
    1942         assert allclose(points[1][1], 6233785.284)
     1974        assert allclose(points[0][0], 6180432.601)
     1975        assert allclose(points[0][1], 308728.009)
     1976        assert allclose(points[1][0], 6233785.284)
     1977        assert allclose(points[1][1], 222908.705)
    19431978        self.failUnless(gsd.get_geo_reference().get_zone() == 56,
    19441979                        'Bad zone error!')
     
    19902025        points = gsd.get_data_points(absolute=True)
    19912026       
    1992         assert allclose(points[0][0], 308728.009)
    1993         assert allclose(points[0][1], 6180432.601)
    1994         assert allclose(points[1][0],  222908.705)
    1995         assert allclose(points[1][1], 6233785.284)
     2027        assert allclose(points[0][0], 6180432.601)
     2028        assert allclose(points[0][1], 308728.009)
     2029        assert allclose(points[1][0], 6233785.284)
     2030        assert allclose(points[1][1], 222908.705)
     2031       
    19962032        self.failUnless(gsd.get_geo_reference().get_zone() == 56,
    19972033                        'Bad zone error!')
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4176 r4199  
    45324532        points = gsd.get_data_points(absolute=True)
    45334533       
    4534         assert allclose(points[0][0], 308728.009)
    4535         assert allclose(points[0][1], 6180432.601)
    4536         assert allclose(points[1][0],  222908.705)
    4537         assert allclose(points[1][1], 6233785.284)
     4534
     4535        assert allclose(points[0][0], 6180432.601)
     4536        assert allclose(points[0][1], 308728.009)
     4537        assert allclose(points[1][0], 6233785.284)
     4538        assert allclose(points[1][1], 222908.705)
     4539       
    45384540        self.failUnless(gsd.get_geo_reference().get_zone() == 56,
    45394541                        'Bad zone error!')
Note: See TracChangeset for help on using the changeset viewer.