@Test public void testRenamedDefinition() throws DataStoreException, NoSuchAuthorityCodeException, FactoryException { final ExtendedDataStore store = new ExtendedDataStore(dataStore); final Name name = DefaultName.valueOf("{http://www.geotoolkit.org/test}extsql"); assertFalse(store.getNames().contains(name)); // add a new query final Query query = QueryBuilder.language( JDBCDataStore.CUSTOM_SQL, "SELECT geometry as geo ,\"intProperty\" as it FROM custom", name); store.addQuery(query); assertTrue(store.getNames().contains(name)); final FeatureType ft = store.getFeatureType(name); assertEquals(name, ft.getName()); assertEquals(2, ft.getDescriptors().size()); assertTrue(ft.getDescriptor("geo") != null); assertTrue(ft.getDescriptor("it") != null); assertEquals(Point.class, ft.getDescriptor("geo").getType().getBinding()); assertTrue( CRS.equalsIgnoreMetadata( CRS.decode("EPSG:4326", true), ((GeometryDescriptor) ft.getDescriptor("geo")).getCoordinateReferenceSystem())); assertEquals(Integer.class, ft.getDescriptor("it").getType().getBinding()); }
/** {@inheritDoc } */ @Override public double[] getResolution(final CoordinateReferenceSystem crs) { if (CRS.equalsIgnoreMetadata(objectiveCRS, crs)) { return getResolution(); } else { final double[] res = new double[crs.getCoordinateSystem().getDimension()]; final Envelope env; try { env = CRS.transform(canvasObjectiveBBox2D, crs); final Rectangle2D canvasCRSBounds = new Rectangle2D.Double(0, 0, env.getSpan(0), env.getSpan(1)); res[0] = Math.abs(canvasCRSBounds.getWidth() / canvasDisplaybounds.getWidth()); res[1] = Math.abs(canvasCRSBounds.getHeight() / canvasDisplaybounds.getHeight()); for (int i = 2; i < res.length; i++) { // other dimension are likely to be the temporal and elevation one. // we set a hug resolution to ensure that only one slice of data will be retrived. res[i] = Double.MAX_VALUE; } } catch (TransformException ex) { LOGGER.log(Level.WARNING, null, ex); } catch (IllegalArgumentException ex) { LOGGER.log(Level.WARNING, null, ex); } catch (Exception ex) { LOGGER.log(Level.WARNING, null, ex); } return adjustResolutionWithDPI(res); } }
/** * Returns the CRS code for the specified envelope, or {@code null} if not found. * * @param envelope The envelope to return the CRS code. */ public static String toCrsCode(final Envelope envelope) { if (org.geotoolkit.referencing.CRS.equalsIgnoreMetadata( envelope.getCoordinateReferenceSystem(), CommonCRS.WGS84.normalizedGeographic())) { return "EPSG:4326"; } final Set<Identifier> identifiers = envelope.getCoordinateReferenceSystem().getIdentifiers(); if (identifiers != null && !identifiers.isEmpty()) { return identifiers.iterator().next().toString(); } return null; }