Search in sources :

Example 1 with UrlResource

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;
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) UrlResource(com.revolsys.spring.resource.UrlResource) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx)

Example 2 with UrlResource

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);
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) UrlResource(com.revolsys.spring.resource.UrlResource) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) File(java.io.File)

Example 3 with UrlResource

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);
}
Also used : UrlResource(com.revolsys.spring.resource.UrlResource) MapEx(com.revolsys.collection.map.MapEx) Resource(com.revolsys.spring.resource.Resource) UrlResource(com.revolsys.spring.resource.UrlResource) SymbolLibrary(com.revolsys.swing.map.symbol.SymbolLibrary) File(java.io.File)

Example 4 with UrlResource

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);
}
Also used : UrlResource(com.revolsys.spring.resource.UrlResource) WmsCapabilities(com.revolsys.gis.wms.capabilities.WmsCapabilities) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with UrlResource

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;
}
Also used : GzipResource(com.revolsys.spring.resource.GzipResource) UrlResource(com.revolsys.spring.resource.UrlResource) GzipResource(com.revolsys.spring.resource.GzipResource) UrlResource(com.revolsys.spring.resource.UrlResource) Resource(com.revolsys.spring.resource.Resource)

Aggregations

UrlResource (com.revolsys.spring.resource.UrlResource)18 MapEx (com.revolsys.collection.map.MapEx)4 Resource (com.revolsys.spring.resource.Resource)4 PathName (com.revolsys.io.PathName)3 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)2 WmsCapabilities (com.revolsys.gis.wms.capabilities.WmsCapabilities)2 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)1 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)1 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)1 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)1 GzipResource (com.revolsys.spring.resource.GzipResource)1 SymbolLibrary (com.revolsys.swing.map.symbol.SymbolLibrary)1 WebServiceResource (com.revolsys.webservice.WebServiceResource)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1