Sp2IMG

作者

杰夫麦克纳

联系

jmckenna在gatewaygeomatics.com

最后更新

2021-05-06

目的

从 Mapfile 创建地图图像。默认情况下,输出为PNG,但您可以指定映射文件中定义的其他输出格式。这是一个非常有用的实用程序来测试您的 Mapfile (并且应该始终是您的第一个测试,在通过Web浏览器或OGC客户端进行任何测试之前)。您只需提供映射文件的路径和输出图像的名称,就应该返回一个图像。如果无法创建图像,将在命令行显示一个错误,该错误应该引用映射文件中的行号。

句法

shp2img -m mapfile [-o image] [-e minx miny maxx maxy] [-s sizex sizey]
           [-l "layer1 [layers2...]"] [-i format]
           [-all_debug n] [-map_debug n] [-layer_debug n] [-p n] [-c n] [-d layername datavalue]
-m mapfile: Map file to operate on - required
-i format: Override the IMAGETYPE value to pick output format
-o image: output filename (stdout if not provided)
-e minx miny maxx maxy: extents to render
-s sizex sizey: output image size
-l layers: layers / groups to enable - make sure they are quoted and space separated if more than one listed
-all_debug n: Set debug level for map and all layers
-map_debug n: Set map debug level
-layer_debug layer_name n: Set layer debug level
-c n: draw map n number of times
-p n: pause for n seconds after reading the map
-d layername datavalue: change DATA value for layer

示例1生成地图图像

shp2img -m local.map -o test.png
结果

将创建一个名为“test.png”的文件,您可以将其拖到浏览器中查看。

小技巧

这些示例使用分布式工作映射文件,每个 MS4W 实例包含在 /ms4w/apps/local-demo/local.map

示例2使用绘制速度生成地图图像

shp2img -m local.map -o test2.png -map_debug 3
结果

创建名为“test2.png”的文件,并返回层绘制速度,例如:

msDrawMap(): rendering using outputformat named png (AGG/PNG).
msDrawMap(): WMS/WFS set-up and query, 0.000s
msDrawMap(): Layer 0 (ocean), 0.081s
msDrawMap(): Layer 1 (countries), 0.026s
msDrawMap(): Layer 2 (lakes), 0.009s
msDrawMap(): Layer 3 (ocean-labels), 0.010s
msDrawMap(): Drawing Label Cache, 0.039s
msDrawMap() total time: 0.167s
msSaveImage(test2.png) total time: 0.019s

示例3生成包含所有层调试信息的地图图像

shp2img -m local.map -o test3.png -all_debug 3
结果

创建名为“test3.png”的文件,返回层绘制速度,并且未找到索引QIX文件的一些警告,例如:

msLoadMap(): 0.006s
msDrawMap(): rendering using outputformat named png (AGG/PNG).
msDrawMap(): WMS/WFS set-up and query, 0.000s
msOGRFileOpen(demo.sqlite)...
OGROPen(D:\ms4w\apps\local-demo/.\./data/demo.sqlite)
msConnPoolRegister(ocean,demo.sqlite,015672C8)
msOGRLayerClose(demo.sqlite).
msOGRFileClose(D:\ms4w\apps\local-demo/.\./data/demo.sqlite,3).
msConnPoolRelease(ocean,demo.sqlite,015672C8)
msConnPoolClose(demo.sqlite,015672C8)
msDrawMap(): Layer 0 (ocean), 0.030s
msOGRFileOpen(demo.sqlite)...
OGROPen(D:\ms4w\apps\local-demo/.\./data/demo.sqlite)
msConnPoolRegister(countries,demo.sqlite,03561F40)
msOGRLayerClose(demo.sqlite).
msOGRFileClose(D:\ms4w\apps\local-demo/.\./data/demo.sqlite,0).
msConnPoolRelease(countries,demo.sqlite,03561F40)
msConnPoolClose(demo.sqlite,03561F40)
msDrawMap(): Layer 1 (countries), 0.020s
msOGRFileOpen(demo.sqlite)...
OGROPen(D:\ms4w\apps\local-demo/.\./data/demo.sqlite)
msConnPoolRegister(lakes,demo.sqlite,03517620)
msOGRLayerClose(demo.sqlite).
msOGRFileClose(D:\ms4w\apps\local-demo/.\./data/demo.sqlite,2).
msConnPoolRelease(lakes,demo.sqlite,03517620)
msConnPoolClose(demo.sqlite,03517620)
msDrawMap(): Layer 2 (lakes), 0.009s
msOGRFileOpen(demo.sqlite)...
OGROPen(D:\ms4w\apps\local-demo/.\./data/demo.sqlite)
msConnPoolRegister(ocean-labels,demo.sqlite,03517620)
msOGRLayerClose(demo.sqlite).
msOGRFileClose(D:\ms4w\apps\local-demo/.\./data/demo.sqlite,4).
msConnPoolRelease(ocean-labels,demo.sqlite,03517620)
msConnPoolClose(demo.sqlite,03517620)
msDrawMap(): Layer 3 (ocean-labels), 0.012s
msLayerIsVisible(): Skipping layer (places) because no CLASS in the layer is in-scale for this MAP scale
msDrawMap(): Drawing Label Cache, 0.004s
msDrawMap() total time: 0.075s
msSaveImage(test3.png) total time: 0.013s
shp2img total time: 0.096s

示例4生成特定层的地图图像

shp2img -m local.map -o test4.png -l "countries" -map_debug 3
结果

创建一个名为“test4.png”的文件,只返回一个层的层绘制速度,例如:

msDrawMap(): rendering using outputformat named png (AGG/PNG).
msDrawMap(): WMS/WFS set-up and query, 0.000s
msDrawMap(): Layer 1 (countries), 0.036s
msDrawMap(): Drawing Label Cache, 0.002s
msDrawMap() total time: 0.038s
msSaveImage(test4.png) total time: 0.026s

示例5为特定(多)层生成地图图像

备注

指定多个图层的语法是:-l“layer1 layer2 layer3 layer4”

shp2img -m local.map -o test5.png -l "countries lakes" -map_debug 3
结果

将创建一个名为“test5.png”的文件,并且仅返回两个指定层的层绘制速度,例如:

msDrawMap(): rendering using outputformat named png (AGG/PNG).
msDrawMap(): WMS/WFS set-up and query, 0.000s
msDrawMap(): Layer 1 (countries), 0.037s
msDrawMap(): Layer 2 (lakes), 0.008s
msDrawMap(): Drawing Label Cache, 0.002s
msDrawMap() total time: 0.049s
msSaveImage(test5.png) total time: 0.011s