/** Builds the default coverage contained in the current store */ public CoverageInfo buildCoverage(String coverageName) throws Exception { if (store == null || !(store instanceof CoverageStoreInfo)) { throw new IllegalStateException("Coverage store not set."); } CoverageStoreInfo csinfo = (CoverageStoreInfo) store; GridCoverage2DReader reader = (GridCoverage2DReader) catalog.getResourcePool() .getGridCoverageReader(csinfo, GeoTools.getDefaultHints()); if (reader == null) throw new Exception( "Unable to acquire a reader for this coverage with format: " + csinfo.getFormat().getName()); return buildCoverage(reader, coverageName, null); }
/** Make sure a JNDI context is available */ public boolean isAvailable() { try { GeoTools.getInitialContext(GeoTools.getDefaultHints()); return true; } catch (Exception e) { return false; } } }
/** * Provides GeoTools with the JNDI context for resource lookup. * * @param applicationContext The initial context to use. * @see #getInitialContext * @since 2.4 */ public static void init(final InitialContext applicationContext) { synchronized (GeoTools.class) { context = applicationContext; } fireConfigurationChanged(); }
GeoTools.init((Hints) null); final Hints defHints = GeoTools.getDefaultHints();
public String newRequestHandle(WFSOperationType operation) { StringBuilder handle = new StringBuilder("GeoTools ") .append(GeoTools.getVersion()) .append("(") .append(GeoTools.getBuildRevision()) .append(") WFS ") .append(getVersion()) .append(" DataStore @"); try { handle.append(InetAddress.getLocalHost().getHostName()); } catch (Exception ignore) { handle.append("<uknown host>"); } AtomicLong reqHandleSeq = requestHandleSequences.get(operation); handle.append('#').append(reqHandleSeq.incrementAndGet()); return handle.toString(); }
/** * Reports the GeoTools {@linkplain #getVersion version} number to the {@linkplain System#out * standard output stream}. * * @param args Command line arguments. */ public static void main(String[] args) { final Arguments arguments = new Arguments(args); args = arguments.getRemainingArguments(0); arguments.out.print("GeoTools version "); arguments.out.println(getVersion()); final Hints hints = getDefaultHints(); if (hints != null && !hints.isEmpty()) { arguments.out.println(hints); } } }
/** * Returns the default entity resolver, used to configure {@link SAXParser}. * * @param hints An optional set of hints, or {@code null} if none, see {@link * Hints#ENTITY_RESOLVER}. * @return An entity resolver (never {@code null}) */ public static EntityResolver getEntityResolver(Hints hints) { if (hints == null) { hints = getDefaultHints(); } if (hints.containsKey(Hints.ENTITY_RESOLVER)) { Object hint = hints.get(Hints.ENTITY_RESOLVER); if (hint == null) { return NullEntityResolver.INSTANCE; } else if (hint instanceof EntityResolver) { return (EntityResolver) hint; } else if (hint instanceof String) { String className = (String) hint; return instantiate( className, EntityResolver.class, PreventLocalEntityResolver.INSTANCE); } } return PreventLocalEntityResolver.INSTANCE; }
protected void setUp() throws Exception { // this is the only thing that actually forces CRS object to give up // its configuration, necessary when tests are run by Maven, one JVM for all // the tests in this module Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); GeoTools.fireConfigurationChanged(); ft = DataUtilities.createType( "testType", "geom:Point:srid=4326,line:LineString,name:String,id:int"); ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints()); reprojector = new ReprojectingFilterVisitor(ff, ft); }
DataSource source = null; try { context = GeoTools.getInitialContext(new Hints(hints)); source = (DataSource) context.lookup(datasourceName); } catch (IllegalArgumentException exception) {
final URL classLocation = classLocation(type); String path = classLocation.toString(); String jarVersion = jarVersion(path); if (jarVersion != null) { return new Version(jarVersion); URL manifestLocation = manifestLocation(path); Manifest manifest = new Manifest(); try (InputStream content = manifestLocation.openStream()) { return GeoTools.getVersion();
final URL classLocation = classLocation(type); Manifest manifest = new Manifest(); URL manifestLocation = manifestLocation(classLocation.toString()); if (manifestLocation != null) { try { || name.startsWith("net.opengis")) { String generated = "Manifest-Version: 1.0\n" + "Project-Version: " + getVersion() + "\n";
/** * A helper method for {@linkplain #getGeoToolsJarInfo} which scans the classpath looking for * GeoTools jars matching the current version. * * @return a list of jar names */ private static List<String> getGeoToolsJars() { final Pattern pattern = Pattern.compile(".*\\/" + getVersion() + "\\/(gt-.*jar$)"); final List<String> jarNames = new ArrayList<String>(); String pathSep = System.getProperty("path.separator"); String classpath = System.getProperty("java.class.path"); StringTokenizer st = new StringTokenizer(classpath, pathSep); while (st.hasMoreTokens()) { String path = st.nextToken(); Matcher matcher = pattern.matcher(path); if (matcher.find()) { jarNames.add(matcher.group(1)); } } Collections.sort(jarNames); return jarNames; }
/** * Implementation of {@code fixName} method. If the context is {@code null}, then the * {@linkplain #getInitialContext GeoTools initial context} will be fetch only when first * needed. */ private static String fixName(Context context, final String name, final Hints hints) { String fixed = null; if (name != null) { final StringTokenizer tokens = new StringTokenizer(name, ":/"); while (tokens.hasMoreTokens()) { final String part = tokens.nextToken(); if (fixed == null) { fixed = part; } else try { if (context == null) { context = getInitialContext(hints); } fixed = context.composeName(fixed, part); } catch (NamingException e) { Logging.unexpectedException(GeoTools.class, "fixName", e); return name; } } } return fixed; }
/** * Returns summary information about the GeoTools version and the host environment. * * @return information as a String */ public static String getEnvironmentInfo() { final String newline = String.format("%n"); final StringBuilder sb = new StringBuilder(); sb.append("GeoTools version ").append(getVersion().toString()); if (sb.toString().endsWith("SNAPSHOT")) { sb.append(" (built from r").append(getBuildRevision().toString()).append(")"); } sb.append(newline).append("Java version: "); sb.append(System.getProperty("java.version")); sb.append(newline).append("Operating system: "); sb.append(System.getProperty("os.name")) .append(' ') .append(System.getProperty("os.version")); return sb.toString(); }
/** Sets the metadata information. */ private void setInfo() { Map<String, String> info = new HashMap<String, String>(); info.put("name", "ArcSDE Raster"); info.put("description", "ArcSDE Raster Format"); info.put("vendor", "Geotools "); info.put("docURL", ""); info.put("version", GeoTools.getVersion().toString()); mInfo = info; readParameters = new ParameterGroup( new DefaultParameterDescriptorGroup( mInfo, new GeneralParameterDescriptor[] { READ_GRIDGEOMETRY2D, OVERVIEW_POLICY })); }
/** * Builds the default coverage contained in the current store * * @param nativeCoverageName the native name for the coverage * @param specifiedName the published name for the coverage. If null, the name will be * determined from the coverage store. * @return coverage for the specified name * @throws Exception if the coverage store was not found or could not be read, or if the * coverage could not be created. */ public CoverageInfo buildCoverageByName(String nativeCoverageName, String specifiedName) throws Exception { if (store == null || !(store instanceof CoverageStoreInfo)) { throw new IllegalStateException("Coverage store not set."); } CoverageStoreInfo csinfo = (CoverageStoreInfo) store; GridCoverage2DReader reader = (GridCoverage2DReader) catalog.getResourcePool() .getGridCoverageReader(csinfo, GeoTools.getDefaultHints()); if (reader == null) throw new Exception( "Unable to acquire a reader for this coverage with format: " + csinfo.getFormat().getName()); return buildCoverageInternal(reader, nativeCoverageName, null, specifiedName); }
/** * Determines if the datastore is available. * * <p>Check in an Initial Context is available, that is all what can be done Checking for the * right jdbc jars in the classpath is not possible here */ public boolean isAvailable() { try { GeoTools.getInitialContext(GeoTools.getDefaultHints()); return true; } catch (NamingException e) { return false; } }
/** * Adds a class loader to be included in the list of class loaders that are used to locate * GeoTools plug-ins. * * <p>Client code that calls this method may also need to call {@link * FactoryRegistry#scanForPlugins()} on any existing registry to force it to clear its cache and * use the added class loader to locate plugins. * * @param classLoader The class loader. */ public static void addClassLoader(ClassLoader classLoader) { addedClassLoaders.add(classLoader); fireConfigurationChanged(); }
public AbstractEpsgFactory(final Hints userHints) throws FactoryException { super(MAXIMUM_PRIORITY - 20); // The following hints have no effect on this class behaviour, // but tell to the user what this factory do about axis order. hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE); hints.put(Hints.FORCE_STANDARD_AXIS_DIRECTIONS, Boolean.FALSE); hints.put(Hints.FORCE_STANDARD_AXIS_UNITS, Boolean.FALSE); // // We need to obtain our DataSource if (userHints != null) { Object hint = userHints.get(Hints.EPSG_DATA_SOURCE); if (hint instanceof String) { String name = (String) hint; try { dataSource = (DataSource) GeoTools.getInitialContext(userHints).lookup(name); } catch (NamingException e) { throw new FactoryException("A EPSG_DATA_SOURCE hint is required:" + e); } hints.put(Hints.EPSG_DATA_SOURCE, dataSource); } else if (hint instanceof DataSource) { dataSource = (DataSource) hint; hints.put(Hints.EPSG_DATA_SOURCE, dataSource); } else { throw new FactoryException("A EPSG_DATA_SOURCE hint is required."); } } else { throw new FactoryException("A EPSG_DATA_SOURCE hint is required."); } }
final Hints defHints = GeoTools.getDefaultHints();