/** * Gives a connection to a remote WFS * * @param wfsUrl URL of the WFS. Should be a GetCapabilities request * @return Virtual DataStore. All features can be extracted from it. * @throws DocServiceException */ @SuppressWarnings("unchecked") private WFSContentDataStore connectToWFS(final URL wfsUrl) throws DocServiceException { WFSContentDataStore wfs = null; Map m = new HashMap(); try { UsernamePasswordCredentials credentials = findCredentials(wfsUrl); if (credentials != null) { m.put(WFSDataStoreFactory.USERNAME.key, credentials.getUserName()); m.put(WFSDataStoreFactory.PASSWORD.key, credentials.getPassword()); } // connect to remote WFS m.put(WFSDataStoreFactory.URL.key, wfsUrl); m.put(WFSDataStoreFactory.TIMEOUT.key, 60000); // default: 3000 // TODO : .key necessary for those two ? m.put(WFSDataStoreFactory.TRY_GZIP, true); // try to optimize communication m.put(WFSDataStoreFactory.ENCODING, "UTF-8"); // try to force UTF-8 // TODO : configurable ? m.put(WFSDataStoreFactory.MAXFEATURES.key, 2000); wfs = _factory.createDataStore(m); } catch (SocketTimeoutException e) { throw new DocServiceException("WFS is unavailable", HttpServletResponse.SC_GATEWAY_TIMEOUT); } catch (DataSourceException e) { // happens when wfs url is wrong (missing request or service parameters...) throw new DocServiceException(e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); } catch (IOException e) { e.printStackTrace(); } return wfs; }
public void updateTypeFilter(String typeName, GeometryType geometryType, String srs) { this.geometryType = geometryType; entityIterator = theUnivers.theEntities.iterator(); try { createFeatureType(typeName, srs); } catch (DataSourceException ex) { log.error(ex.getLocalizedMessage()); } }
/** @see org.geotools.data.coverage.grid.AbstractGridFormat#getReader(Object, Hints) */ @Override public AbstractGridCoverage2DReader getReader(Object source, Hints hints) { try { return new JP2KReader(source, hints); } catch (MismatchedDimensionException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } catch (DataSourceException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } catch (IOException e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } }