Convert the given feature object to a {@link SimpleFeature}.

@param possibleFeature feature object to convert
@return converted feature
@throws LayerException object could not be converted
185058
protected SimpleFeature asFeature(Object possibleFeature) throws LayerException {
		if (possibleFeature instanceof SimpleFeature) {
			return (SimpleFeature) possibleFeature;
		} else {
			throw new LayerException(ExceptionCode.INVALID_FEATURE_OBJECT, possibleFeature.getClass().getName());
		}
	}
465416
private static Map<VectorLayer, List<Feature>> convertFromDto(
			Map<String, List<org.geomajas.layer.feature.Feature>> dtoFeatures, MapModel model) {
		Map<VectorLayer, List<Feature>> result = new LinkedHashMap<VectorLayer, List<Feature>>();
		for (Entry<String, List<org.geomajas.layer.feature.Feature>> entry : dtoFeatures.entrySet()) {
			if (!entry.getValue().isEmpty()) {
				List<Feature> convertedFeatures = new ArrayList<Feature>();
				VectorLayer layer = convertFromDto(entry.getKey(), entry.getValue(), convertedFeatures, model);
				if (layer != null) {
					result.put(layer, convertedFeatures);
				} else {
					// TODO couldn't find layer client-side ?? maybe should throw an error here
					GWT.log("Couldn't find layer client-side ?? " + entry.getKey());
				}
			}
		}
		return result;
	}
127457
public boolean selectFeature(Feature feature) {
		if (!selectedFeatures.containsKey(feature.getId())) {
			// make sure we get the layer's instance (if we can find it) !
			Feature layerFeature = getFeatureStore().getPartialFeature(feature.getId());
			if (null != layerFeature) {
				selectedFeatures.put(layerFeature.getId(), layerFeature);
				handlerManager.fireEvent(new FeatureSelectedEvent(layerFeature));
			} else {
				selectedFeatures.put(feature.getId(), feature);
				handlerManager.fireEvent(new FeatureSelectedEvent(feature));
			}
			return true;
		} else {
			return false;
		}
	}
125093
@VisibleForTesting
  public FeatureSet with(FeatureSet newFeatures) {
    return new FeatureSet(union(features, newFeatures.features));
  }
787872
public int getFeaturePosition(AbstractFeature feature) {
        AbstractFeature result = feature;
        if (!featurePositions.containsKey(feature)) {
            if (feature instanceof FeatureGroup) {
                FeatureGroup featureGroup = (FeatureGroup) feature;
                List<Feature> features = featureGroup.getConcreteFeatures();
                if (!features.isEmpty()) {
                    Collections.sort(features, new Comparator<Feature>() {
                        @Override
                        public int compare(Feature feat1, Feature feat2) {
                            return getFeaturePosition(feat1) - getFeaturePosition(feat2);
                        }
                    });
                    result = features.get(0);
                }
            }
        }
        return featurePositions.getOrDefault(result, 0);
    }
868827
public static SimpleFeatureType createGridFeatureType(
            @Nonnull final MapfishMapContext mapContext,
            @Nonnull final Class<? extends Geometry> geomClass) {
        final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
        CoordinateReferenceSystem projection = mapContext.getBounds().getProjection();
        typeBuilder.add(Constants.Style.Grid.ATT_GEOM, geomClass, projection);
        typeBuilder.setName(Constants.Style.Grid.NAME_LINES);

        return typeBuilder.buildFeatureType();
    }
1365953
public final SimpleFeatureCollection autoTreat(final Template template, final String features)
            throws IOException {
        SimpleFeatureCollection featuresCollection = treatStringAsURL(template, features);
        if (featuresCollection == null) {
            featuresCollection = treatStringAsGeoJson(features);
        }
        return featuresCollection;
    }
602111
@Api
	public void zoomToFeatures(List<Feature> features) {
		// calculate the point scale as the minimum point scale for all layers (only relevant for zooming to multiple
		// points at the exact same location)
		double zoomToPointScale = getMapInfo().getScaleConfiguration().getMaximumScale().getPixelPerUnit();
		for (Feature feature : features) {
			double scale = feature.getLayer().getLayerInfo().getZoomToPointScale().getPixelPerUnit();
			zoomToPointScale = Math.min(zoomToPointScale,  scale);
		}
		ZoomToFeaturesLazyLoadCallback callback = new ZoomToFeaturesLazyLoadCallback(features.size(), 
				zoomToPointScale);
		for (Feature feature : features) {
			// no need to fetch if we already have the geometry !
			if (feature.isGeometryLoaded()) {
				callback.execute(Arrays.asList(feature));
			} else {
				feature.getLayer().getFeatureStore()
						.getFeature(feature.getId(), GeomajasConstant.FEATURE_INCLUDE_GEOMETRY, callback);			
			}
		}
	}
173759
public Feature getFeature() {
		for (AttributeInfo info : layer.getLayerInfo().getFeatureInfo().getAttributes()) {
			featureForm.fromForm(info.getName(), feature.getAttributes().get(info.getName()));
		}
		return feature;
	}
1060364
public Feature nextFeature() {
	Feature f = null;
    
	if (hasNextSFeature()) {
	    f = nextSFeature();
	} else if (hasNextEFeature()) {
	    f = nextEFeature();
	} else {
	    // do nothing
	}
	
	return f;
    }
1317319
public static FeatureCollection fromFeature(@NonNull Feature feature) {
    List<Feature> featureList = Arrays.asList(feature);
    return new FeatureCollection(TYPE, null, featureList);
  }
