Utility to convert a featurecollection to a queryresult format.

@param featureCollection the collection to convert.
@return the queryresult object.
777549
public static QueryResult featureCollection2QueryResult( SimpleFeatureCollection featureCollection ) {
        List<AttributeDescriptor> attributeDescriptors = featureCollection.getSchema().getAttributeDescriptors();
        QueryResult queryResult = new QueryResult();
        int count = 0;
        for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
            if (!(attributeDescriptor instanceof GeometryDescriptor)) {
                String fieldName = attributeDescriptor.getLocalName();
                String type = attributeDescriptor.getType().getBinding().toString();
                queryResult.names.add(fieldName);
                queryResult.types.add(type);
                count++;
            }
        }

        SimpleFeatureIterator featureIterator = featureCollection.features();
        while( featureIterator.hasNext() ) {
            SimpleFeature f = featureIterator.next();

            Geometry geometry = (Geometry) f.getDefaultGeometry();
            queryResult.geometries.add(geometry);

            Object[] dataRow = new Object[count];
            int index = 0;
            for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
                if (!(attributeDescriptor instanceof GeometryDescriptor)) {
                    String fieldName = attributeDescriptor.getLocalName();
                    Object attribute = f.getAttribute(fieldName);
                    if (attribute == null) {
                        attribute = "";
                    }
                    dataRow[index++] = attribute;
                }
            }
            queryResult.data.add(dataRow);
        }

        return queryResult;
    }
163783
public static List<SimpleFeature> featureCollectionToList( SimpleFeatureCollection collection ) {
        List<SimpleFeature> featuresList = new ArrayList<SimpleFeature>();
        if (collection == null) {
            return featuresList;
        }
        SimpleFeatureIterator featureIterator = collection.features();
        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
            featuresList.add(feature);
        }
        featureIterator.close();
        return featuresList;
    }
1165015
public int getIndex(String feature)
	{
		//logger.debug("FeatureIndex.get : " + feature + "(" + count + ")");
		Integer index = (Integer) map.get(feature);

		if (index == null)
			return -1;

		return index.intValue();
	}
704515
@Override
    public final Object singleResult(DBCollection dbCollection) {
        MapReduceOutput output = dbCollection.mapReduce(createMapFunction(), createReduceFunction(), null, query);
        Iterable<DBObject> results = output.results();

        try {
            return transformToValue(results);
        } finally {
            output.drop();
        }
    }
742577
public ConversionType getConversionTypeFor(XAbstractFeatureCall featureCall) {
		if (this.conversions == null) {
			this.conversions = initMapping();
		}
		final List<Object> receiver = new ArrayList<>();
		AbstractExpressionGenerator.buildCallReceiver(
				featureCall,
				this.keywords.getThisKeywordLambda(),
				this.referenceNameLambda,
				receiver);
		final String simpleName = AbstractExpressionGenerator.getCallSimpleName(
				featureCall,
				this.logicalContainerProvider,
				this.simpleNameProvider,
				this.keywords.getNullKeywordLambda(),
				this.keywords.getThisKeywordLambda(),
				this.keywords.getSuperKeywordLambda(),
				this.referenceNameLambda2);
		final List<Pair<FeaturePattern, FeatureReplacement>> struct = this.conversions.get(getKey(simpleName));
		if (struct != null) {
			final String replacementId = featureCall.getFeature().getIdentifier();
			final FeatureReplacement replacement = matchFirstPattern(struct, replacementId, simpleName, receiver);
			if (replacement != null) {
				if (replacement.hasReplacement()) {
					return ConversionType.EXPLICIT;
				}
				return ConversionType.FORBIDDEN_CONVERSION;
			}
		}
		return ConversionType.IMPLICIT;
	}
922067
public FeatureIndexResults query(GeometryEnvelope envelope) {
		FeatureIndexResults results = null;
		switch (getIndexedType()) {
		case GEOPACKAGE:
			long count = featureTableIndex.count(envelope);
			CloseableIterator<GeometryIndex> geometryIndices = featureTableIndex
					.query(envelope);
			results = new FeatureIndexGeoPackageResults(featureTableIndex,
					count, geometryIndices);
			break;
		case RTREE:
			UserCustomResultSet resultSet = rTreeIndexTableDao.query(envelope);
			results = new FeatureIndexRTreeResults(rTreeIndexTableDao,
					resultSet);
			break;
		default:
			results = manualFeatureQuery.query(envelope);
		}
		return results;
	}
793800
public static SimpleFeatureCollection createFeatureCollection( SimpleFeature... features ) {
        DefaultFeatureCollection fcollection = new DefaultFeatureCollection();

        for( SimpleFeature feature : features ) {
            fcollection.add(feature);
        }
        return fcollection;
    }
