Get GeoJSON featurecollection from DataBC WFS
420198
def get_data(
    dataset,
    query=None,
    crs="epsg:4326",
    bounds=None,
    sortby=None,
    pagesize=10000,
    max_workers=5,
):
    
    param_dicts = define_request(dataset, query, crs, bounds, sortby, pagesize)

    with ThreadPoolExecutor(max_workers=max_workers) as executor:
        results = executor.map(make_request, param_dicts)

    outjson = dict(type="FeatureCollection", features=[])
    for result in results:
        outjson["features"] += result
    return outjson
451170
function serialize (layersCollection, dataviewsCollection) {
  var analysisList = AnalysisService.getAnalysisList(layersCollection, dataviewsCollection);
  return _generateUniqueAnalysisList(analysisList);
}
995967
def v1_fc_get(visid_to_dbid, store, cid):
    '''
    '''
    fc = store.get(visid_to_dbid(cid))
    if fc is None:
        bottle.abort(404, 'Feature collection "%s" does not exist.' % cid)
    return util.fc_to_json(fc)
1309589
function(features) {
        var collection, geometry, isCollection;
        if (features.constructor == Array) {
            collection = features;
            isCollection = true;
        } else {
            collection = [features];
            isCollection = false;
        }
        var pieces = [];
        if (isCollection) {
            pieces.push('GEOMETRYCOLLECTION(');
        }
        for (var i=0, len=collection.length; i<len; ++i) {
            if (isCollection && i>0) {
                pieces.push(',');
            }
            geometry = collection[i].geometry;
            pieces.push(this.extractGeometry(geometry));
        }
        if (isCollection) {
            pieces.push(')');
        }
        return pieces.join('');
    }
1369707
public JSONObject getJsonFormatted(Map<String, String> dataMap) {
        JSONObject oneRowJson = new JSONObject();

        for (int i = 0; i < outTemplate.length; i++) {
            oneRowJson.put(outTemplate[i], dataMap.get(outTemplate[i]));
        }


        return oneRowJson;
    }
135335
def _read_geojson_features(data, features=None, prefix=""):
        """"""
        if features is None:
            features = collections.OrderedDict()
        for i, feature in enumerate(data['features']):
            key = feature.get('id', prefix + str(i))
            feature_type = feature['geometry']['type']
            if feature_type == 'FeatureCollection':
                _read_geojson_features(feature, features, prefix + '.' + key)
            elif feature_type == 'Point':
                value = Circle._convert_point(feature)
            elif feature_type in ['Polygon', 'MultiPolygon']:
                value = Region(feature)
            else:
                # TODO Support all http://geojson.org/geojson-spec.html#geometry-objects
                value = None
            features[key] = value
        return features
1227470
def geojson(self, feature_id):
        """"""
        if self._geojson.get('id', feature_id) == feature_id:
            return self._geojson
        else:
            geo = self._geojson.copy()
            geo['id'] = feature_id
            return geo
577416
def get_wfs_typename(cls, data_source):
        
        is_eocloud = SHConfig().is_eocloud_ogc_url()
        return {
            cls.SENTINEL2_L1C: 'S2.TILE',
            cls.SENTINEL2_L2A: 'SEN4CAP_S2L2A.TILE' if is_eocloud else 'DSS2',
            cls.SENTINEL1_IW: 'S1.TILE' if is_eocloud else 'DSS3',
            cls.SENTINEL1_EW: 'S1_EW.TILE' if is_eocloud else 'DSS3',
            cls.SENTINEL1_EW_SH: 'S1_EW_SH.TILE' if is_eocloud else 'DSS3',
            cls.DEM: 'DSS4',
            cls.MODIS: 'DSS5',
            cls.LANDSAT8: 'L8.TILE' if is_eocloud else 'DSS6',
            # eocloud sources only:
            cls.LANDSAT5: 'L5.TILE',
            cls.LANDSAT7: 'L7.TILE',
            cls.SENTINEL3: 'S3.TILE',
            cls.SENTINEL5P: 'S5p_L2.TILE',
            cls.ENVISAT_MERIS: 'ENV.TILE',
            cls.SENTINEL2_L3B: 'SEN4CAP_S2L3B.TILE',
            cls.LANDSAT8_L2A: 'SEN4CAP_L8L2A.TILE'
        }[data_source]
697495
def probably_geojson(input):
    ''''''
    valid = False
    if not isinstance(input, dict):
        try:
            input = json.loads(input)
        except ValueError:
            return None
    typename = input.get('type', None)
    supported_types = set([
        'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString',
        'MultiPolygon', 'GeometryCollection', 'Feature', 'FeatureCollection'
    ])
    valid = typename in supported_types
    return input if valid else None
