private SimpleFeatureType reType(SimpleFeatureType type, CoordinateReferenceSystem target) {
   try {
     return FeatureTypes.transform(type, target);
   } catch (SchemaException e) {
     throw new IllegalArgumentException("Could not transform source schema", e);
   }
 }
예제 #2
0
 static {
   SimpleFeatureType featureType = null;
   try {
     featureType =
         FeatureTypes.newFeatureType(null, "Feature", new URI("http://www.opengis.net/gml"), true);
   } catch (Exception e) {
     // shold not happen
   }
   ABSTRACT_FEATURE_TYPE = featureType;
 }
 /**
  * Quick heuristic used to find a small attribute to use when scanning over the entire collection
  * just to get the size of the collection. The result is indicative, just an heuristic to quickly
  * compare attributes in order to find a suitably small one, it's not meant to be the actual size
  * of an attribute in bytes.
  *
  * @param ad
  * @return
  */
 int size(AttributeDescriptor ad) {
   Class<?> binding = ad.getType().getBinding();
   if (binding.isPrimitive()
       || Number.class.isAssignableFrom(binding)
       || Date.class.isAssignableFrom(binding)) {
     return 4;
   } else if (binding.equals(String.class)) {
     int fieldLen = FeatureTypes.getFieldLength(ad);
     if (fieldLen > 0) {
       return fieldLen * 2;
     } else {
       return Integer.MAX_VALUE;
     }
   } else if (Point.class.isAssignableFrom(binding)) {
     return 4 * 3;
   } else {
     return Integer.MAX_VALUE;
   }
 }
예제 #4
0
  /**
   * Filters the feature type styles of <code>style</code> returning only those that apply to <code>
   * featureType</code>
   *
   * <p>This methods returns feature types for which <code>featureTypeStyle.getFeatureTypeName()
   * </code> matches the name of the feature type of <code>featureType</code>, or matches the name
   * of any parent type of the feature type of <code>featureType</code>. This method returns an
   * empty array in the case of which no rules match.
   *
   * @param style The style containing the feature type styles.
   * @param featureType The feature type being filtered against.
   */
  public static FeatureTypeStyle[] filterFeatureTypeStyles(Style style, SimpleFeatureType ftype) {
    List<FeatureTypeStyle> featureTypeStyles = style.featureTypeStyles();

    if (featureTypeStyles == null || featureTypeStyles.isEmpty()) {
      return new FeatureTypeStyle[0];
    }

    ArrayList<FeatureTypeStyle> filtered =
        new ArrayList<FeatureTypeStyle>(featureTypeStyles.size());
    for (FeatureTypeStyle fts : featureTypeStyles) {
      String ftName = fts.getFeatureTypeName();

      // yeah, ugly, but exactly the same code as the streaming renderer... we should
      // really factor out this style massaging in a delegate object (StyleOverlord)
      if (fts.featureTypeNames().isEmpty()
          || ((ftype.getName().getLocalPart() != null)
              && (ftype.getName().getLocalPart().equalsIgnoreCase(ftName)
                  || FeatureTypes.isDecendedFrom(ftype, null, ftName)))) {
        filtered.add(fts);
      }
    }

    return (FeatureTypeStyle[]) filtered.toArray(new FeatureTypeStyle[filtered.size()]);
  }