Exemple #1
0
    def test_URS_points_needed(self):

        ll_lat = -21.5
        ll_long = 114.5
        grid_spacing = 1. / 60.
        lat_amount = 30
        long_amount = 30
        zone = 50

        boundary_polygon = [[250000, 7660000], [280000, 7660000],
                            [280000, 7630000], [250000, 7630000]]
        geo = calculate_boundary_points(boundary_polygon,
                                        zone,
                                        ll_lat,
                                        ll_long,
                                        grid_spacing,
                                        lat_amount,
                                        long_amount,
                                        verbose=self.verbose)
        # to test this geo, can info from it be transfered onto the boundary
        # poly?
        #Maybe see if I can fit the data to the polygon - have to represent
        # the poly as points though.
        #geo.export_points_file("results.txt", as_lat_long=True)
        results = frozenset(geo.get_data_points(as_lat_long=True))
        #print 'results',results

        # These are a set of points that have to be in results
        points = []
        for i in range(18):
            lat = -21.0 - 8. / 60 - grid_spacing * i
            points.append((lat, degminsec2decimal_degrees(114, 35, 0)))
            points.append((lat, degminsec2decimal_degrees(114, 36, 0)))
            points.append((lat, degminsec2decimal_degrees(114, 52, 0)))
            points.append((lat, degminsec2decimal_degrees(114, 53, 0)))
        geo_answer = Geospatial_data(data_points=points,
                                     points_are_lats_longs=True)
        #geo_answer.export_points_file("answer.txt", as_lat_long=True)
        answer = frozenset(points)

        outs = answer.difference(results)
        #print "outs", outs
        # This doesn't work.  Though visualising the results shows that
        # it is correct.
        #assert answer.issubset(results)
        # this is why;
        #point (-21.133333333333333, 114.58333333333333)
        #result (-21.133333332232368, 114.58333333300342)

        for point in points:
            found = False
            for result in results:
                if num.allclose(point, result):
                    found = True
                    break
            if not found:
                assert False
    def test_URS_points_needed(self):
        
        ll_lat = -21.5
        ll_long = 114.5
        grid_spacing = 1./60.
        lat_amount = 30
        long_amount = 30
        zone = 50

        boundary_polygon = [[250000,7660000],[280000,7660000],
                             [280000,7630000],[250000,7630000]]
        geo=calculate_boundary_points(boundary_polygon, zone, 
                              ll_lat, ll_long, grid_spacing, 
                              lat_amount, long_amount,
                              verbose=self.verbose)
        # to test this geo, can info from it be transfered onto the boundary
        # poly?
        #Maybe see if I can fit the data to the polygon - have to represent
        # the poly as points though.
        #geo.export_points_file("results.txt", as_lat_long=True)
        results = frozenset(geo.get_data_points(as_lat_long=True))
        #print 'results',results

        # These are a set of points that have to be in results
        points = []
        for i in range(18):
            lat = -21.0 - 8./60 - grid_spacing * i
            points.append((lat,degminsec2decimal_degrees(114,35,0))) 
            points.append((lat,degminsec2decimal_degrees(114,36,0))) 
            points.append((lat,degminsec2decimal_degrees(114,52,0))) 
            points.append((lat,degminsec2decimal_degrees(114,53,0)))
        geo_answer = Geospatial_data(data_points=points,
                                     points_are_lats_longs=True) 
        #geo_answer.export_points_file("answer.txt", as_lat_long=True)  
        answer = frozenset(points)
        
        outs = answer.difference(results)
        #print "outs", outs
        # This doesn't work.  Though visualising the results shows that
        # it is correct.
        #assert answer.issubset(results)
        # this is why;
        #point (-21.133333333333333, 114.58333333333333)
        #result (-21.133333332232368, 114.58333333300342)
        
        for point in points:
            found = False
            for result in results:
                if num.allclose(point, result):
                    found = True
                    break
            if not found:
                assert False
Exemple #3
0
    def test_UTM_3(self):
        #Test 3
        lat = degminsec2decimal_degrees(-60,0,0)
        lon = degminsec2decimal_degrees(130,0,0) 

        zone, easting, northing = LLtoUTM(lat,lon)

        assert zone == 52
        assert num.allclose(easting, 555776.267)
        assert num.allclose(northing, 3348167.264)

        Lat, Long = UTMtoLL(northing, easting, zone)
Exemple #4
0
    def test_UTM_5(self):
        #Test 5 (Wollongong)

        lat = degminsec2decimal_degrees(-34,30,0.)
        lon = degminsec2decimal_degrees(150,55,0.) 
        
        zone, easting, northing = LLtoUTM(lat,lon)


        assert zone == 56
        assert num.allclose(easting, 308728.009)
        assert num.allclose(northing, 6180432.601)

        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
        assert num.allclose(lat,  lat_calced)
        assert num.allclose(lon, long_calced)
Exemple #5
0
    def test_UTM_2(self):
        #TEST 2

        #Latitude:  -37 57 03.7203
        #Longitude: 144 25 29.5244
        #Zone:   55    
        #Easting:  273741.297  Northing: 5796489.777 
        #Latitude:   -37  57 ' 3.72030 ''  Longitude: 144  25 ' 29.52440 '' 
        #Grid Convergence:  -1  35 ' 3.65 ''  Point Scale: 1.00023056 

        lat = degminsec2decimal_degrees(-37,57,03.7203)
        lon = degminsec2decimal_degrees(144,25,29.5244) 

        zone, easting, northing = LLtoUTM(lat,lon)

        
        assert zone == 55
        assert num.allclose(easting, 273741.297)
        assert num.allclose(northing, 5796489.777)

        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
        assert num.allclose(lat,  lat_calced)
        assert num.allclose(lon, long_calced)
