Package org.opengis.feature.type

Examples of org.opengis.feature.type.GeometryDescriptor


    }

    public static ImageDescriptor generateStyledIcon( ILayer layer, Rule rule ) {
        if (layer.hasResource(FeatureSource.class) && rule != null) {
            SimpleFeatureType type = layer.getSchema();
            GeometryDescriptor geom = type.getGeometryDescriptor();
            if (geom != null) {
                Class geom_type = geom.getType().getBinding();
                if (geom_type == Point.class || geom_type == MultiPoint.class) {
                    return Glyph.point(rule);
                } else if (geom_type == LineString.class || geom_type == MultiLineString.class) {
                    return Glyph.line(rule);
                } else if (geom_type == Polygon.class || geom_type == MultiPolygon.class) {
View Full Code Here


        // lets try for featuretype based glyph
        //
        if (layer.hasResource(FeatureSource.class)) {

            SimpleFeatureType type = layer.getSchema();
            GeometryDescriptor geom = type.getGeometryDescriptor();
            if (geom != null) {
                Class geom_type = geom.getType().getBinding();
                if (geom_type == Point.class || geom_type == MultiPoint.class) {
                    return Glyph.point(null, null);
                } else if (geom_type == LineString.class || geom_type == MultiLineString.class) {
                    return Glyph.line(null, SLDs.NOTFOUND);
                } else if (geom_type == Polygon.class || geom_type == MultiPolygon.class) {
View Full Code Here

        for( int i = 0; i < schema.getAttributeCount(); i++ ) {
            AttributeDescriptor attribute = schema.getDescriptor(i);
            if (!(attribute instanceof GeometryDescriptor)) {
                builder.add(attribute);
            } else {
                GeometryDescriptor geom = schema.getGeometryDescriptor();
                builder.crs(crs).defaultValue(null).restrictions(geom.getType().getRestrictions())
                        .nillable(geom.isNillable()).add(geom.getLocalName(), geomBinding);
            }
        }

        return builder.buildFeatureType();
    }
View Full Code Here

                            } catch (TransformException e) {
                                throw (RuntimeException) new RuntimeException(
                                        Messages.ReprojectingFeatureCollection_transformationError + next.getID()).initCause(e);
                            }
                    }
                    GeometryDescriptor defaultGeometry2 = featureType.getGeometryDescriptor();
                    Name name = defaultGeometry2.getName();
                    String localPart = name.getLocalPart();
                    feature = new FeatureWrapper(next, featureType, new Geometry[]{geometry},
                                new String[]{ localPart});
                }
                return feature!=null;
View Full Code Here

    SimpleFeatureTypeBuilder builder;

    builder = new SimpleFeatureTypeBuilder();
    builder.setName(typeName);
    List<AttributeDescriptor> attributes = prototype.getAttributeDescriptors();
    GeometryDescriptor defaultGeometry = prototype.getGeometryDescriptor();

    for (int i = 0; i < attributes.size(); i++) {

      AttributeDescriptor att = attributes.get(i);

      if (att == defaultGeometry) {
        if (att.getType().getBinding() != MultiPolygon.class && att.getType().getBinding() != Polygon.class) {

          Class<?> targetGeomType = Polygon.class;
          final Class<?> sourceGeomClass = defaultGeometry.getType().getBinding();
          if (GeometryCollection.class.isAssignableFrom(sourceGeomClass)) {

            targetGeomType = MultiPolygon.class;
          }
          final String geomTypeName = att.getLocalName();
          CoordinateReferenceSystem crs = defaultGeometry.getCoordinateReferenceSystem();

          AttributeTypeBuilder build = new AttributeTypeBuilder();
          build.setName(geomTypeName);
          build.setBinding(targetGeomType);
          build.setNillable(true);
View Full Code Here

  public static SimpleFeatureType createFeatureTypefinal SimpleFeatureType prototype,
                            final String typeName,
                            final CoordinateReferenceSystem crs) throws SchemaException {

    assert prototype != null : "prototype can be null";
    GeometryDescriptor geomAttrType = prototype.getGeometryDescriptor();

    assert geomAttrType != null : "the Geometry Class can be null";
    Class<? extends Geometry> geomClass = (Class<? extends Geometry>) geomAttrType.getType().getBinding();

    return createFeatureType(prototype, typeName, crs, geomClass);
  }
View Full Code Here

    SimpleFeatureTypeBuilder builder;
    builder = new SimpleFeatureTypeBuilder();
    builder.setName(typeName);

    List<AttributeDescriptor> attributes = prototype.getAttributeDescriptors();
    GeometryDescriptor defaultGeomAttr = prototype.getGeometryDescriptor();

    assert defaultGeomAttr != null : "default geometry was expected"; //$NON-NLS-1$

    // adds all attributes without default geometry
    for (int i = 0; i < attributes.size(); i++) {
      AttributeDescriptor att = attributes.get(i);
      if (att != defaultGeomAttr) {
        builder.add(att);
      }
    }
    // create the default geometry with Geometry Class value
    AttributeTypeBuilder build = new AttributeTypeBuilder();
    build.setName(defaultGeomAttr.getLocalName());
    build.setNillable(true);
    build.setBinding(geometryClass);
    build.setCRS(crs);

    GeometryType type = build.buildGeometryType();

    builder.setDefaultGeometry(build.buildDescriptor(defaultGeomAttr.getLocalName(), type).getLocalName());

    builder.add(defaultGeomAttr.getLocalName(), geometryClass, crs);

    return builder.buildFeatureType();

  }
View Full Code Here

                          final SimpleFeatureType targetType,
                          final Geometry newGeometry) throws IllegalAttributeException {

    try {
      SimpleFeature newFeature = DataUtilities.template(targetType);
      final GeometryDescriptor targetGeometryType = targetType.getGeometryDescriptor();
      final String geoAttName = targetGeometryType.getLocalName();
      List<String> omitAttr = new ArrayList<String>(1);
      omitAttr.add(geoAttName);

      newFeature = FeatureUtil.copyAttributesOmitting(sourceFeature, newFeature, omitAttr);

      final Class<? extends Geometry> geomClass = (Class<? extends Geometry>) targetGeometryType.getType()
            .getBinding();
      final Geometry adaptedGeometry = GeometryUtil.adapt(newGeometry, geomClass);

      newFeature.setAttribute(geoAttName, adaptedGeometry);
View Full Code Here

  public static SimpleFeature createFeatureWithGeometry(final SimpleFeatureType type, Geometry geometry) {

    SimpleFeature newFeature;
    try {
      newFeature = DataUtilities.template(type);
      final GeometryDescriptor targetGeometryType = type.getGeometryDescriptor();

      final String attGeomName = targetGeometryType.getLocalName();
      final Class<? extends Geometry> geomClass = (Class<? extends Geometry>) targetGeometryType.getType()
            .getBinding();
      Geometry geoAdapted = GeometryUtil.adapt(geometry, geomClass);
     
      newFeature.setAttribute(attGeomName, geoAdapted);
View Full Code Here

      return;
    }
   
    ISelection selection = window.getSelectionService().getSelection();
   
    GeometryDescriptor geom = findGeometryType(selection);
   
    if( geom==null ){
        IMap map = ApplicationGIS.getActiveMap();
        if( map==ApplicationGIS.NO_MAP ){
            return;
        }
       
        IEditManager editManager = map.getEditManager();
        if( editManager == null ){
            return;
        }
            ILayer selectedLayer = editManager.getSelectedLayer();
            if( selectedLayer == null ){
                return;
            }
            SimpleFeatureType schema = selectedLayer.getSchema();
        if( schema ==null ){
            return;
        }
        geom = schema.getGeometryDescriptor();       
    }   
    FeatureTypeEditor editor = dialog.getEditor();
        SimpleFeatureType ft = editor.createDefaultFeatureType();
        SimpleFeatureTypeBuilder builder = editor.builderFromFeatureType(ft);
        String defaultGeometry = ft.getGeometryDescriptor().getLocalName();
        if( defaultGeometry == null ){
            return;
        }
        builder.remove(defaultGeometry);
        builder.add(geom);
        builder.setDefaultGeometry(geom.getLocalName());
        dialog.setDefaultFeatureType(builder.buildFeatureType());
  }
View Full Code Here

TOP

Related Classes of org.opengis.feature.type.GeometryDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.