public FeatureType getFeatureType() throws IOException { return delegate.getFeatureType(); }
/** * Generate a style for a resource in the catalog, and add the created style to the catalog. * * @param handler The StyleHandler used to generate the style. Determines the style format. * @param featureType The FeatureType to generate the style for. Determines the style type and * style name * @return The StyleInfo referencing the generated style * @throws IOException */ public StyleInfo createStyle(StyleHandler handler, FeatureTypeInfo featureType) throws IOException { return createStyle(handler, featureType, featureType.getFeatureType()); }
if (featureType.getFeatureType() == null) { return null; GeometryDescriptor gd = featureType.getFeatureType().getGeometryDescriptor(); if (gd == null) { return null;
crs = data.getSchema().getCoordinateReferenceSystem(); } else { crs = ftinfo.getFeatureType().getCoordinateReferenceSystem();
expect(ft.getFeatureType()) .andAnswer( new IAnswer<FeatureType>() {
FeatureType type = ftInfo.getFeatureType(); assertEquals("sf_archsites", type.getName().getLocalPart()); assertEquals(
@Test public void testDefaultGeometry() throws IOException { FeatureTypeInfo featureType = getCatalog().getResourceByName("cdf", "Nulls", FeatureTypeInfo.class); GeometryDescriptor schemaDefaultGeometry = featureType.getFeatureType().getGeometryDescriptor(); FeatureIterator i = featureType.getFeatureSource(null, null).getFeatures().features(); GeometryDescriptor featureDefaultGeometry = i.next().getDefaultGeometryProperty().getDescriptor(); assertNotNull(schemaDefaultGeometry); assertNotNull(featureDefaultGeometry); assertEquals("pointProperty", schemaDefaultGeometry.getLocalName()); assertEquals(schemaDefaultGeometry, featureDefaultGeometry); } }
@Test public void testEmptyBounds() throws Exception { // test the bounds of a single point Catalog cat = getCatalog(); FeatureTypeInfo fti = cat.getFeatureTypeByName(toString(MockData.POINTS)); assertEquals( Point.class, fti.getFeatureType().getGeometryDescriptor().getType().getBinding()); assertEquals(1, fti.getFeatureSource(null, null).getCount(Query.ALL)); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getStoreByName(MockData.CGF_PREFIX, DataStoreInfo.class)); FeatureTypeInfo built = cb.buildFeatureType(fti.getQualifiedName()); cb.setupBounds(built); assertTrue(built.getNativeBoundingBox().getWidth() > 0); assertTrue(built.getNativeBoundingBox().getHeight() > 0); }
private boolean isSimpleFeature(FeatureTypeInfo[] featureTypeInfos) { boolean simple = true; for (int i = 0; i < featureTypeInfos.length && simple; i++) { try { simple = featureTypeInfos[i].getFeatureType() instanceof SimpleFeatureType; } catch (IOException e) { // ignore so that broken feature types don't prevent others from continuing to // work } } return simple; }
/** Checks if the provided feature types contains complex types. */ private static boolean containsComplexTypes(FeatureTypeInfo[] featureTypes) { for (FeatureTypeInfo featureType : featureTypes) { try { if (!(featureType.getFeatureType() instanceof SimpleFeatureType)) { return true; } } catch (Exception exception) { // ignore the broken feature type } } return false; }
@JsonIgnore public FeatureType getSchema() { try { return featureType.getFeatureType(); } catch (IOException e) { LOGGER.log(Level.INFO, "Failed to compute feature type", e); return null; } }
@Override protected Object load() { try { FeatureTypeInfo fti = (FeatureTypeInfo) featureTypeInfo.getObject(); List<String> result = new ArrayList<String>(); for (PropertyDescriptor property : fti.getFeatureType().getDescriptors()) { result.add(property.getName().getLocalPart()); } Collections.sort(result); return result; } catch(IOException e) { throw new RuntimeException("Could not load feature type attribute list", e); } }
@Override protected List<String> load() { try { FeatureTypeInfo fti = featureTypeInfo.getObject(); List<String> result = new ArrayList<String>(); for (PropertyDescriptor property : fti.getFeatureType().getDescriptors()) { result.add(property.getName().getLocalPart()); } Collections.sort(result); return result; } catch (IOException e) { throw new RuntimeException("Could not load feature type attribute list", e); } } }
private List<String> getAttributesNames(FeatureTypeInfo featureTypeInfo) { try { return featureTypeInfo .getFeatureType() .getDescriptors() .stream() .map(attribute -> attribute.getName().getLocalPart()) .collect(Collectors.toList()); } catch (Exception exception) { throw new RuntimeException( String.format( "Error processing attributes of feature type '%s'.", featureTypeInfo.getName()), exception); } }
protected List<PropertyName> addGeometryProperties( FeatureTypeInfo meta, List<PropertyName> oldProperties) throws IOException { List<AttributeTypeInfo> atts = meta.attributes(); Iterator ii = atts.iterator(); List<PropertyName> properties = new ArrayList<PropertyName>(oldProperties); while (ii.hasNext()) { AttributeTypeInfo ati = (AttributeTypeInfo) ii.next(); PropertyName propName = filterFactory.property(ati.getName()); if (meta.getFeatureType().getDescriptor(ati.getName()) instanceof GeometryDescriptor && !properties.contains(propName)) { properties.add(propName); } } return properties; } }
private List<String> getTimeProperties(QName typeName) throws IOException { Catalog catalog = geoServer.getCatalog(); NamespaceInfo ns = catalog.getNamespaceByURI(typeName.getNamespaceURI()); FeatureTypeInfo ft = catalog.getFeatureTypeByName(ns, typeName.getLocalPart()); if (ft == null) { return Collections.emptyList(); } FeatureType schema = ft.getFeatureType(); return schema.getDescriptors() .stream() .filter(pd -> Date.class.isAssignableFrom(pd.getType().getBinding())) .map(pd -> pd.getName().getLocalPart()) .collect(Collectors.toList()); }
@Override protected String checkAttribute(FeatureTypeInfo cfg){ String attribute = MapLayerInfo.getRegionateAttribute(cfg); try{ FeatureType ft = cfg.getFeatureType(); if ((attribute != null) && (ft.getDescriptor(attribute) != null)) return attribute; return ft.getGeometryDescriptor().getLocalName(); } catch (Exception e) { LOGGER.severe("Couldn't get attribute name due to " + e); return null; } }
void validateSortBy(List<SortBy> sortBys, FeatureTypeInfo meta, final GetFeatureRequest request) throws IOException { FeatureType featureType = meta.getFeatureType(); for (SortBy sortBy : sortBys) { PropertyName name = sortBy.getPropertyName(); if (name.evaluate(featureType) == null) { throw new WFSException( request, "Illegal property name: " + name.getPropertyName() + " for feature type " + meta.prefixedName(), "InvalidParameterValue"); } } }
/** Tests that symbols are not bigger than the requested icon size. */ @org.junit.Test public void testSymbolContainedInIcon() throws Exception { GetLegendGraphicRequest req = new GetLegendGraphicRequest(); FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName( MockData.MPOINTS.getNamespaceURI(), MockData.MPOINTS.getLocalPart()); req.setLayer(ftInfo.getFeatureType()); req.setStyle(readSLD("BigSymbol.sld")); BufferedImage image = this.legendProducer.buildLegendGraphic(req); assertNotBlank("testSymbolSize", image, LegendUtils.DEFAULT_BG_COLOR); // background at borders assertPixel(image, 1, 1, new Color(255, 255, 255)); // symbol in the center assertPixel(image, 10, 10, new Color(255, 0, 0)); }
@Test public void testDefaultStyle() throws Exception { List<org.geoserver.catalog.FeatureTypeInfo> typeInfos = getCatalog().getFeatureTypes(); for (org.geoserver.catalog.FeatureTypeInfo info : typeInfos) { if (info.getQualifiedName().getNamespaceURI().equals(MockData.CITE_URI) && info.getFeatureType().getGeometryDescriptor() != null) testDefaultStyle(info.getFeatureSource(null, null)); } }