Refine search
throws SQLException { schemaName = schemaName != null ? schemaName : "public"; String tableName = featureType.getName().getLocalPart(); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { if (att instanceof GeometryDescriptor) { GeometryDescriptor gd = (GeometryDescriptor) att; if (gd.getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID) != null) { srid = (Integer) gd.getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID); } else if (gd.getCoordinateReferenceSystem() != null) { try { Integer result = String geomType = CLASS_TO_TYPE_MAP.get(gd.getType().getBinding()); if (geomType == null) { geomType = "GEOMETRY";
public CoordinateReferenceSystem getCoordinateReferenceSystem() { if (crs == null) { if (getGeometryDescriptor() != null && getGeometryDescriptor().getType().getCoordinateReferenceSystem() != null) { crs = defaultGeometry.getType().getCoordinateReferenceSystem(); } if (crs == null) { for (PropertyDescriptor property : getDescriptors()) { if (property instanceof GeometryDescriptor) { GeometryDescriptor geometry = (GeometryDescriptor) property; if (geometry.getType().getCoordinateReferenceSystem() != null) { crs = geometry.getType().getCoordinateReferenceSystem(); break; } } } } } return crs; }
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; }
public String toString() { StringBuffer sb = new StringBuffer(getClass().getSimpleName()).append(":"); sb.append(getDescriptor().getName().getLocalPart()); CoordinateReferenceSystem crs = getDescriptor().getType().getCoordinateReferenceSystem(); if (!getDescriptor() .getName() .getLocalPart() .equals(getDescriptor().getType().getName().getLocalPart()) || id != null || crs != null) { sb.append("<"); sb.append(getDescriptor().getType().getName().getLocalPart()); if (id != null) { sb.append(" id=");
throws SchemaException { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName(schema.getTypeName()); tb.setNamespaceURI(schema.getName().getNamespaceURI()); tb.setAbstract(schema.isAbstract()); for (int i = 0; i < schema.getAttributeCount(); i++) { if (!forceOnlyMissing || geometryType.getCoordinateReferenceSystem() == null) { tb.crs(crs); tb.add(geometryType.getLocalName(), geometryType.getType().getBinding()); } else { tb.add(attributeType);
/** * 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(); }
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); } }
@Test public void testParseStreamsGML3() throws Exception { File file = new File( "./src/test/resources/org/geoserver/importer/test-data/gml/streams.gml3.gml"); SimpleFeatureType schema = gmlFileFormat.getSchema(file); assertEquals(MultiLineString.class, schema.getGeometryDescriptor().getType().getBinding()); assertEquals( CRS.decode("urn:x-ogc:def:crs:EPSG:26713"), schema.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals(Integer.class, schema.getDescriptor("cat").getType().getBinding()); } }
GeometryDescriptor desc = schema.getGeometryDescriptor(); Class<? extends Geometry> clazz = (Class<? extends Geometry>) desc.getType().getBinding(); geomType = Geometries.getForBinding(clazz); String labelText = schema.getTypeName(); fieldsForLabels = new String[schema.getAttributeCount() - 1];
throws SQLException, IOException { FeatureEntry fe = (FeatureEntry) featureType.getUserData().get(FeatureEntry.class); if (fe == null) { fe = new FeatureEntry(); fe.setIdentifier(featureType.getTypeName()); fe.setDescription(featureType.getTypeName()); fe.setTableName(featureType.getTypeName()); fe.setLastChange(new java.util.Date()); GeometryDescriptor gd = featureType.getGeometryDescriptor(); if (gd != null) { fe.setGeometryColumn(gd.getLocalName()); fe.setGeometryType(Geometries.getForBinding((Class) gd.getType().getBinding())); if (descr instanceof GeometryDescriptor) { GeometryDescriptor gd1 = (GeometryDescriptor) descr; if (!(gd1.getLocalName()).equals(fe.getGeometryColumn())) { FeatureEntry fe1 = new FeatureEntry(); fe1.init(fe); fe1.setGeometryColumn(gd1.getLocalName()); fe1.setGeometryType( Geometries.getForBinding((Class) gd1.getType().getBinding())); geopkg.addGeometryColumnsEntry(fe1);
for (AttributeDescriptor ad : featureType.getAttributeDescriptors()) { if (!(ad instanceof GeometryDescriptor)) { continue; encodeTableName(featureType.getTypeName(), sql); sql.append(" ADD SPATIAL INDEX ("); encodeColumnName(null, gd.getLocalName(), sql); sql.append(")"); CoordinateReferenceSystem crs = gd.getCoordinateReferenceSystem(); int srid = -1; if (crs != null) { sql.append(" VALUES ("); sql.append(schemaName != null ? "'" + schemaName + "'" : "NULL").append(", "); sql.append("'").append(featureType.getTypeName()).append("', "); sql.append("'").append(ad.getLocalName()).append("', "); sql.append("2, "); Geometries.getForBinding((Class<? extends Geometry>) gd.getType().getBinding()); sql.append("'").append(g != null ? g.getName().toUpperCase() : "GEOMETRY").append("')");
@Test public void testPlainFeatureType() { SimpleFeatureType sft = PlainFeatureFactory.createPlainFeatureType("MyPoint", Point.class, DefaultGeographicCRS.WGS84); assertEquals("MyPoint", sft.getTypeName()); assertNotNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY)); assertFalse(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY).isNillable()); assertNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY).getDefaultValue()); assertEquals(Point.class, sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY).getType().getBinding()); assertNotNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS)); assertTrue(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS).isNillable()); assertNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS).getDefaultValue()); assertSame(sft.getGeometryDescriptor(), sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY)); assertNotNull(sft.getGeometryDescriptor().getType()); assertSame(DefaultGeographicCRS.WGS84, sft.getCoordinateReferenceSystem()); assertSame(DefaultGeographicCRS.WGS84, sft.getGeometryDescriptor().getCoordinateReferenceSystem()); assertSame(DefaultGeographicCRS.WGS84, sft.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); }
@Test public void testBuildFeatureType() { String input = CSVTestStrategySupport.buildInputString("lat,lon,quux,morx\n"); CSVFileState fileState = new CSVFileState(input, "foo"); CSVLatLonStrategy strategy = new CSVLatLonStrategy(fileState); SimpleFeatureType featureType = strategy.getFeatureType(); assertEquals("Invalid attribute count", 3, featureType.getAttributeCount()); assertEquals("Invalid featuretype name", "foo", featureType.getName().getLocalPart()); assertEquals("Invalid name", "foo", featureType.getTypeName()); List<AttributeDescriptor> attrs = featureType.getAttributeDescriptors(); assertEquals("Invalid number of attributes", 3, attrs.size()); List<String> attrNames = new ArrayList<String>(2); for (AttributeDescriptor attr : attrs) { if (!(attr instanceof GeometryDescriptor)) { attrNames.add(attr.getName().getLocalPart()); } } Collections.sort(attrNames); assertEquals("Invalid property descriptor", "morx", attrNames.get(0)); assertEquals("Invalid property descriptor", "quux", attrNames.get(1)); GeometryDescriptor geometryDescriptor = featureType.getGeometryDescriptor(); GeometryType geometryType = geometryDescriptor.getType(); assertEquals("Invalid geometry name", "location", geometryType.getName().getLocalPart()); }
assertNotNull(simpleFeatureType.getCoordinateReferenceSystem()); assertEquals("org.esa.beam.FT1", simpleFeatureType.getTypeName()); assertEquals(4, simpleFeatureType.getAttributeCount()); List<AttributeDescriptor> list = simpleFeatureType.getAttributeDescriptors(); GeometryDescriptor geometryDescriptor = simpleFeatureType.getGeometryDescriptor(); assertEquals("geom", geometryDescriptor.getType().getName().getLocalPart());
.getGeometryDescriptor(); .getAttributeDescriptors(); GeometryType geomType = null; List<AttributeDescriptor> attribs = new ArrayList<AttributeDescriptor>(); new NameImpl("the_geom"), geomType.getBinding(), geomType.getCoordinateReferenceSystem(), geomType.isIdentified(), geomType.isAbstract(), geomType.getRestrictions(), geomType.getSuper(), geomType.getDescription()); geom.getMinOccurs(), geom.getMaxOccurs(), geom.isNillable(), geom.getDefaultValue()); schema.getName(), attribs, geomDesc, schema.isAbstract(), schema.getRestrictions(), schema.getSuper(), schema.getDescription());
AttributeDescriptor descriptor = origional.getDescriptor(name); AttributeType attributeType = descriptor.getType(); binding = attributeType.getBinding(); AttributeType originalAttributeType = origional.getType(name); if (originalAttributeType != null && originalAttributeType instanceof GeometryType) { GeometryType geometryType = (GeometryType) originalAttributeType; crs = geometryType.getCoordinateReferenceSystem(); } else { crs = origional.getCoordinateReferenceSystem();
if (gd == null) return catalog.getStyleByName(StyleInfo.DEFAULT_POINT); Class gtype = gd.getType().getBinding(); StyleType st; if (LineString.class.isAssignableFrom(gtype)
/** * {@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); }
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; }
featureType.getGeometryDescriptor().getCoordinateReferenceSystem(); final Class<?> geomType = featureType.getGeometryDescriptor().getType().getBinding(); final ShapeType shapeType;