if (gd == null) return catalog.getStyleByName(StyleInfo.DEFAULT_POINT); Class gtype = gd.getType().getBinding(); StyleType st; if (LineString.class.isAssignableFrom(gtype)
Class gtype = gd.getType().getBinding(); if (Point.class.isAssignableFrom(gtype) || MultiPoint.class.isAssignableFrom(gtype)) { styleName = StyleInfo.DEFAULT_POINT;
@Override public Geometry decodeGeometryValue( GeometryDescriptor descriptor, ResultSet rs, int column, GeometryFactory factory, Connection cx, Hints hints) throws IOException, SQLException { return geometry(descriptor.getType().getBinding(), rs.getBytes(column), factory, hints); }
/** * Checks if reduction required and makes sense * * @param hints hints passed in * @param gatt Geometry attribute descriptor * @param param {@link Hints#GEOMETRY_GENERALIZATION} or {@link Hints#GEOMETRY_SIMPLIFICATION} * @return true to indicate reducing the geometry, false otherwise */ protected boolean isGeometryReduceRequired( Hints hints, GeometryDescriptor gatt, Hints.Key param) { if (hints == null) return false; if (hints.containsKey(param) == false) return false; if (gatt.getType().getBinding() == Point.class) return false; return true; }
Class featureClass = gd.getType().getBinding(); Integer dimension = (Integer) gd.getUserData().get(Hints.COORDINATE_DIMENSION);
Class<?> clazz = desc.getType().getBinding(); Color fillColor = null;
static Geometries findGeometryType(SimpleFeatureType schema) { GeometryDescriptor gd = findGeometryDescriptor(schema); return gd != null ? Geometries.getForBinding((Class<? extends Geometry>) gd.getType().getBinding()) : null; }
public static BufferedImage icon(SimpleFeatureType ft) { if (ft == null || ft.getGeometryDescriptor() == null) return null; Class binding = ft.getGeometryDescriptor().getType().getBinding(); if (Point.class.isAssignableFrom(binding) || MultiPoint.class.isAssignableFrom(binding)) { return point(DEFAULT_BORDER, DEFAULT_FILL); } if (LineString.class.isAssignableFrom(binding) || MultiLineString.class.isAssignableFrom(binding) || LinearRing.class.isAssignableFrom(binding)) { return line(DEFAULT_BORDER, 1); } if (Polygon.class.isAssignableFrom(binding) || MultiPolygon.class.isAssignableFrom(binding)) { return polygon(DEFAULT_BORDER, DEFAULT_FILL, 1); } return geometry(DEFAULT_BORDER, DEFAULT_FILL); } }
Geometry convertGeometry( Geometry geom, GeometryDescriptor descriptor, GeometryFactory factory) { // if the geometry is null no need to convert it if (geom == null) { return null; } // grab the binding Class targetClazz = descriptor.getType().getBinding(); // in Oracle you can have polygons in a column declared to be multipolygon, and so on... // so we better convert geometries, since our feature model is not so lenient if (targetClazz.equals(MultiPolygon.class) && geom instanceof Polygon) { return factory.createMultiPolygon(new Polygon[] {(Polygon) geom}); } else if (targetClazz.equals(MultiPoint.class) && geom instanceof Point) { return factory.createMultiPoint(new Point[] {(Point) geom}); } else if (targetClazz.equals(MultiLineString.class) && geom instanceof LineString) { return factory.createMultiLineString(new LineString[] {(LineString) geom}); } else if (targetClazz.equals(GeometryCollection.class)) { return factory.createGeometryCollection(new Geometry[] {geom}); } return geom; }
@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); }
/** * The query that defines this readers interaction with an ArcSDE instance. * * @param query the {@link SeQuery} wrapper where to fetch rows from. Must NOT be already {@link * ArcSDEQuery#execute() executed}. * @param geometryFactory the JTS GeometryFactory to use when creating Feature geometries * @param session the session the <code>query</code> is being ran over. This attribute reader * will close it only if it does not have a transaction in progress. * @throws IOException */ @SuppressWarnings("unchecked") public ArcSDEAttributeReader( final ArcSDEQuery query, final GeometryFactory geometryFactory, final ISession session) throws IOException { this.query = query; this.session = session; this.fidReader = query.getFidReader(); this.schema = query.getSchema(); this.geometryFactory = geometryFactory; String typeName = schema.getTypeName(); this.fidPrefix = new StringBuffer(typeName).append('.'); this.fidPrefixLen = this.fidPrefix.length(); final GeometryDescriptor geomType = schema.getGeometryDescriptor(); if (geomType != null) { this.schemaGeometryClass = (Class<? extends Geometry>) geomType.getType().getBinding(); } else { this.schemaGeometryClass = null; } query.execute(); }
if ((geometryAttrType.getType().getBinding() == MultiPolygon.class) || (geometryAttrType.getType().getBinding() == Polygon.class)) { Fill fill = sb.createFill(color, opacity); symb = sb.createPolygonSymbolizer(defaultStroke, fill); } else if (geometryAttrType.getType().getBinding() == LineString.class) { symb = sb.createLineSymbolizer(color); } else if ((geometryAttrType.getType().getBinding() == MultiPoint.class) || (geometryAttrType.getType().getBinding() == Point.class)) { Fill fill = sb.createFill(color, opacity); Mark square = sb.createMark(StyleBuilder.MARK_SQUARE, fill, defaultStroke);
private void buildType() { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName("feature"); typeBuilder.setNamespaceURI("http://geotools.org"); if (geom != null) { typeBuilder.add(geom.getLocalName(), geom.getType().getBinding(), crs); } if (propertyTypes != null) { Set<Entry<String, Class<?>>> entrySet = propertyTypes.entrySet(); for (Entry<String, Class<?>> entry : entrySet) { Class<?> binding = entry.getValue(); if (binding.equals(Object.class)) { binding = String.class; } typeBuilder.add(entry.getKey(), binding); } } if (crs != null) { typeBuilder.setCRS(crs); } featureType = typeBuilder.buildFeatureType(); }
sql.append("),'base64')"); } else { if (NON_CURVED_GEOMETRY_CLASSES.contains(gatt.getType().getBinding())) { sql.append("encode(ST_AsBinary(ST_Simplify(" + getForce2DFunction() + "("); encodeColumnName(prefix, gatt.getLocalName(), sql);
/** * {@inheritDoc} The {@code layer} argument must be an instance of {@linkplain FeatureLayer}. */ @Override public void setLayer(Layer layer) { if (!(layer instanceof FeatureLayer)) { throw new IllegalArgumentException("layer must be an instance of FeatureLayer"); } super.setLayer(layer); GeometryDescriptor geomDesc = layer.getFeatureSource().getSchema().getGeometryDescriptor(); attrName = geomDesc.getLocalName(); Class<? extends Geometry> geomClass = (Class<? extends Geometry>) geomDesc.getType().getBinding(); geomType = Geometries.getForBinding(geomClass); }
@Override protected SimpleFeatureType buildFeatureType() throws IOException { List<AttributeDescriptor> types = readAttributes(); SimpleFeatureType parent = null; GeometryDescriptor geomDescriptor = (GeometryDescriptor) types.get(0); Class<?> geomBinding = geomDescriptor.getType().getBinding(); if ((geomBinding == Point.class) || (geomBinding == MultiPoint.class)) { parent = BasicFeatureTypes.POINT; } else if ((geomBinding == Polygon.class) || (geomBinding == MultiPolygon.class)) { parent = BasicFeatureTypes.POLYGON; } else if ((geomBinding == LineString.class) || (geomBinding == MultiLineString.class)) { parent = BasicFeatureTypes.LINE; } SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setDefaultGeometry(geomDescriptor.getLocalName()); builder.addAll(types); builder.setName(entry.getName()); builder.setAbstract(false); if (parent != null) { builder.setSuperType(parent); } return builder.buildFeatureType(); }
static AttributeDescriptor getIntersectionType( SimpleFeatureCollection first, SimpleFeatureCollection second) { Class firstGeomType = first.getSchema().getGeometryDescriptor().getType().getBinding(); Class secondGeomType = second.getSchema().getGeometryDescriptor().getType().getBinding(); // figure out the output geometry type Class binding; if (isGeometryTypeIn(secondGeomType, Point.class)) { binding = Point.class; } else if (isGeometryTypeIn(secondGeomType, MultiPoint.class)) { binding = MultiPoint.class; } else if (isGeometryTypeIn(secondGeomType, LineString.class, MultiLineString.class)) { binding = MultiLineString.class; } else if (isGeometryTypeIn(secondGeomType, Polygon.class, MultiPolygon.class)) { if (isGeometryTypeIn(firstGeomType, Polygon.class, MultiPolygon.class)) { binding = MultiPolygon.class; } else { binding = MultiLineString.class; } } else { // we can't be more precise than this binding = Geometry.class; } AttributeTypeBuilder builder = new AttributeTypeBuilder(); builder.setName("the_geom"); builder.setBinding(binding); builder.setCRS(first.features().next().getFeatureType().getCoordinateReferenceSystem()); AttributeDescriptor descriptor = builder.buildDescriptor("the_geom"); return descriptor; }
private GeometryDescriptor reprojectGeometry(GeometryDescriptor descr) { if (descr == null) { return null; } GeometryType type = ftf.createGeometryType( descr.getType().getName(), descr.getType().getBinding(), reprojection, descr.getType().isIdentified(), descr.getType().isAbstract(), descr.getType().getRestrictions(), descr.getType().getSuper(), descr.getType().getDescription()); type.getUserData().putAll(descr.getType().getUserData()); GeometryDescriptor gd = ftf.createGeometryDescriptor( type, descr.getName(), descr.getMinOccurs(), descr.getMaxOccurs(), descr.isNillable(), descr.getDefaultValue()); gd.getUserData().putAll(descr.getUserData()); return gd; }
protected Class checkGeometryType(Class geomClass) throws Exception { // we just prefix the table name with "t" otherwise we go beyond // the Oracle identifier max length limit (oh my my...) String featureTypeName = tname("t" + geomClass.getSimpleName()); // create a featureType and write it to PostGIS CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName(featureTypeName); ftb.add(aname("id"), Integer.class); ftb.add(aname("name"), String.class); ftb.add(aname("geom"), geomClass, crs); SimpleFeatureType newFT = ftb.buildFeatureType(); dataStore.createSchema(newFT); SimpleFeatureType newSchema = dataStore.getSchema(featureTypeName); assertNotNull(newSchema); assertEquals(3, newSchema.getAttributeCount()); return newSchema.getGeometryDescriptor().getType().getBinding(); } }
tb.add(geometryType.getLocalName(), geometryType.getType().getBinding()); } else { tb.add(attributeType);