390509
public FeatureCollection createCollection(JSONObject jsonObject, FeaturesSupported layer) {
		FeatureCollection dto = new FeatureCollection(layer);
		String type = JsonService.getStringValue(jsonObject, "type");
		if ("FeatureCollection".equals(type)) {
			JSONArray features = JsonService.getChildArray(jsonObject, "features");
			for (int i = 0; i < features.size(); i++) {
				dto.getFeatures().add(createFeature((JSONObject) features.get(i), layer));
			}
		} else if ("Feature".equals(type)) {
			dto.getFeatures().add(createFeature(jsonObject, layer));
		}
		return dto;
	}
569781
public SimpleFeature convertDwgPoint( String typeName, String layerName, DwgPoint point, int id ) {
        double[] p = point.getPoint();
        Point2D pto = new Point2D.Double(p[0], p[1]);

        CoordinateList coordList = new CoordinateList();
        Coordinate coord = new Coordinate(pto.getX(), pto.getY(), 0.0);
        coordList.add(coord);

        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName(typeName);
        b.setCRS(crs);
        b.add(THE_GEOM, MultiPoint.class);
        b.add(LAYER, String.class);
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        Geometry points = gF.createMultiPoint(coordList.toCoordinateArray());
        Object[] values = new Object[]{points, layerName};
        builder.addAll(values);
        return builder.buildFeature(typeName + "." + id);
    }
656257
public SimpleFeatureCollection areaToFeatureCollection(
            @Nonnull final MapAttribute.MapAttributeValues mapAttributes) {
        Assert.isTrue(mapAttributes.areaOfInterest == this,
                      "map attributes passed in does not contain this area of interest object");

        final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
        typeBuilder.setName("aoi");
        CoordinateReferenceSystem crs = mapAttributes.getMapBounds().getProjection();
        typeBuilder.add("geom", this.polygon.getClass(), crs);
        final SimpleFeature feature =
                SimpleFeatureBuilder.build(typeBuilder.buildFeatureType(), new Object[]{this.polygon}, "aoi");
        final DefaultFeatureCollection features = new DefaultFeatureCollection();
        features.add(feature);
        return features;
    }
993879
public SimpleFeatureCollection toFeatureCollection() {
        checkTinGeometries();
        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName("triangle");
        b.setCRS(crs);

        DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
        b.add("the_geom", Polygon.class);
        b.add("elev0", Double.class);
        b.add("elev1", Double.class);
        b.add("elev2", Double.class);
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        for( Geometry g : tinGeometries ) {
            Coordinate[] coordinates = g.getCoordinates();

            Object[] values;
            int windingRule = GeometryUtilities.getTriangleWindingRule(coordinates[0], coordinates[1], coordinates[2]);
            if (windingRule > 0) {
                // need to reverse the triangle
                values = new Object[]{g, coordinates[0].z, coordinates[2].z, coordinates[1].z};
            } else {
                values = new Object[]{g, coordinates[0].z, coordinates[1].z, coordinates[2].z};
            }

            builder.addAll(values);
            SimpleFeature feature = builder.buildFeature(null);
            newCollection.add(feature);
        }
        return newCollection;
    }
453325
@PostConstruct
	protected void initFeatures() throws LayerException {
		if (null == layerInfo) {
			return;
		}
		crs = geoService.getCrs2(layerInfo.getCrs());
		setFeatureSourceName(layerInfo.getFeatureInfo().getDataSourceName());
		try {
			if (null == super.getDataStore()) {
				Map<String, Object> params = new HashMap<String, Object>();
				if (null != url) {
					params.put(ShapefileDataStoreFactory.URLP.key, url);
				}
				if (null != dbtype) {
					params.put(JDBCDataStoreFactory.DBTYPE.key, dbtype);
				}
				if (null != parameters) {
					for (Parameter parameter : parameters) {
						params.put(parameter.getName(), parameter.getValue());
					}
				}
				if (null != dataSource) {
					params.put(JDBCDataStoreFactory.DATASOURCE.key, dataSource);
					// these are apparently required but not used
					params.put(JDBCDataStoreFactory.DATABASE.key, "some_database");
					params.put(JDBCDataStoreFactory.USER.key, "some_user");
					params.put(JDBCDataStoreFactory.PASSWD.key, "some_password");
					params.put(JDBCDataStoreFactory.HOST.key, "some host");
					params.put(JDBCDataStoreFactory.PORT.key, "0");
				}
				DataStore store = DataStoreFactory.create(params);
				super.setDataStore(store);
			}
			if (null == super.getDataStore()) {
				return;
			}
			this.featureModel = new GeoToolsFeatureModel(super.getDataStore(), layerInfo.getFeatureInfo()
					.getDataSourceName(), geoService.getSridFromCrs(layerInfo.getCrs()), converterService);
			featureModel.setLayerInfo(layerInfo);
			featureModelUsable = true;

		} catch (IOException ioe) {
			if (MAGIC_STRING_LIBRARY_MISSING.equals(ioe.getMessage())) {
				throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION, url);
			} else {
				featureModelUsable = false;
				log.warn("The layer could not be correctly initialized: " + getId(), ioe);
			}
		} catch (LayerException le) {
			featureModelUsable = false;
			log.warn("The layer could not be correctly initialized: " + getId(), le);
		} catch (RuntimeException e) {
			featureModelUsable = false;
			log.warn("The layer could not be correctly initialized: " + getId(), e);
		}
	}
1344831
def fromFeatureClass(fc, paramName):
        
        from ..common.spatial import featureclass_to_json
        val = json.loads(featureclass_to_json(fc))
        v = GPFeatureRecordSetLayer()
        v.value = val
        v.paramName = paramName
        return v