Examples of GeometryDescriptor


Examples of org.opengis.feature.type.GeometryDescriptor

                    return geom.getShell();
                }
            }
            if (!cycleGeom) {
                SimpleFeatureType featureType = editLayer.getSchema();
                GeometryDescriptor defaultGeometryType = featureType.getGeometryDescriptor();
                Class< ? > type = defaultGeometryType.getType().getBinding();
                boolean polygonLayer=Polygon.class.isAssignableFrom(type) || MultiPolygon.class.isAssignableFrom(type);
                ClosestEdge edge = geom.getShell().getClosestEdge(Point.valueOf(e.x, e.y), polygonLayer);
                if (edge != null &&
                        edge.getDistanceToEdge() <= PreferenceUtil.instance().getVertexRadius()){
                    return geom.getShell();
View Full Code Here

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

Examples of org.opengis.feature.type.GeometryDescriptor

        // 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

Examples of org.opengis.feature.type.GeometryDescriptor

        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

Examples of org.opengis.feature.type.GeometryDescriptor

                            } 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

Examples of org.opengis.feature.type.GeometryDescriptor

    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

Examples of org.opengis.feature.type.GeometryDescriptor

  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

Examples of org.opengis.feature.type.GeometryDescriptor

    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

Examples of org.opengis.feature.type.GeometryDescriptor

                          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

Examples of org.opengis.feature.type.GeometryDescriptor

  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
TOP
Copyright © 2018 www.massapi.com. 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.