def ogr_query_7(): map = pmstestlib.map map.draw() layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break count = count + 1 if count != 2: pmstestlib.post_reason("got %d results instead of expected %d." % (count, 55)) return "fail" ######################################################################### # Check first shape attributes. result = layer.getResult(0) s = layer.getShape(result) if not check_EAS_ID_with_or_without_space(layer, s, " 168"): return "fail" layer.close() layer.close() # discard resultset. return "success"
def rqtest_7(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break count = count + 1 if count != 1: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 1) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult(0) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('value_0', '115'), ('x', '35.5'), ('y', '25.5')]) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def rqtest_7(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult( i ) if result is None: break count = count + 1 if count != 1: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 1) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult( 0 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('value_0','115'), ('x','35.5'), ('y','25.5')] ) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def rqtest_13(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break count = count + 1 if count != 1: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 1) ) return 'fail' result = layer.getResult(0) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('value_0', '1'), ('red', '255'), ('green', '0'), ('blue', '0'), ('class', 'Grid'), ('x', '13.5'), ('y', '36.5')]) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
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 wkt_test_2(): if ('SUPPORTS=GEOS' in mapscript.msGetVersion() or 'INPUT=OGR' not in mapscript.msGetVersion()): return 'skip' orig_wkt = 'MULTIPOLYGON(((50 50, 350 50, 350 250, 50 250, 50 50)),((250 150, 550 150, 550 350, 250 350, 250 150)))' expected_wkt = 'POLYGON ((50 50, 350 50, 350 250, 50 250, 50 50), (250 150, 550 150, 550 350, 250 350, 250 150))' shp = mapscript.shapeObj.fromWKT(orig_wkt) new_wkt = shp.toWKT().replace('.0000000000000000', '') if new_wkt != expected_wkt: pmstestlib.post_reason( 'WKT "%s" converted to "%s".' \ % (expected_wkt, new_wkt) ) return 'fail' return 'success'
def wkt_test_2(): if string.find(mapscript.msGetVersion(),'SUPPORTS=GEOS') != -1 \ or string.find(mapscript.msGetVersion(),'INPUT=OGR') == -1: return 'skip' orig_wkt = 'MULTIPOLYGON(((50 50, 350 50, 350 250, 50 250, 50 50)),((250 150, 550 150, 550 350, 250 350, 250 150)))' expected_wkt = 'POLYGON ((50 50,350 50,350 250,50 250,50 50),(250 150,550 150,550 350,250 350,250 150))' shp = mapscript.shapeObj.fromWKT(orig_wkt) new_wkt = shp.toWKT() if new_wkt != expected_wkt: pmstestlib.post_reason( 'WKT "%s" converted to "%s".' \ % (expected_wkt, new_wkt) ) return 'fail' return 'success'
def wkt_test_2(): if string.find(mapscript.msGetVersion(),'SUPPORTS=GEOS') != -1 \ or string.find(mapscript.msGetVersion(),'INPUT=OGR') == -1: return 'skip' orig_wkt = 'MULTIPOLYGON(((50 50, 350 50, 350 250, 50 250, 50 50)),((250 150, 550 150, 550 350, 250 350, 250 150)))' expected_wkt = 'POLYGON ((50 50,350 50,350 250,50 250,50 50),(250 150,550 150,550 350,250 350,250 150))' shp = mapscript.shapeObj.fromWKT( orig_wkt ) new_wkt = shp.toWKT() if new_wkt != expected_wkt: pmstestlib.post_reason( 'WKT "%s" converted to "%s".' \ % (expected_wkt, new_wkt) ) return 'fail' return 'success'
def wkt_test_3(): if string.find(mapscript.msGetVersion(),'SUPPORTS=GEOS') == -1: return 'skip' wkt_list = [ 'POINT (5.0000000000000000 7.0000000000000000)', 'LINESTRING (5.0000000000000000 7.0000000000000000, 7.0000000000000000 9.0000000000000000, 9.0000000000000000 -1.0000000000000000)', 'POLYGON ((500.0000000000000000 500.0000000000000000, 3500.0000000000000000 500.0000000000000000, 3500.0000000000000000 2500.0000000000000000, 500.0000000000000000 2500.0000000000000000, 500.0000000000000000 500.0000000000000000), (1000.0000000000000000 1000.0000000000000000, 1000.0000000000000000 1500.0000000000000000, 1500.0000000000000000 1500.0000000000000000, 1500.0000000000000000 1000.0000000000000000, 1000.0000000000000000 1000.0000000000000000))', 'MULTIPOINT (2000.0000000000000000 2000.0000000000000000, 2000.0000000000000000 1900.0000000000000000)', 'MULTILINESTRING ((600.0000000000000000 1500.0000000000000000, 1600.0000000000000000 2500.0000000000000000), (700.0000000000000000 1500.0000000000000000, 1700.0000000000000000 2500.0000000000000000))'] for orig_wkt in wkt_list: shp = mapscript.shapeObj.fromWKT( orig_wkt ) new_wkt = shp.toWKT() if new_wkt != orig_wkt: pmstestlib.post_reason( 'WKT "%s" converted to "%s".' \ % (orig_wkt, new_wkt) ) return 'fail' return 'success'
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 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 ogr_query_7(): map = pmstestlib.map map.draw() layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult( i ) if result is None: break count = count + 1 if count != 2: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 55) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult( 0 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('EAS_ID',' 168')] ) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def test_msIO_getAndStripStdoutBufferMimeHeaders(): if 'INPUT=GDAL' not in mapscript.msGetVersion(): return 'skip' if 'SUPPORTS=WMS' not in mapscript.msGetVersion(): return 'skip' map = mapscript.mapObj('test_mapio.map') request = mapscript.OWSRequest() mapscript.msIO_installStdoutToBuffer() request.loadParamsFromURL( 'service=WMS&version=1.1.1&request=GetMap&layers=grey&srs=EPSG:4326&bbox=-180,-90,180,90&format=image/png&width=80&height=40' ) status = map.OWSDispatch(request) if status != 0: pmstestlib.post_reason('wrong OWSDispatch status') return 'fail' headers = mapscript.msIO_getAndStripStdoutBufferMimeHeaders() if headers is None: pmstestlib.post_reason('headers is None') return 'fail' if 'Content-Type' not in headers or headers['Content-Type'] != 'image/png': pmstestlib.post_reason('wrong Content-Type') print(headers) return 'fail' if 'Cache-Control' not in headers or headers[ 'Cache-Control'] != 'max-age=86400': pmstestlib.post_reason('wrong Cache-Control') print(headers) return 'fail' result = mapscript.msIO_getStdoutBufferBytes() if result is None or result[1:4] != b'PNG': pmstestlib.post_reason('wrong data') return 'fail' return 'success'
def wkt_test_1(): if ('SUPPORTS=GEOS' in mapscript.msGetVersion() or 'INPUT=OGR' not in mapscript.msGetVersion()): return 'skip' wkt_list = [ 'POINT (5 7)', 'LINESTRING (5 7, 7 9, 9 -1)', 'POLYGON ((500 500, 3500 500, 3500 2500, 500 2500, 500 500), ' '(1000 1000, 1000 1500, 1500 1500, 1500 1000, 1000 1000))', 'MULTIPOINT (2000 2000, 2000 1900)', 'MULTILINESTRING ((600 1500, 1600 2500), (700 1500, 1700 2500))' ] for orig_wkt in wkt_list: shp = mapscript.shapeObj.fromWKT(orig_wkt) new_wkt = shp.toWKT().replace('.0000000000000000', '') if new_wkt != orig_wkt: pmstestlib.post_reason( 'WKT "%s" converted to "%s".' \ % (orig_wkt, new_wkt) ) return 'fail' return 'success'
def rqtest_13(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult( i ) if result is None: break count = count + 1 if count != 1: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 1) ) return 'fail' result = layer.getResult( 0 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('value_0','1'), ('red','255'), ('green','0'), ('blue','0'), ('class','Grid'), ('x','13.5'), ('y','36.5')] ) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def test_pattern(): si = mapscript.styleObj() if len(si.pattern) != 0: pmstestlib.post_reason('fail 1') return 'fail' if si.patternlength != 0: pmstestlib.post_reason('fail 2') return 'fail' si.pattern = [2.0, 3, 4] if si.pattern != (2.0, 3.0, 4.0): pmstestlib.post_reason('fail 3') return 'fail' if si.patternlength != 3: pmstestlib.post_reason('fail 4') return 'fail' try: si.pattern = [1.0] pmstestlib.post_reason('fail 5') return 'fail' except mapscript.MapServerError, e: pass
def test_pattern(): si = mapscript.styleObj() if len(si.pattern) != 0: pmstestlib.post_reason('fail 1') return 'fail' if si.patternlength != 0: pmstestlib.post_reason('fail 2') return 'fail' si.pattern = [2.0,3,4] if si.pattern != (2.0, 3.0, 4.0): pmstestlib.post_reason('fail 3') return 'fail' if si.patternlength != 3: pmstestlib.post_reason('fail 4') return 'fail' try: si.pattern = [1.0] pmstestlib.post_reason('fail 5') return 'fail' except mapscript.MapServerError, e: pass
def ogr_query_7(): map = pmstestlib.map map.draw() layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break count = count + 1 if count != 2: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 55) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult(0) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('EAS_ID', ' 168')]) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def rqtest_3(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult( i ) if result is None: break count = count + 1 if count != 55: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 55) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult( 0 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('value_0','115'), ('red','115'), ('green','115'), ('blue','115'), ('value_list','115'), ('x','39.5'), ('y','29.5')] ) == 0: return 'fail' ######################################################################### # Check first shape geometry. if s.type != mapscript.MS_SHAPE_POINT: pmstestlib.post_reason( 'raster query result is not a point.' ) return 'fail' if s.numlines != 1: pmstestlib.post_reason( 'raster query has other than 1 lines.' ) return 'fail' try: l = s.getLine( 0 ) except: l = s.get( 0 ) if l.numpoints != 1: pmstestlib.post_reason( 'raster query has other than 1 points.' ) return 'fail' try: p = l.getPoint(0) except: p = l.get(0) if p.x != 39.5 or p.y != 29.5: pmstestlib.post_reason( 'got wrong point location.' ) return 'fail' ######################################################################### # Check last shape attributes. result = layer.getResult( 54 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('value_0','132'), ('x','44.5'), ('y','25.5')] ) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def ogr_query_5(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break count = count + 1 if count != 2: pmstestlib.post_reason("got %d results instead of expected %d." % (count, 55)) return "fail" ######################################################################### # Check first shape attributes. result = layer.getResult(0) s = layer.getShape(result) if not check_EAS_ID_with_or_without_space(layer, s, " 158"): return "fail" ######################################################################### # Check first shape geometry. if s.type != mapscript.MS_SHAPE_POLYGON: pmstestlib.post_reason("query result is not a polygon.") return "fail" if s.numlines != 1: pmstestlib.post_reason("query has other than 1 lines.") return "fail" try: l = s.getLine(0) except: l = s.get(0) if l.numpoints != 61: pmstestlib.post_reason("query has %d points, instead of expected number." % l.numpoints) return "fail" try: p = l.getPoint(0) except: p = l.get(5) if abs(p.x - 480984.25) > 0.01 or abs(p.y - 4764875.0) > 0.01: print p.x, p.y pmstestlib.post_reason("got wrong location.") return "fail" ######################################################################### # Check last shape attributes. result = layer.getResult(1) s = layer.getShape(result) if not check_EAS_ID_with_or_without_space(layer, s, " 165"): return "fail" layer.close() layer.close() # discard resultset. return "success"
def test_pattern(): si = mapscript.styleObj() if len(si.pattern) != 0: pmstestlib.post_reason('fail 1') return 'fail' if si.patternlength != 0: pmstestlib.post_reason('fail 2') return 'fail' si.pattern = [2.0, 3, 4] if si.pattern != (2.0, 3.0, 4.0): pmstestlib.post_reason('fail 3') return 'fail' if si.patternlength != 3: pmstestlib.post_reason('fail 4') return 'fail' try: si.pattern = [1.0] pmstestlib.post_reason('fail 5') return 'fail' except mapscript.MapServerError: pass try: si.pattern = [i for i in range(11)] pmstestlib.post_reason('fail 6') return 'fail' except mapscript.MapServerError: pass try: si.patternlength = 0 pmstestlib.post_reason('fail 7') return 'fail' except mapscript.MapServerError: pass return 'success'
pmstestlib.post_reason('fail 3') return 'fail' if si.patternlength != 3: pmstestlib.post_reason('fail 4') return 'fail' try: si.pattern = [1.0] pmstestlib.post_reason('fail 5') return 'fail' except mapscript.MapServerError, e: pass try: si.pattern = [i for i in range(11)] pmstestlib.post_reason('fail 6') return 'fail' except mapscript.MapServerError, e: pass try: si.patternlength = 0 pmstestlib.post_reason('fail 7') return 'fail' except mapscript.MapServerError, e: pass return 'success' test_list = [bug_673, test_pattern, None]
pmstestlib.post_reason('fail 3') return 'fail' if si.patternlength != 3: pmstestlib.post_reason('fail 4') return 'fail' try: si.pattern = [1.0] pmstestlib.post_reason('fail 5') return 'fail' except mapscript.MapServerError, e: pass try: si.pattern = [i for i in range(11)] pmstestlib.post_reason('fail 6') return 'fail' except mapscript.MapServerError, e: pass try: si.patternlength = 0 pmstestlib.post_reason('fail 7') return 'fail' except mapscript.MapServerError, e: pass return 'success' test_list = [ bug_673,
def ogr_query_3(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult( i ) if result is None: break s = layer.getShape( result ) count = count + 1 if count != 2: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 55) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult( 0 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('EAS_ID',' 158')] ) == 0: return 'fail' ######################################################################### # Check first shape geometry. if s.type != mapscript.MS_SHAPE_POLYGON: pmstestlib.post_reason( 'query result is not a polygon.' ) return 'fail' if s.numlines != 1: pmstestlib.post_reason( 'query has other than 1 lines.' ) return 'fail' try: l = s.getLine( 0 ) except: l = s.get( 0 ) if l.numpoints != 61: pmstestlib.post_reason( 'query has %d points, instead of expected number.' % l.numpoints ) return 'fail' try: p = l.getPoint(0) except: p = l.get(5) if abs(p.x-480984.25) > 0.01 or abs(p.y-4764875.0) > 0.01: print p.x, p.y pmstestlib.post_reason( 'got wrong location.' ) return 'fail' ######################################################################### # Check last shape attributes. result = layer.getResult( 1 ) s = layer.getShape( result ) if pmstestlib.check_items( layer, s, [('EAS_ID',' 165')] ) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def ogr_query_3(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break s = layer.getShape(result) count = count + 1 if count != 2: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 55) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult(0) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('EAS_ID', ' 158')]) == 0: return 'fail' ######################################################################### # Check first shape geometry. if s.type != mapscript.MS_SHAPE_POLYGON: pmstestlib.post_reason('query result is not a polygon.') return 'fail' if s.numlines != 1: pmstestlib.post_reason('query has other than 1 lines.') return 'fail' try: l = s.getLine(0) except: l = s.get(0) if l.numpoints != 61: pmstestlib.post_reason( 'query has %d points, instead of expected number.' % l.numpoints) return 'fail' try: p = l.getPoint(0) except: p = l.get(5) if abs(p.x - 480984.25) > 0.01 or abs(p.y - 4764875.0) > 0.01: print p.x, p.y pmstestlib.post_reason('got wrong location.') return 'fail' ######################################################################### # Check last shape attributes. result = layer.getResult(1) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('EAS_ID', ' 165')]) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'
def rqtest_3(): layer = pmstestlib.layer ######################################################################### # Check result count. layer.open() count = 0 for i in range(1000): result = layer.getResult(i) if result is None: break count = count + 1 if count != 55: pmstestlib.post_reason( 'got %d results instead of expected %d.' \ % (count, 55) ) return 'fail' ######################################################################### # Check first shape attributes. result = layer.getResult(0) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('value_0', '115'), ('red', '115'), ('green', '115'), ('blue', '115'), ('value_list', '115'), ('x', '39.5'), ('y', '29.5')]) == 0: return 'fail' ######################################################################### # Check first shape geometry. if s.type != mapscript.MS_SHAPE_POINT: pmstestlib.post_reason('raster query result is not a point.') return 'fail' if s.numlines != 1: pmstestlib.post_reason('raster query has other than 1 lines.') return 'fail' try: l = s.getLine(0) except: l = s.get(0) if l.numpoints != 1: pmstestlib.post_reason('raster query has other than 1 points.') return 'fail' try: p = l.getPoint(0) except: p = l.get(0) if p.x != 39.5 or p.y != 29.5: pmstestlib.post_reason('got wrong point location.') return 'fail' ######################################################################### # Check last shape attributes. result = layer.getResult(54) s = layer.getShape(result) if pmstestlib.check_items(layer, s, [('value_0', '132'), ('x', '44.5'), ('y', '25.5')]) == 0: return 'fail' layer.close() layer.close() # discard resultset. return 'success'