public FidTransformeVisitor(FeatureTypeMap map) { super(CommonFactoryFinder.getFilterFactory2(null)); this.map = map; }
public PropertyStyleHandler() { super("Property", FORMAT); styleFactory = CommonFactoryFinder.getStyleFactory(); filterFactory = CommonFactoryFinder.getFilterFactory(); }
@Override public GridCoverage2D getGridCoverage() { try { // There is a serious standardization failure around the axis order of WGS84. See issue #1930. // GeoTools assumes strict EPSG axis order of (latitude, longitude) unless told otherwise. // Both NED and SRTM data use the longitude-first axis order, so OTP makes grid coverages // for unprojected DEMs assuming coordinates are in (longitude, latitude) order. Hints forceLongLat = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); GeoTiffFormat format = new GeoTiffFormat(); GeoTiffReader reader = format.getReader(path, forceLongLat); coverage = reader.read(null); LOG.info("Elevation model CRS is: {}", coverage.getCoordinateReferenceSystem2D()); } catch (IOException e) { throw new RuntimeException("Error getting coverage automatically. ", e); } return coverage; }
private CatalogInfo replaceCatalogInfo(CatalogInfo ci) { String id = ci.getId(); Catalog catalog = (Catalog) GeoServerExtensions.bean("catalog"); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Class iface = getCatalogInfoInterface(ci.getClass()); CatalogInfo replacement = catalog.get(iface, ff.equal(ff.property("id"), ff.literal(id), true)); return replacement; }
Hints.putSystemDefault(Hints.FILTER_FACTORY, CommonFactoryFinder.getFilterFactory2(null)); Hints.putSystemDefault(Hints.STYLE_FACTORY, CommonFactoryFinder.getStyleFactory(null)); Hints.putSystemDefault(Hints.FEATURE_FACTORY, CommonFactoryFinder.getFeatureFactory(null));
/** * Returns the first implementation of {@link StyleFactory}. If no implementation matches, a new * one is created if possible or an exception is thrown otherwise. * * @return The first style factory available * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link StyleFactory} interface. * @see Hints#STYLE_FACTORY */ public static StyleFactory getStyleFactory() throws FactoryRegistryException { return getStyleFactory(null); }
public void testGetDefaultFeatureFactory() { FeatureFactory featureFactory = CommonFactoryFinder.getFeatureFactory(null); assertNotNull(featureFactory); assertTrue(featureFactory instanceof AbstractFeatureFactoryImpl); }
/** * Gets an instance of the FeatureLockFactory. * * @return A FeatureLockFactory instance. * @throws FactoryRegistryException If there exists a configuration error. */ public static FeatureLockFactory getInstance() throws FactoryRegistryException { if (factory == null) { factory = CommonFactoryFinder.getFeatureLockFactory(null); } return factory; }
@Before public void setUp() throws Exception { data = File.createTempFile("retype", "data", new File("./target")); data.delete(); data.mkdir(); final String fileName = MockData.BUILDINGS.getLocalPart() + ".properties"; URL properties = MockData.class.getResource(fileName); IOUtils.copy(properties.openStream(), new File(data, fileName)); PropertyDataStore pds = new PropertyDataStore(data); rts = new RetypingDataStore(pds) { @Override protected String transformFeatureTypeName(String originalName) { if (originalName.equals(MockData.BUILDINGS.getLocalPart())) return RENAMED; else return super.transformFeatureTypeName(originalName); } }; // build a filter that will retrieve one feature only FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); fid = RENAMED + ".1107531701011"; fidFilter = ff.id(Collections.singleton(ff.featureId(fid))); }
@Test public void testMaxVisitorDelegation() throws SchemaException, IOException { MaxVisitor visitor = new MaxVisitor(CommonFactoryFinder.getFilterFactory2().property("value")); assertOptimalVisit(visitor); }
@Test public void testEmptyStyle() throws Exception { SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory()); parser.setInput(StylesTest.class.getResourceAsStream("empty.sld")); StyledLayerDescriptor sld = parser.parseSLD(); assertNull(Styles.style(sld)); }
FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); fid = RENAMED + ".f001"; fidFilter = ff.id(Collections.singleton(ff.featureId(fid)));
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
@Override public Void answer() throws Throwable { Object[] args = getCurrentArguments(); InputStream is = (InputStream) args[1]; byte[] input = IOUtils.toByteArray(is); SLDParser parser = new SLDParser(CommonFactoryFinder.getStyleFactory()); parser.setInput(new ByteArrayInputStream(input)); StyledLayerDescriptor sld = parser.parseSLD(); NamedLayer nl = (NamedLayer) sld.getStyledLayers()[0]; assertEquals("foo", nl.getName()); Style style = nl.getStyles()[0]; assertEquals( "A raster style", style.getDescription().getTitle().toString()); assertEquals(1, style.featureTypeStyles().size()); FeatureTypeStyle fts = style.featureTypeStyles().get(0); assertEquals(1, fts.rules().size()); assertThat( fts.rules().get(0).symbolizers().get(0), instanceOf(RasterSymbolizer.class)); // make sure it's valid SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(new ByteArrayInputStream(input)); assertEquals(0, errors.size()); return null; } });
FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); dq.setFilter(ff.greater(ff.property("PERSONS"), ff.literal(20000000))); FeatureCollection fc = fs.getFeatures(dq);
new SLDParser(CommonFactoryFinder.getStyleFactory()); parser.setInput(new ByteArrayInputStream(input)); StyledLayerDescriptor sld = parser.parseSLD();
addNamespace(); final FilterFactory factory = CommonFactoryFinder.getFilterFactory();
assertEquals(BRIDGES.getLocalPart(), rs.getTypeNames()[0]); FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); String fid = BRIDGES.getLocalPart() + ".1107531701011"; Filter fidFilter = ff.id(Collections.singleton(ff.featureId(fid)));
@Test public void testFeautureSourceFidFilter() throws Exception { // grab the last feature in the collection (there are more than one) SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); // build a filter that will retrieve that feature only FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); final String fid = RENAMED + ".1107531701011"; Filter fidFilter = ff.id(Collections.singleton(ff.featureId(fid))); SimpleFeatureCollection fc = fs.getFeatures(new Query(RENAMED, fidFilter)); assertEquals(RENAMED, fc.getSchema().getName().getLocalPart()); assertEquals(1, fc.size()); FeatureIterator<SimpleFeature> it = fc.features(); assertTrue(it.hasNext()); SimpleFeature sf = it.next(); assertFalse(it.hasNext()); it.close(); assertEquals(fid, sf.getID()); }
@Test public void testFeautureSourceFidFilter() throws Exception { // grab the last feature in the collection (there are more than one) SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); // build a filter that will retrieve that feature only FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); final String fid = RENAMED + ".f001"; Filter fidFilter = ff.id(Collections.singleton(ff.featureId(fid))); SimpleFeatureCollection fc = fs.getFeatures(new Query(RENAMED, fidFilter)); assertEquals(RENAMED, fc.getSchema().getName().getLocalPart()); assertEquals(1, fc.size()); FeatureIterator<SimpleFeature> it = fc.features(); assertTrue(it.hasNext()); SimpleFeature sf = it.next(); assertFalse(it.hasNext()); it.close(); assertEquals(fid, sf.getID()); }