Skip to content
Permalink
Browse files

Enhance msautotest with testing of support fro raster tileindex with …

…mixed srs
  • Loading branch information
rouault committed Jun 30, 2013
1 parent c68b496 commit 8f791427817600ac69a45c7c14da18aa7fe0032b
Binary file not shown.
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
#
# REQUIRES: SUPPORTS=PROJ
#
MAP

# Recipe to produce the tileindex :
# wget http://svn.osgeo.org/gdal/trunk/autotest/gcore/data/utmsmall.tif
# gdal_translate utmsmall.tif utmsmall_topleft_26711.tif -srcwin 0 0 50 50
# gdal_translate utmsmall.tif utmsmall_topright_26711.tif -srcwin 50 0 50 50
# gdal_translate utmsmall.tif utmsmall_bottomleft_26711.tif -srcwin 0 50 50 50
# gdal_translate utmsmall.tif utmsmall_bottomright_26711.tif -srcwin 50 50 50 50
# gdalwarp utmsmall_bottomleft_26711.tif utmsmall_bottomleft_4326.tif -t_srs EPSG:4326
# gdalwarp utmsmall_topright_26711.tif utmsmall_topright_32611.tif -t_srs EPSG:32611
# gdalwarp utmsmall_bottomright_26711.tif utmsmall_bottomright_3857.tif -t_srs EPSG:3857
# gdaltindex -t_srs EPSG:4326 -src_srs_name src_srs tile_index_mixed_srs.shp utmsmall_topleft_26711.tif utmsmall_topright_32611.tif utmsmall_bottomleft_4326.tif utmsmall_bottomright_3857.tif
# Just to test that we can also deduce the SRS from the GDAL file itself
# ogrinfo tile_index_mixed_srs.shp -sql "UPDATE tile_index_mixed_srs SET src_srs = NULL WHERE location = 'utmsmall_topright_32611.tif'" -dialect SQLITE

NAME TEST
STATUS ON
SIZE 100 100
EXTENT 440720.000 3745320.000 446720.000 3751320.000
IMAGECOLOR 0 0 0

PROJECTION
"+proj=utm +zone=11 +datum=NAD27"
END

IMAGETYPE PNG8

LAYER
NAME grey
TYPE raster
STATUS default
DUMP TRUE
TEMPLATE "fake.html"
TILEINDEX "data/tile_index_mixed_srs.shp"
TILEITEM "location"
TILESRS "src_srs"
PROJECTION
"+proj=latlong +datum=WGS84"
END
END

END # of map file
@@ -0,0 +1,33 @@
#
# REQUIRES: SUPPORTS=PROJ
#
# Same as tileindexmixedsrs.map but with PROJECTION AUTO
MAP

NAME TEST
STATUS ON
SIZE 100 100
EXTENT 440720.000 3745320.000 446720.000 3751320.000
IMAGECOLOR 0 0 0

PROJECTION
"+proj=utm +zone=11 +datum=NAD27"
END

IMAGETYPE PNG8

LAYER
NAME grey
TYPE raster
STATUS default
DUMP TRUE
TEMPLATE "fake.html"
TILEINDEX "data/tile_index_mixed_srs.shp"
TILEITEM "location"
TILESRS "src_srs"
PROJECTION
AUTO
END
END

END # of map file
@@ -0,0 +1,44 @@
#
# REQUIRES: SUPPORTS=PROJ
#
# Same as tileindexmixedsrs.map but with tileindex as a layer
MAP

NAME TEST
STATUS ON
SIZE 100 100
EXTENT 440720.000 3745320.000 446720.000 3751320.000
IMAGECOLOR 0 0 0

PROJECTION
"+proj=utm +zone=11 +datum=NAD27"
END

IMAGETYPE PNG8

LAYER
NAME mytileindex
TYPE POLYGON
STATUS OFF
DUMP OFF
DATA "data/tile_index_mixed_srs_with_data_dir.shp"
PROJECTION
AUTO
END
END