974074
function toGeoJSON(json, options = Options) {
  const collection = helpers.featureCollection([])
  json.resourceSets[0].resources.map(result => {
    // Point GeoJSON
    const point = parsePoint(result)
    const bbox = parseBBox(result)
    let confidence = confidenceScore(bbox)
    const properties = {
      confidence,
      authenticationResultCode: json.authenticationResultCode,
      brandLogoUri: json.brandLogoUri,
      copyright: json.copyright,
      entityType: result.entityType,
      matchCodes: result.matchCodes,
      name: result.name,
      statusCode: json.statusCode,
      statusDescription: json.statusDescription,
      traceId: json.traceId,
    }
    Object.keys(result.address).forEach(key => properties[key] = result.address[key])

    // Store Point to GeoJSON feature collection
    if (point) {
      point.bbox = bbox
      point.properties = properties
      collection.features.push(point)
    }
  })
  return collection
}
504217
def from_geojson(cls, filename):
        """"""
        with open(filename) as fd:
            geometry = json.load(fd)

        if 'type' not in geometry:
            raise TypeError("%s is not a valid geojson." % (filename,))

        return cls(to_shape(geometry), WGS84_CRS)
344125
def get_feature_type_info(self):
        
        caps = self.get_capabilities()
        if caps is None:
            return None

        el = caps.find('{http://www.opengis.net/wfs}FeatureTypeList')
        for e in el.findall('{http://www.opengis.net/wfs}FeatureType'):
            if e.find('{http://www.opengis.net/wfs}Name').text == self._feature_name:
                # transform into python dict
                # <Name>sample</Name>
                # <Abstract/>
                # <LatLongBoundingBox maxx="1" maxy="5" ... />
                #
                # becomes:
                #
                # {'Name'               :'sample',
                #  'Abtract'            : None,
                #  'LatLongBoundingBox' : {'maxx':1, 'maxy':5 ... }}
                #
                d = {sube.tag[28:]:sube.text or sube.attrib or None for sube in e.getchildren()}

                # transform LatLongBoundingBox into a Shapely box
                llbb = {k:round(float(v), 4) for k,v in d['LatLongBoundingBox'].iteritems()}
                d['LatLongBoundingBox'] = box(llbb['minx'], llbb['miny'], llbb['maxx'], llbb['maxy'])
                return d

        return None
1265426
def get_datasets_in_nodes():
    

    data_dir = os.path.join(scriptdir, "..", "usgs", "data")

    cwic = map(lambda d: d["datasetName"], api.datasets(None, CWIC_LSI_EXPLORER_CATALOG_NODE)['data'])
    ee = map(lambda d: d["datasetName"], api.datasets(None, EARTH_EXPLORER_CATALOG_NODE)['data'])
    hdds = map(lambda d: d["datasetName"], api.datasets(None, HDDS_EXPLORER_CATALOG_NODE)['data'])
    lpcs = map(lambda d: d["datasetName"], api.datasets(None, LPCS_EXPLORER_CATALOG_NODE)['data'])

    # Create mapping from dataset to node
    datasets = {}
    datasets.update( { ds : "CWIC" for ds in cwic } )
    datasets.update( { ds : "EE" for ds in ee } )
    datasets.update( { ds : "HDDS" for ds in hdds } )
    datasets.update( { ds : "LPCS" for ds in lpcs } )

    datasets_path = os.path.join(data_dir, "datasets.json")
    with open(datasets_path, "w") as f:
        f.write(json.dumps(datasets))

    # Find the datasets with ambiguous nodes
    cwic_ee = [ds for ds in cwic if ds in ee]
    cwic_hdds = [ds for ds in cwic if ds in hdds]
    cwic_lpcs = [ds for ds in cwic if ds in lpcs]
    ee_hdds = [ds for ds in ee if ds in hdds]
    ee_lpcs = [ds for ds in ee if ds in lpcs]
    hdds_lpcs = [ds for ds in hdds if ds in lpcs]
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;
	}
1176481
def to_geojson(products):
        
        feature_list = []
        for i, (product_id, props) in enumerate(products.items()):
            props = props.copy()
            props['id'] = product_id
            poly = geomet.wkt.loads(props['footprint'])
            del props['footprint']
            del props['gmlfootprint']
            # Fix "'datetime' is not JSON serializable"
            for k, v in props.items():
                if isinstance(v, (date, datetime)):
                    props[k] = v.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
            feature_list.append(
                geojson.Feature(geometry=poly, id=i, properties=props)
            )
        return geojson.FeatureCollection(feature_list)
837111
function (featureCollection, indexKey) {
		var features = featureCollection.features;
		var feature;
		var properties;
		var featureIndex = {};
		var value;

		for (var index = 0; index < features.length; ++index) {
			feature = features[index];

			properties = feature.properties;

			value = properties[indexKey];

			// If the value already exists in the index, then either create a GeometryCollection or append the
			// feature's geometry to the existing GeometryCollection
			if (value in featureIndex) {
				var existingFeature = featureIndex[value];

				if (existingFeature.geometry.type !== 'GeometryCollection') {
					featureIndex[value] = {
						type: 'Feature',
						geometry: {
							type: 'GeometryCollection',
							geometries: [feature.geometry, existingFeature.geometry]
						}
					};
				}
				else {
					existingFeature.geometry.geometries.push(feature.geometry);
				}
			}
			else {
				featureIndex[value] = feature;
			}
		}

		return featureIndex;
	}
759233
def get(self, dataset_name):
        
        url = "{0}/{1}".format(self._cached_datasets_url, dataset_name)
        return self._get_json(HTTPMethods.GET, url, self._get_read_key())