public AttributeType getType() { return featureType.getType(index); }
AttributeType originalAttributeType = origional.getType(name); if (originalAttributeType != null && originalAttributeType instanceof GeometryType) {
AttributeType originalAttributeType = origional.getType(name); if( originalAttributeType != null && originalAttributeType instanceof GeometryType ) { GeometryType geometryType = (GeometryType)originalAttributeType;
@Override public AttributeType getType() { return featureType.getType(index); }
@Override public AttributeType getType() { return featureType.getType(index); }
public AttributeType getType() { return featureType.getType(index); }
@Override public AttributeType getType() { return featureType.getType(index); }
public void testSanity() { builder.setName("testName"); builder.setNamespaceURI("testNamespaceURI"); builder.add("point", Point.class, (CoordinateReferenceSystem) null); builder.add("integer", Integer.class); SimpleFeatureType type = builder.buildFeatureType(); assertNotNull(type); assertEquals(2, type.getAttributeCount()); AttributeType t = type.getType("point"); assertNotNull(t); assertEquals(Point.class, t.getBinding()); t = type.getType("integer"); assertNotNull(t); assertEquals(Integer.class, t.getBinding()); t = type.getGeometryDescriptor().getType(); assertNotNull(t); assertEquals(Point.class, t.getBinding()); }
public void testCRS() { builder.setName("testName"); builder.setNamespaceURI("testNamespaceURI"); builder.setCRS(DefaultGeographicCRS.WGS84); builder.crs(null).add("point", Point.class); builder.add("point2", Point.class, DefaultGeographicCRS.WGS84); builder.setDefaultGeometry("point"); SimpleFeatureType type = builder.buildFeatureType(); assertEquals(DefaultGeographicCRS.WGS84, type.getCoordinateReferenceSystem()); assertNull(type.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals( DefaultGeographicCRS.WGS84, ((GeometryType) type.getType("point2")).getCoordinateReferenceSystem()); }
public static Converter[] getConverters(SimpleFeatureType simpleFeatureType) throws IOException { Converter[] converters = new Converter[simpleFeatureType.getAttributeCount()]; for (int i = 0; i < converters.length; i++) { Class<?> attributeType = simpleFeatureType.getType(i).getBinding(); Converter converter = ConverterRegistry.getInstance().getConverter(attributeType); if (converter == null) { throw new IOException(String.format("No converter for type %s found.", attributeType)); } converters[i] = converter; } return converters; }
protected void setAttributeValue(SimpleFeatureBuilder builder, SimpleFeatureType simpleFeatureType, int attributeIndex, String token) throws IOException, ConversionException { token = VectorDataNodeIO.decodeTabString(token); Object value = null; if (!VectorDataNodeIO.NULL_TEXT.equals(token)) { Class<?> attributeType = simpleFeatureType.getType(attributeIndex).getBinding(); ConverterRegistry converterRegistry = ConverterRegistry.getInstance(); Converter<?> converter = converterRegistry.getConverter(attributeType); if (converter == null) { throw new IOException(String.format("No converter for type %s found.", attributeType)); } value = converter.parse(token); } builder.set(simpleFeatureType.getDescriptor(attributeIndex).getLocalName(), value); }
@Override protected void checkAttribute(WMSMapContext con, SimpleFeatureType ft) { // find out which attribute we're going to use Map options = con.getRequest().getFormatOptions(); attribute = (String) options.get("regionateAttr"); if (attribute == null) { attribute = typeInfo.getRegionateAttribute(); } if (attribute == null) { LOGGER.log(Level.INFO, "No attribute specified, falling " + "back on geometry attribute"); attribute = ft.getGeometryDescriptor().getLocalName(); } else { // Make sure the attribute is actually there AttributeType attributeType = ft.getType(attribute); if (attributeType == null) { throw new WmsException("Could not find regionating attribute " + attribute + " in layer " + typeInfo.getName()); } } // geometry size is a double h2Type = "DOUBLE"; }
@Override protected void checkAttribute(WMSMapContent con, SimpleFeatureType ft) { // find out which attribute we're going to use Map options = con.getRequest().getFormatOptions(); attribute = (String) options.get("regionateAttr"); if (attribute == null) { attribute = MapLayerInfo.getRegionateAttribute(featureType); } if (attribute == null || ft.getDescriptor(attribute) == null) { LOGGER.log(Level.FINER, "No attribute specified, falling " + "back on geometry attribute"); attribute = ft.getGeometryDescriptor().getLocalName(); } else { // Make sure the attribute is actually there AttributeType attributeType = ft.getType(attribute); if (attributeType == null) { throw new ServiceException("Could not find regionating attribute " + attribute + " in layer " + featureType.getName()); } } // geometry size is a double h2Type = "DOUBLE"; }
@Override protected String getDatabaseName(WMSMapContext con, MapLayer layer) throws Exception { fs = layer.getFeatureSource(); SimpleFeatureType type = (SimpleFeatureType) fs.getSchema(); // find out which attribute we're going to use Map options = con.getRequest().getFormatOptions(); attribute = (String) options.get("regionateAttr"); if (attribute == null) attribute = typeInfo.getRegionateAttribute(); if (attribute == null) throw new WmsException("Regionating attribute has not been specified"); // Make sure the attribute is actually there AttributeType attributeType = type.getType(attribute); if (attributeType == null) { throw new WmsException("Could not find regionating attribute " + attribute + " in layer " + typeInfo.getName()); } // check we can actually sort on that attribute if(!fs.getQueryCapabilities().supportsSorting(new SortBy[] {ff.sort(attribute, SortOrder.DESCENDING)})) throw new WmsException("Native sorting on the " + attribute + " is not possible for layer " + typeInfo.getName()); // make sure a special db for this layer and attribute will be created return super.getDatabaseName(con, layer) + "_" + attribute; }
@Override protected String getDatabaseName(WMSMapContent con, Layer layer) throws Exception { fs = layer.getFeatureSource(); SimpleFeatureType type = (SimpleFeatureType) fs.getSchema(); // find out which attribute we're going to use Map options = con.getRequest().getFormatOptions(); attribute = (String) options.get("regionateAttr"); if (attribute == null) attribute = MapLayerInfo.getRegionateAttribute( featureType ); if (attribute == null) throw new ServiceException("Regionating attribute has not been specified"); // Make sure the attribute is actually there AttributeType attributeType = type.getType(attribute); if (attributeType == null) { throw new ServiceException("Could not find regionating attribute " + attribute + " in layer " + featureType.getName()); } // check we can actually sort on that attribute if(!fs.getQueryCapabilities().supportsSorting(new SortBy[] {ff.sort(attribute, SortOrder.DESCENDING)})) throw new ServiceException("Native sorting on the " + attribute + " is not possible for layer " + featureType.getName()); // make sure a special db for this layer and attribute will be created return super.getDatabaseName(con, layer) + "_" + attribute; }
ProgressMonitor.NULL).getFeatureCollection(); assertEquals(1, fc.size()); assertEquals(Double.class, fc.getSchema().getType(0).getBinding()); assertEquals(10.0, fc.features().next().getAttribute("a")); } catch (IOException e) {