use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.
the class MapGuideWebService method getResource.
public Resource getResource(final String operation, final String format, final Map<String, ? extends Object> parameters) throws Error {
final MapEx newParameters = new LinkedHashMapEx(parameters);
newParameters.put("VERSION", "1.0.0");
newParameters.put("OPERATION", operation);
newParameters.put("format", format);
final UrlResource serviceUrl = getServiceUrl();
final UrlResource mapAgentUrl = serviceUrl.newChildResource("mapagent/mapagent.fcgi");
final UrlResource resource = mapAgentUrl.newUrlResource(newParameters);
return resource;
}
use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.
the class GeoPackage method newDataSource.
@Override
public DataSource newDataSource(final Map<String, ? extends Object> config) {
final MapEx newConfig = new LinkedHashMapEx(config);
final String url = newConfig.getString("url");
if (Property.hasValue(url) && !url.startsWith("jdbc")) {
try {
final UrlResource resource = new UrlResource(url);
final File file = resource.getFile();
final String newUrl = JDBC_PREFIX + FileUtil.getCanonicalPath(file);
newConfig.put("url", newUrl);
} catch (final Exception e) {
throw new IllegalArgumentException(url + " must be a file", e);
}
}
newConfig.put("enable_load_extension", true);
return JdbcDatabaseFactory.super.newDataSource(newConfig);
}
use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.
the class CreateIndex method main.
public static void main(final String[] args) {
SymbolLibrary.findSymbol("maki/police");
final Resource makiFile = new UrlResource("https://www.mapbox.com/maki/www/maki.json");
final List<MapEx> symbolList = Json.toMapList(makiFile);
final SymbolLibrary symbolLibrary = new SymbolLibrary("maki", "Maki");
for (final MapEx symbolMap : symbolList) {
final String name = "maki/" + symbolMap.getString("icon");
final String title = symbolMap.getString("name");
symbolLibrary.addSymbolSvg(name, title);
}
final File symbolLibraryFile = new File("src/main/resources/META-INF/com.revolsys.swing.map.symbol.SymbolLibrary.json");
MapObjectFactory.write(symbolLibraryFile, symbolLibrary);
final SymbolLibrary symbolLibrary2 = MapObjectFactory.toObject(symbolLibraryFile);
}
use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.
the class WmsClient method getMapUrl.
public UrlResource getMapUrl(final List<String> layers, final List<String> styles, final String srid, final BoundingBox envelope, final String format, final int width, final int height) {
final WmsCapabilities capabilities = getCapabilities();
final String version = capabilities.getVersion();
final Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("SERVICE", "WMS");
if (version.equals("1.0.0")) {
parameters.put(WmsParameters.WMTVER, version);
parameters.put(WmsParameters.REQUEST, WmsParameterValues.MAP);
} else {
parameters.put(WmsParameters.VERSION, version);
parameters.put(WmsParameters.REQUEST, WmsParameterValues.GET_MAP);
}
parameters.put(WmsParameters.LAYERS, Strings.toString(layers));
String style;
if (styles == null) {
style = "";
} else {
style = Strings.toString(styles);
for (int i = styles.size(); i < layers.size(); i++) {
style += ",";
}
}
parameters.put(WmsParameters.STYLES, style);
if (version.equals("1.3.0")) {
parameters.put(WmsParameters.CRS, srid);
} else {
parameters.put(WmsParameters.SRS, srid);
}
final String bbox = envelope.getMinX() + "," + envelope.getMinY() + "," + envelope.getMaxX() + "," + envelope.getMaxY();
parameters.put(WmsParameters.BBOX, bbox);
parameters.put(WmsParameters.WIDTH, width);
parameters.put(WmsParameters.HEIGHT, height);
parameters.put(WmsParameters.FORMAT, format);
final String exceptionFormat = capabilities.getExceptionFormat();
parameters.put(WmsParameters.EXCEPTIONS, exceptionFormat);
parameters.put(WmsParameters.TRANSPARENT, "TRUE");
// = getCapabilities().getRequestUrl("GetMap",
UrlResource requestUrl = null;
// "GET");
if (requestUrl == null) {
requestUrl = getServiceUrl();
}
return requestUrl.newUrlResource(parameters);
}
use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.
the class IoFactory method getZipResource.
default Resource getZipResource(final Object source) {
Resource resource = Resource.getResource(source);
if (isReadFromZipFileSupported()) {
final String filename = resource.getFilename();
if (filename.endsWith(".zip")) {
final String baseName = filename.substring(0, filename.length() - 4);
final String url = "jar:" + resource.getUri() + "!/" + baseName;
final UrlResource urlResource = new UrlResource(url);
if (urlResource.exists()) {
resource = urlResource;
} else {
return null;
}
} else if (filename.endsWith(".gz")) {
return new GzipResource(resource);
} else if (filename.endsWith(getFileExtensions().get(0) + "z")) {
return new GzipResource(resource);
}
}
return resource;
}
Aggregations