Search in sources :

Example 16 with UrlResource

use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.

the class WmsClient method loadCapabilities.

public WmsCapabilities loadCapabilities() {
    final Map<String, Object> parameters = new LinkedHashMap<>();
    parameters.put(WmsParameters.SERVICE, WmsParameterValues.WMS);
    parameters.put(WmsParameters.REQUEST, WmsParameterValues.GET_CAPABILITIES);
    final UrlResource capabilitiesUrl = newServiceUrlResource(parameters);
    try (InputStream in = capabilitiesUrl.getInputStream()) {
        final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setValidating(false);
        documentBuilderFactory.setNamespaceAware(true);
        final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        final Document document = documentBuilder.parse(in);
        this.capabilities = new WmsCapabilities(this, document.getDocumentElement());
        return this.capabilities;
    } catch (final Throwable e) {
        throw Exceptions.wrap("Unable to read capabilities: " + capabilitiesUrl, e);
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) UrlResource(com.revolsys.spring.resource.UrlResource) DocumentBuilder(javax.xml.parsers.DocumentBuilder) InputStream(java.io.InputStream) Document(org.w3c.dom.Document) LinkedHashMap(java.util.LinkedHashMap) WmsCapabilities(com.revolsys.gis.wms.capabilities.WmsCapabilities)

Example 17 with UrlResource

use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystemsLoader method validateEsri.

private void validateEsri() {
    EsriCoordinateSystems.getCoordinateSystem(0);
    for (final CoordinateSystem coordinateSytstem : EpsgCoordinateSystems.getCoordinateSystems()) {
        if (coordinateSytstem instanceof GeographicCoordinateSystem) {
            final GeographicCoordinateSystem geoCs = (GeographicCoordinateSystem) coordinateSytstem;
            final int id = coordinateSytstem.getCoordinateSystemId();
            final GeographicCoordinateSystem esri = EsriCoordinateSystems.getCoordinateSystem(id);
            if (esri != null && !geoCs.equalsExact(esri)) {
            // System.out.println(id + coordinateSytstem.getCoordinateSystemName());
            }
        } else if (coordinateSytstem instanceof ProjectedCoordinateSystem) {
            final ProjectedCoordinateSystem projectedCs = (ProjectedCoordinateSystem) coordinateSytstem;
            final int id = coordinateSytstem.getCoordinateSystemId();
            final String wkt = new UrlResource("http://spatialreference.org/ref/epsg/" + id + "/esriwkt/").contentsAsString();
            final ProjectedCoordinateSystem esri = GeometryFactory.floating2d(wkt).getCoordinateSystem();
            final CoordinateOperationMethod coordinateOperationMethod = esri.getCoordinateOperationMethod();
            if (esri != null && !projectedCs.equals(esri) && coordinateOperationMethod != null && Property.hasValue(coordinateOperationMethod.getName()) && !projectedCs.isDeprecated()) {
                final Map<ParameterName, Object> p1 = projectedCs.getParameters();
                final Map<ParameterName, Object> p2 = esri.getParameters();
                final Set<ParameterName> n1 = p1.keySet();
                final Set<ParameterName> n2 = p2.keySet();
                if (!n1.equals(n2)) {
                    final TreeSet<ParameterName> nm1 = new TreeSet<>(n1);
                    nm1.removeAll(n2);
                    final TreeSet<ParameterName> nm2 = new TreeSet<>(n2);
                    nm2.removeAll(n1);
                    final String m = id + "\t" + coordinateSytstem.getCoordinateSystemName() + "\t" + nm1 + "\t" + nm2;
                // System.out.println(m);
                }
            }
        }
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) UrlResource(com.revolsys.spring.resource.UrlResource) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) TreeSet(java.util.TreeSet) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 18 with UrlResource

use of com.revolsys.spring.resource.UrlResource in project com.revolsys.open by revolsys.

the class ArcGisResponse method getResource.

public Resource getResource(final String child, final Map<String, ? extends Object> parameters) {
    final UrlResource serviceUrl = getServiceUrl(child);
    if (isUseProxy()) {
        final StringBuilder queryUrl = new StringBuilder(serviceUrl.getUriString());
        final String query = '?' + UrlUtil.getQueryString(parameters);
        queryUrl.append(UrlUtil.percentEncode(query));
        final String username = serviceUrl.getUsername();
        final String password = serviceUrl.getPassword();
        return new UrlResource(queryUrl, username, password);
    } else {
        return serviceUrl.newUrlResource(parameters);
    }
}
Also used : UrlResource(com.revolsys.spring.resource.UrlResource)

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