* @return thumbnail URL
*/
private String createThumbnailUrl(ServiceInfo serviceInfo) {
if (serviceInfo.getEnvelope() instanceof EnvelopeN) {
EnvelopeN e = (EnvelopeN) serviceInfo.getEnvelope();
Envelope envelope = new Envelope(e.getXMin(), e.getYMin(), e.getXMax(), e.getYMax());
envelope.setWkid(e.getSpatialReference()!=null && e.getSpatialReference().getWKID()!=null? e.getSpatialReference().getWKID().toString(): "4326");
GeometryService gs = GeometryService.createDefaultInstance();
try {
List<Envelope> envelopes = gs.project(Arrays.asList(new Envelope[]{envelope}), "4326");
if (!envelopes.isEmpty()) {
envelope = envelopes.get(0);
StringBuilder thumbnailURL = new StringBuilder();
thumbnailURL.append(serviceInfo.getSoapUrl());
thumbnailURL.append("?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=TRUE&STYLES=&VERSION=1.3.0");
thumbnailURL.append("&layers=");
StringBuilder liSB = new StringBuilder();
for (LayerInfo li : serviceInfo.getLayersInfo()) {
if (liSB.length()>0) {
liSB.append(",");
}
liSB.append(li.getName());
}
thumbnailURL.append(liSB);
thumbnailURL.append("&WIDTH=200&HEIGHT=133&CRS=EPSG:4326");
StringBuilder bboxSB = new StringBuilder();
bboxSB.append(envelope.getMinY()).append(",").append(envelope.getMinX()).append(",").append(envelope.getMaxY()).append(",").append(envelope.getMaxX());
thumbnailURL.append("&BBOX=").append(bboxSB);
return thumbnailURL.toString();
}