LAYER
NAME grey
TYPE raster
STATUS default
DUMP TRUE
TEMPLATE "fake.html"
TILEINDEX "mytileindex"
TILEITEM "location"
TILESRS "src_srs"
PROJECTION
AUTO
END
END

END # of map file
@@ -0,0 +1,45 @@
#
# REQUIRES: SUPPORTS=PROJ
#
# Same as tileindexmixedsrs.map but with tileindex as a OGR layer
MAP

NAME TEST
STATUS ON
SIZE 100 100
EXTENT 440720.000 3745320.000 446720.000 3751320.000
IMAGECOLOR 0 0 0

PROJECTION
"+proj=utm +zone=11 +datum=NAD27"
END

IMAGETYPE PNG8

LAYER
NAME mytileindex
TYPE POLYGON
STATUS OFF
DUMP OFF
CONNECTION "data/tile_index_mixed_srs_with_data_dir.shp"
CONNECTIONTYPE OGR
PROJECTION
AUTO
END
END

LAYER
NAME grey
TYPE raster
STATUS default
DUMP TRUE
TEMPLATE "fake.html"
TILEINDEX "mytileindex"
TILEITEM "location"
TILESRS "src_srs"
PROJECTION
AUTO
END
END

END # of map file
@@ -627,7 +627,7 @@ def rqtest_15():
dist = math.pow(dist_sq,0.5)
if dist > 200000.0:
pmstestlib.post_reason(
'Got point %f from target, but tolerance was 200000.0.' % dst )
'Got point %f from target, but tolerance was 200000.0.' % dist )
return 'fail'


@@ -691,20 +691,69 @@ def rqtest_17():
dist = math.pow(dist_sq,0.5)
if dist > 200000.0:
pmstestlib.post_reason(
'Got point %f from target, but tolerance was 200000.0.' % dst )
'Got point %f from target, but tolerance was 200000.0.' % dist )
return 'fail'


if count != 4:
pmstestlib.post_reason( 'got %d results instead of expected %d.' \
% (count, 10) )
% (count, 4) )
return 'fail'

layer.close()
layer.close() # discard resultset.

return 'success'

###############################################################################
# Test a layer with a tileindex with mixed SRS

def rqtest_18():

pmstestlib.map = mapscript.mapObj('../gdal/tileindexmixedsrs.map')
pmstestlib.layer = pmstestlib.map.getLayer(0)

pmstestlib.map.setProjection("+proj=latlong +datum=WGS84")

pnt = mapscript.pointObj()
pnt.x = -117.6
pnt.y = 33.9

pmstestlib.layer.queryByPoint( pmstestlib.map, pnt, mapscript.MS_SINGLE,
0.001 )

#########################################################################
# Check result count.
layer = pmstestlib.layer
layer.open()
count = 0
for i in range(1000):
result = layer.getResult( i )
if result is None:
break

count = count + 1

s = layer.getShape( result )
x = float(pmstestlib.get_item_value( layer, s, 'x' ))
y = float(pmstestlib.get_item_value( layer, s, 'y' ))
dist_sq = (x-pnt.x) * (x-pnt.x) + (y-pnt.y) * (y-pnt.y)
dist = math.pow(dist_sq,0.5)
if dist > 0.001:
pmstestlib.post_reason(
'Got point %f from target, but tolerance was 0.001.' % dist )
return 'fail'

if count != 1:
pmstestlib.post_reason( 'got %d results instead of expected %d.' \
% (count, 1) )
return 'fail'

layer.close()
layer.close() # discard resultset.

return 'success'

###############################################################################
# Cleanup.

@@ -733,6 +782,7 @@ def rqtest_cleanup():
rqtest_15,
rqtest_16,
rqtest_17,
rqtest_18,
rqtest_cleanup ]

if __name__ == '__main__':

0 comments on commit 8f79142

Please sign in to comment.
You can’t perform that action at this time.