Exemple #6
0
    def test_UTM_1(self):
        #latitude:  -37 39' 10.15610" 
        #Longitude: 143 55' 35.38390" 
        #Site Name:    GDA-MGA: (UTM with GRS80 ellipsoid) 
        #Zone:   54    
        #Easting:  758173.797  Northing: 5828674.340 
        #Latitude:   -37  39 ' 10.15610 ''  Longitude: 143  55 ' 35.38390 '' 
        #Grid Convergence:  1  47 ' 19.36 ''  Point Scale: 1.00042107 

        lat = degminsec2decimal_degrees(-37,39,10.15610)
        lon = degminsec2decimal_degrees(143,55,35.38390) 
        assert num.allclose(lat, -37.65282114)
        assert num.allclose(lon, 143.9264955)


        zone, easting, northing = LLtoUTM(lat,lon)

        assert zone == 54
        assert num.allclose(easting, 758173.797)
        assert num.allclose(northing, 5828674.340)

        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
        assert num.allclose(lat,  lat_calced)
        assert num.allclose(lon, long_calced)
    def test_URS_points_northern_hemisphere(self):

        LL_LAT = 8.0
        LL_LONG = 97.0
        GRID_SPACING = 2.0/60.0
        LAT_AMOUNT = 2
        LONG_AMOUNT = 2
        ZONE = 47

        # 
        points = []
        for i in range(2):
            for j in range(2):
                points.append((degminsec2decimal_degrees(8,1+i*2,0),
                               degminsec2decimal_degrees(97,1+i*2,0)))
        #print "points", points
        geo_poly = Geospatial_data(data_points=points,
                                     points_are_lats_longs=True)
        poly_lat_long = geo_poly.get_data_points(as_lat_long=False,
                                       isSouthHemisphere=False)
        #print "seg_lat_long",  poly_lat_long
        
      #   geo=URS_points_needed_to_file('test_example_poly3', poly_lat_long,
#                                   ZONE,
#                                   LL_LAT, LL_LONG,
#                                   GRID_SPACING,
#                                   LAT_AMOUNT, LONG_AMOUNT,
#                                   isSouthernHemisphere=False,
#                                   export_csv=True,
#                                   verbose=self.verbose)

        geo=calculate_boundary_points(poly_lat_long,
                                  ZONE,
                                  LL_LAT, LL_LONG,
                                  GRID_SPACING,
                                  LAT_AMOUNT, LONG_AMOUNT,
                                  isSouthHemisphere=False,
                                  verbose=self.verbose)

        results = frozenset(geo.get_data_points(as_lat_long=True,
                                                isSouthHemisphere=False))

        #print 'results',results

        # These are a set of points that have to be in results
        points = [] 
        for i in range(2):
            for j in range(2):
                points.append((degminsec2decimal_degrees(8,i*2,0),
                               degminsec2decimal_degrees(97,i*2,0)))
        #print "answer points", points
        answer = frozenset(points)
        
        for point in points:
            found = False
            for result in results:
                if num.allclose(point, result):
                    found = True
                    break
            if not found:
                assert False
Exemple #8
0
    def test_URS_points_northern_hemisphere(self):

        LL_LAT = 8.0
        LL_LONG = 97.0
        GRID_SPACING = 2.0 / 60.0
        LAT_AMOUNT = 2
        LONG_AMOUNT = 2
        ZONE = 47

        #
        points = []
        for i in range(2):
            for j in range(2):
                points.append((degminsec2decimal_degrees(8, 1 + i * 2, 0),
                               degminsec2decimal_degrees(97, 1 + i * 2, 0)))
        #print "points", points
        geo_poly = Geospatial_data(data_points=points,
                                   points_are_lats_longs=True)
        poly_lat_long = geo_poly.get_data_points(as_lat_long=False,
                                                 isSouthHemisphere=False)
        #print "seg_lat_long",  poly_lat_long

        #   geo=URS_points_needed_to_file('test_example_poly3', poly_lat_long,
        #                                   ZONE,
        #                                   LL_LAT, LL_LONG,
        #                                   GRID_SPACING,
        #                                   LAT_AMOUNT, LONG_AMOUNT,
        #                                   isSouthernHemisphere=False,
        #                                   export_csv=True,
        #                                   verbose=self.verbose)

        geo = calculate_boundary_points(poly_lat_long,
                                        ZONE,
                                        LL_LAT,
                                        LL_LONG,
                                        GRID_SPACING,
                                        LAT_AMOUNT,
                                        LONG_AMOUNT,
                                        isSouthHemisphere=False,
                                        verbose=self.verbose)

        results = frozenset(
            geo.get_data_points(as_lat_long=True, isSouthHemisphere=False))

        #print 'results',results

        # These are a set of points that have to be in results
        points = []
        for i in range(2):
            for j in range(2):
                points.append((degminsec2decimal_degrees(8, i * 2, 0),
                               degminsec2decimal_degrees(97, i * 2, 0)))
        #print "answer points", points
        answer = frozenset(points)

        for point in points:
            found = False
            for result in results:
                if num.allclose(point, result):
                    found = True
                    break
            if not found:
                assert False