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'
def check_EAS_ID_with_or_without_space(layer, s, expected_value): name = "EAS_ID" actual_value = pmstestlib.get_item_value(layer, s, name) if actual_value is None: post_reason("missing expected attribute %s" % name) return False if actual_value == expected_value or actual_value == expected_value.strip(): return True else: post_reason('attribute %s is "%s" instead of expected "%s"' % (name, actual_value, str(expected_value))) return False
def rqtest_17(): layer = pmstestlib.layer pnt = mapscript.pointObj() pnt.x = 889690 pnt.y = 55369 ######################################################################### # Check result count. 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 > 200000.0: pmstestlib.post_reason( 'Got point %f from target, but tolerance was 200000.0.' % dst ) return 'fail' if count != 4: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 10) ) return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def check_EAS_ID_with_or_without_space(layer, s, expected_value): name = 'EAS_ID' actual_value = pmstestlib.get_item_value( layer, s, name ) if actual_value is None: post_reason( 'missing expected attribute %s' % name ) return False if actual_value == expected_value or actual_value == expected_value.strip(): return True else: post_reason( 'attribute %s is "%s" instead of expected "%s"' % \ (name, actual_value, str(expected_value)) ) return False
def rqtest_17(): layer = pmstestlib.layer pnt = mapscript.pointObj() pnt.x = 889690 pnt.y = 55369 ######################################################################### # Check result count. 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 > 200000.0: pmstestlib.post_reason( 'Got point %f from target, but tolerance was 200000.0.' % dst) return 'fail' if count != 4: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 10) ) return 'fail' layer.close() layer.close() # discard resultset. return 'success'