507569
@Override
    public Map<String, FieldTypes> get(final Collection<String> fieldNames, Collection<String> indexNames) {
        // Shortcut - if we don't select any fields we don't have to do any database query
        if (fieldNames.isEmpty()) {
            return Collections.emptyMap();
        }

        // We have to transform the field type database entries to make them usable for the user.
        //
        // [
        //   {
        //     "index_name": "graylog_0",
        //     "fields": [
        //       {"field_name": "message", "physical_type": "text"},
        //       {"field_name": "source", "physical_type": "keyword"}
        //     ]
        //   },
        //   {
        //     "index_name": "graylog_1",
        //     "fields": [
        //       {"field_name": "message", "physical_type": "text"},
        //     ]
        //   }
        // ]
        //
        // gets transformed into
        //
        // {
        //   "message": {
        //     "field_name": "message",
        //     "types": [
        //       {
        //         "type": "string",
        //         "properties": ["full-text-search"],
        //         "index_names": ["graylog_0", "graylog_1"]
        //     ]
        //   },
        //   "source": {
        //     "field_name": "source",
        //     "types": [
        //       {
        //         "type": "string",
        //         "properties": ["enumerable"],
        //         "index_names": ["graylog_0"]
        //     ]
        //   }
        // }

        // field-name -> {physical-type -> [index-name, ...]}
        final Map<String, SetMultimap<String, String>> fields = new HashMap<>();

        // Convert the data from the database to be indexed by field name and physical type
        getTypesStream(fieldNames, indexNames).forEach(types -> {
            final String indexName = types.indexName();

            types.fields().forEach(fieldType -> {
                final String fieldName = fieldType.fieldName();
                final String physicalType = fieldType.physicalType();

                if (fieldNames.contains(fieldName)) {
                    if (indexNames.isEmpty() || indexNames.contains(indexName)) {
                        if (!fields.containsKey(fieldName)) {
                            fields.put(fieldName, HashMultimap.create());
                        }
                        fields.get(fieldName).put(physicalType, indexName);
                    }
                }
            });
        });

        final ImmutableMap.Builder<String, FieldTypes> result = ImmutableMap.builder();

        for (Map.Entry<String, SetMultimap<String, String>> fieldNameEntry : fields.entrySet()) {
            final String fieldName = fieldNameEntry.getKey();
            final Map<String, Collection<String>> physicalTypes = fieldNameEntry.getValue().asMap();

            // Use the field type mapper to do the conversion between the Elasticsearch type and our logical type
            final Set<FieldTypes.Type> types = physicalTypes.entrySet().stream()
                    .map(entry -> {
                        final String physicalType = entry.getKey();
                        final Set<String> indices = ImmutableSet.copyOf(entry.getValue());

                        return typeMapper.mapType(physicalType).map(t -> t.withIndexNames(indices));
                    })
                    .filter(Optional::isPresent)
                    .map(Optional::get)
                    .collect(Collectors.toSet());

            result.put(fieldName, FieldTypes.create(fieldName, types));
        }

        return result.build();
    }
1333915
private void iterateFeatures(VectorLayer layer, SnappingMode handler) {
		if (currentBounds != null && currentBounds.equals(mapModel.getMapView().getBounds(), 0)) {
			List<Feature> feats = featureCache.get(layer);
			if (feats != null) {
				handler.execute(feats);
			}
		} else {
			retrieveFeatures();
		}
	}
742153
public <C extends Feature> C get(Class<C> feature)
    {
        final Feature found = typeToFeature.get(feature);
        if (found != null)
        {
            return feature.cast(found);
        }
        throw new LionEngineException(ERROR_FEATURE_NOT_FOUND + feature.getName());
    }
802018
@SuppressWarnings("unchecked")
    protected Collection _transform(final Collection collection) {
        if (collection == null) return null;
        if (collection instanceof BeanCollection) return collection;
        return new BeanCollection(collection, this);
    }
1237836
function calculateBoundsForFeatureCollection(featureCollection){
    var extents = [], extent;
    for (var i = featureCollection.features.length - 1; i >= 0; i--) {
      extent = calculateBounds(featureCollection.features[i].geometry);
      extents.push([extent[0],extent[1]]);
      extents.push([extent[2],extent[3]]);
    }

    return calculateBoundsFromArray(extents);
  }
118348
@Override
    public FeatureCollector getCollector() {
        JiraMode mode = featureSettings.isJiraBoardAsTeam() ? JiraMode.Board : JiraMode.Team;
        FeatureCollector collector = FeatureCollector.prototype(mode);
        FeatureCollector existing = featureCollectorRepository.findByName(collector.getName());
        if (existing != null) {
            collector.setLastRefreshTime(existing.getLastRefreshTime());
        }
        return collector;
    }
44887
public static String JsonFromFeatureClass(EsriFeatureClass featureClass) throws JsonGenerationException, JsonMappingException, IOException{
		return jsonObjectMapper.writeValueAsString(featureClass);
	}
1108780
public static STRtree featureCollectionToSTRtree( SimpleFeatureCollection collection ) {
        STRtree tree = new STRtree();
        SimpleFeatureIterator featureIterator = collection.features();
        while( featureIterator.hasNext() ) {
            SimpleFeature feature = featureIterator.next();
            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            tree.insert(geometry.getEnvelopeInternal(), feature);
        }
        featureIterator.close();
        return tree;
    }
27976
def normalize_geojson_featurecollection(obj):
    
    if not isinstance(obj, Sequence):
        obj = [obj]

    features = []
    for x in obj:
        if not isinstance(x, Mapping) or 'type' not in x:
            raise ValueError(
                "Expecting a geojson-like mapping or sequence of them")

        if 'features' in x:
            features.extend(x['features'])
        elif 'geometry' in x:
            features.append(x)
        elif 'coordinates' in x:
            feat = {'type': 'Feature',
                    'properties': {},
                    'geometry': x}
            features.append(feat)
        else:
            raise ValueError(
                "Expecting a geojson-like mapping or sequence of them")

    return {'type': 'FeatureCollection', 'features': features}
566739
public JcCollection<JcValue> asCollection() {
		JcCollection<JcValue> ret = new JcCollection<JcValue>(null, this, null);
		QueryRecorder.recordInvocationConditional(this, "asCollection", ret);
		return ret;
	}