public GetResource ( string mapName, ResourceParameter resourceParameter, |
||
mapName | string | 地图名称。 |
resourceParameter | ResourceParameter | 资源图片参数,如生成的图片的高度、宽度、类型,资源的类型、风格等。 |
imageOutputOption | 资源图片输出设置。 | |
return |
public void GetResourceTest_LineID() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); string mapName = "世界地图"; ResourceParameter parameter = new ResourceParameter(); parameter.Style = new Style(); parameter.Style.LineSymbolID = 5; parameter.Type = ResourceType.SYMBOLLINE; ImageOutputOption option = new ImageOutputOption(); option.ImageOutputFormat = ImageOutputFormat.PNG; option.ImageReturnType = ImageReturnType.URL; ResourceImage image = map.GetResource(mapName, parameter, option); Assert.AreEqual(image.ImageUrl, "http://192.168.116.114:8090/iserver/output/resources/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE/SYMBOLLINE/5_781806645.png"); }
public void GetResourceTest_Marker() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); string mapName = "世界地图"; ResourceParameter parameter = new ResourceParameter(); parameter.Type = ResourceType.SYMBOLMARKER; ImageOutputOption option = new ImageOutputOption(); option.ImageOutputFormat = ImageOutputFormat.PNG; option.ImageReturnType = ImageReturnType.URL; ResourceImage image = map.GetResource(mapName, parameter, option); Assert.AreEqual(image.ImageUrl, "http://192.168.116.114:8090/iserver/output/resources/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE/SYMBOLMARKER/0_1160020228.png"); }
public void GetResourceTest_MarkerIDError() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); string mapName = "世界地图"; ResourceParameter parameter = new ResourceParameter(); parameter.Style = new Style(); parameter.Style.MarkerSymbolID = 200; parameter.Type = ResourceType.SYMBOLMARKER; ImageOutputOption option = new ImageOutputOption(); option.ImageOutputFormat = ImageOutputFormat.BMP; option.ImageReturnType = ImageReturnType.URL; ResourceImage image = null; try { image = map.GetResource(mapName, parameter, option); } catch (ServiceException e) { Assert.AreEqual(e.Message, "获取资源图片的符号 ID 超出范围。"); } }
public void GetResourceTest_BitMap() { Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest"); string mapName = "世界地图"; ResourceParameter parameter = new ResourceParameter(); parameter.Type = ResourceType.SYMBOLFILL; ImageOutputOption option = new ImageOutputOption(); option.ImageOutputFormat = ImageOutputFormat.PNG; option.ImageReturnType = ImageReturnType.BINARY; ResourceImage image = map.GetResource(mapName, parameter, option); Assert.AreEqual(image.ImageData[1], 80); Assert.AreEqual(image.ImageData[30], 105); }