def osr_basic_6(): # Without version wkt_1 = osr.GetUserInputAsWKT('urn:x-ogc:def:crs:EPSG::4326') if wkt_1.find('GEOGCS["WGS 84",DATUM["WGS_1984"') == -1 or wkt_1.find( 'AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') == -1: print(wkt_1) gdaltest.post_reason('EPSG:4326 urn lookup not as expected.') return 'fail' # With a version wkt_1 = osr.GetUserInputAsWKT('urn:x-ogc:def:crs:EPSG:6.6:4326') if wkt_1.find('GEOGCS["WGS 84",DATUM["WGS_1984"') == -1 or wkt_1.find( 'AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') == -1: print(wkt_1) print(wkt_2) gdaltest.post_reason('EPSG:4326 urn lookup not as expected.') return 'fail' # Without version, but with no repeated :. Probably illegal from my understanding # of http://www.opengeospatial.org/ogcUrnPolicy, but found quite often in the wild # especially in content returned by GeoServer wkt_1 = osr.GetUserInputAsWKT('urn:x-ogc:def:crs:EPSG:4326') if wkt_1.find('GEOGCS["WGS 84",DATUM["WGS_1984"') == -1 or wkt_1.find( 'AXIS["Latitude",NORTH],AXIS["Longitude",EAST]') == -1: print(wkt_1) print(wkt_2) gdaltest.post_reason('EPSG:4326 urn lookup not as expected.') return 'fail' return 'success'
def osr_basic_12(): wkt_1 = osr.GetUserInputAsWKT('CRS:84') wkt_2 = osr.GetUserInputAsWKT('WGS84') if wkt_1 != wkt_2: gdaltest.post_reason('CRS:84 lookup not as expected.') return 'fail' return 'success'
def osr_basic_5(): wkt_1 = osr.GetUserInputAsWKT('urn:ogc:def:crs:OGC:1.3:CRS84') wkt_2 = osr.GetUserInputAsWKT('WGS84') if wkt_1 != wkt_2: gdaltest.post_reason('CRS84 lookup not as expected.') return 'fail' return 'success'
def osr_basic_17(): wkt_1 = osr.GetUserInputAsWKT('urn:ogc:def:crs:EPSG::4326') wkt_2 = osr.GetUserInputAsWKT('http://www.opengis.net/def/crs/EPSG/0/4326') if wkt_1 != wkt_2: gdaltest.post_reason('CRS URL parsing not as expected.') return 'fail' return 'success'
def osr_basic_7(): wkt_1 = osr.GetUserInputAsWKT('urn:ogc:def:crs:OGC::AUTO42001:-117:33') wkt_2 = 'PROJCS["UTM Zone 11, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1,AUTHORITY["EPSG","9001"]]]' if wkt_1 != wkt_2: print(wkt_1) print(wkt_2) gdaltest.post_reason('AUTO42001 urn lookup not as expected.') return 'fail' return 'success'
def osr_basic_18(): # This is a dummy one, but who cares wkt = osr.GetUserInputAsWKT( 'http://www.opengis.net/def/crs-compound?1=http://www.opengis.net/def/crs/EPSG/0/4326&2=http://www.opengis.net/def/crs/EPSG/0/4326' ) if wkt.find('COMPD_CS') != 0: print(wkt) gdaltest.post_reason('CRS URL parsing not as expected.') return 'fail' return 'success'
def make_index(index_path, filter_path): driver = ogr.GetDriverByName(b'esri shapefile') data_source = driver.CreateDataSource(index_path) layer_name = os.path.basename(index_path) sr = osr.SpatialReference(osr.GetUserInputAsWKT(b'epsg:4326')) layer = data_source.CreateLayer(layer_name, sr) layer.CreateField(ogr.FieldDefn(b'BLADNR', ogr.OFTString)) layer_defn = layer.GetLayerDefn() if filter_path is None: checker = None else: checker = Checker(filter_path) yrange = xrange(-56, 60) total = len(yrange) ogr.TermProgress_nocb(0) for count, y in enumerate(yrange, 1): for x in range(-180, 180): x1, y1, x2, y2 = x, y, x + 1, y + 1 lat = 'S{:02}'.format(-y) if y < 0 else 'N{:02}'.format(y) lon = 'W{:03}'.format(-x) if x < 0 else 'E{:03}'.format(x) feature = ogr.Feature(layer_defn) feature[b'BLADNR'] = '{}{}'.format(lat, lon) ring = ogr.Geometry(ogr.wkbLinearRing) ring.AddPoint_2D(x1, y1) ring.AddPoint_2D(x2, y1) ring.AddPoint_2D(x2, y2) ring.AddPoint_2D(x1, y2) ring.AddPoint_2D(x1, y1) geometry = ogr.Geometry(ogr.wkbPolygon) geometry.AddGeometry(ring) if checker is not None: if not checker.intersects(geometry): continue geometry.AssignSpatialReference(sr) feature.SetGeometry(geometry) layer.CreateFeature(feature) ogr.TermProgress_nocb(count / total) data_source.ExecuteSQL(b'CREATE SPATIAL INDEX ON {}'.format(layer_name))